Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion apis/mpas/v1alpha1/repository_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ type RepositorySpec struct {
Visibility string `json:"visibility,omitempty"`
//+kubebuilder:default:=true
IsOrganization bool `json:"isOrganization"`
// Domain specifies an optional domain address to be used instead of the defaults like github.com.
// Must NOT contain the scheme.
//+optional
//+kubebuilder:validation:Pattern="^\\w+(\\.|:[0-9]).*$"
Domain string `json:"domain,omitempty"`
//+optional
Maintainers []string `json:"maintainers,omitempty"`
Expand Down Expand Up @@ -102,7 +105,7 @@ func (in Repository) GetRepositoryURL() string {
return fmt.Sprintf("%s:%s/%s", in.Spec.Domain, in.Spec.Owner, in.GetName())
}

return fmt.Sprintf("%s/%s/%s", in.Spec.Domain, in.Spec.Owner, in.GetName())
return fmt.Sprintf("https://%s/%s/%s", in.Spec.Domain, in.Spec.Owner, in.GetName())
}

domain := ""
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/mpas.ocm.software_repositories.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ spec:
default: main
type: string
domain:
description: Domain specifies an optional domain address to be used
instead of the defaults like github.com. Must NOT contain the scheme.
pattern: ^\w+(\.|:[0-9]).*$
type: string
existingRepositoryPolicy:
default: adopt
Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ func (c *Client) CreateBranchProtection(ctx context.Context, obj mpasv1alpha1.Re
if err != nil {
return fmt.Errorf("failed to retrieve token: %w", err)
}

ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: string(token)})
tc := oauth2.NewClient(context.Background(), ts)

g := ggithub.NewClient(tc)

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