Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.

Commit b32ae76

Browse files
authored
fix: allowing domain to be added including a scheme (#72)
1 parent 35cef71 commit b32ae76

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

apis/mpas/v1alpha1/repository_types.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ type RepositorySpec struct {
4848
Visibility string `json:"visibility,omitempty"`
4949
//+kubebuilder:default:=true
5050
IsOrganization bool `json:"isOrganization"`
51+
// Domain specifies an optional domain address to be used instead of the defaults like github.com.
52+
// Must NOT contain the scheme.
5153
//+optional
54+
//+kubebuilder:validation:Pattern="^\\w+(\\.|:[0-9]).*$"
5255
Domain string `json:"domain,omitempty"`
5356
//+optional
5457
Maintainers []string `json:"maintainers,omitempty"`
@@ -102,7 +105,7 @@ func (in Repository) GetRepositoryURL() string {
102105
return fmt.Sprintf("%s:%s/%s", in.Spec.Domain, in.Spec.Owner, in.GetName())
103106
}
104107

105-
return fmt.Sprintf("%s/%s/%s", in.Spec.Domain, in.Spec.Owner, in.GetName())
108+
return fmt.Sprintf("https://%s/%s/%s", in.Spec.Domain, in.Spec.Owner, in.GetName())
106109
}
107110

108111
domain := ""

config/crd/bases/mpas.ocm.software_repositories.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ spec:
7171
default: main
7272
type: string
7373
domain:
74+
description: Domain specifies an optional domain address to be used
75+
instead of the defaults like github.com. Must NOT contain the scheme.
76+
pattern: ^\w+(\.|:[0-9]).*$
7477
type: string
7578
existingRepositoryPolicy:
7679
default: adopt

pkg/providers/github/github.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ func (c *Client) CreateBranchProtection(ctx context.Context, obj mpasv1alpha1.Re
8888
if err != nil {
8989
return fmt.Errorf("failed to retrieve token: %w", err)
9090
}
91+
9192
ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: string(token)})
9293
tc := oauth2.NewClient(context.Background(), ts)
93-
9494
g := ggithub.NewClient(tc)
9595

9696
if _, _, err := g.Repositories.UpdateBranchProtection(ctx, obj.Spec.Owner, obj.Name, obj.Spec.DefaultBranch, &ggithub.ProtectionRequest{

0 commit comments

Comments
 (0)