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

Commit 05c6d91

Browse files
committed
fix: allowing domain to be added including a scheme
1 parent 35cef71 commit 05c6d91

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

apis/mpas/v1alpha1/repository_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (in Repository) GetRepositoryURL() string {
102102
return fmt.Sprintf("%s:%s/%s", in.Spec.Domain, in.Spec.Owner, in.GetName())
103103
}
104104

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

108108
domain := ""

controllers/mpas/repository_controller.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"context"
99
"errors"
1010
"fmt"
11+
"net/url"
1112

1213
eventv1 "github.com/fluxcd/pkg/apis/event/v1beta1"
1314
"github.com/fluxcd/pkg/apis/meta"
@@ -55,6 +56,17 @@ func (r *RepositoryReconciler) Reconcile(ctx context.Context, req ctrl.Request)
5556
return ctrl.Result{}, fmt.Errorf("failed to get component object: %w", err)
5657
}
5758

59+
if obj.Spec.Domain != "" {
60+
u, err := url.Parse(obj.Spec.Domain)
61+
if err != nil {
62+
return ctrl.Result{}, fmt.Errorf("failed to parse domain url: %w", err)
63+
}
64+
65+
if u.Scheme != "" {
66+
return ctrl.Result{}, fmt.Errorf("domain URL must be provided without a scheme")
67+
}
68+
}
69+
5870
patchHelper := patch.NewSerialPatcher(obj, r.Client)
5971

6072
// Always attempt to patch the object and status after each reconciliation.

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)