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

Commit 988480e

Browse files
committed
feat: add insecure flag to force http on the domain
1 parent b32ae76 commit 988480e

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

apis/mpas/v1alpha1/repository_types.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ type RepositorySpec struct {
5353
//+optional
5454
//+kubebuilder:validation:Pattern="^\\w+(\\.|:[0-9]).*$"
5555
Domain string `json:"domain,omitempty"`
56+
// Insecure should be defined if `domain` is not HTTPS.
57+
//+optional
58+
Insecure bool `json:"insecure,omitempty"`
5659
//+optional
5760
Maintainers []string `json:"maintainers,omitempty"`
5861
//+optional
@@ -105,7 +108,12 @@ func (in Repository) GetRepositoryURL() string {
105108
return fmt.Sprintf("%s:%s/%s", in.Spec.Domain, in.Spec.Owner, in.GetName())
106109
}
107110

108-
return fmt.Sprintf("https://%s/%s/%s", in.Spec.Domain, in.Spec.Owner, in.GetName())
111+
scheme := "https"
112+
if in.Spec.Insecure {
113+
scheme = "http"
114+
}
115+
116+
return fmt.Sprintf("%s://%s/%s/%s", scheme, in.Spec.Domain, in.Spec.Owner, in.GetName())
109117
}
110118

111119
domain := ""

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ spec:
8383
- adopt
8484
- fail
8585
type: string
86+
insecure:
87+
description: Insecure should be defined if `domain` is not HTTPS.
88+
type: boolean
8689
interval:
8790
type: string
8891
isOrganization:

pkg/providers/gitea/gitea.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,7 @@ func (c *Client) CreateRepository(ctx context.Context, obj mpasv1alpha1.Reposito
6565
return fmt.Errorf("token '%s' not found in secret", tokenKey)
6666
}
6767

68-
domain := defaultDomain
69-
if obj.Spec.Domain != "" {
70-
domain = obj.Spec.Domain
71-
}
72-
73-
client, err := gitea.NewClient(domain, gitea.SetToken(string(token)))
68+
client, err := gitea.NewClient(obj.GetRepositoryURL(), gitea.SetToken(string(token)))
7469
if err != nil {
7570
return fmt.Errorf("failed to create gitea client: %w", err)
7671
}

0 commit comments

Comments
 (0)