Skip to content

Commit

Permalink
Merge pull request #240 from web-seven/238-bugfunctions-crossplane-fu…
Browse files Browse the repository at this point in the history
…nction-load-pulls-from-overlock-namespace-even-when-default-registry-configured-in-another-namespace

fixed registy domain composing regarding namespace
  • Loading branch information
evghen1 authored Nov 8, 2024
2 parents 571cd6b + 8f4e879 commit 768d3a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/policy/kyverno.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func deleteKyvernoRegistryPolicies(ctx context.Context, config *rest.Config, reg
Version: "v1",
Resource: "clusterpolicies",
}
scplcName := "overlock-local-reg-" + registry.Name
scplcName := "overlock." + registry.Name
err = dynamicClient.Resource(gvr).Delete(ctx, scplcName, metav1.DeleteOptions{})
if err != nil {
return err
Expand Down
11 changes: 8 additions & 3 deletions internal/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (
RegistryServerLabel = "overlock-registry-server-url"
DefaultRemoteDomain = "xpkg.upbound.io"
LocalServiceName = "registry"
DefaultLocalDomain = LocalServiceName + "." + namespace.Namespace + ".svc.cluster.local"
defaultLocalDomain = LocalServiceName + ".%s.svc.cluster.local"
AuthConfigLabel = "overlock-registry-auth-config"
)

Expand Down Expand Up @@ -98,9 +98,9 @@ func NewLocal() Registry {
registry := Registry{
Default: false,
Local: true,
Server: DefaultLocalDomain,
Name: "registry.local",
}
registry.Server = registry.LocalDomain()
return registry
}

Expand Down Expand Up @@ -348,7 +348,7 @@ func (r *Registry) WithContext(c string) {
// Domain of primary registry
func (r *Registry) Domain() string {
if r.Local {
return DefaultLocalDomain
return r.LocalDomain()
}
url, err := url.Parse(r.Server)
if err != nil {
Expand All @@ -357,6 +357,11 @@ func (r *Registry) Domain() string {
return url.Hostname()
}

// Local domain composed with parameters
func (r *Registry) LocalDomain() string {
return fmt.Sprintf(defaultLocalDomain, namespace.Namespace)
}

// Creates specs of Secret base on Registry data
func (r *Registry) SecretSpec() corev1.Secret {
regConf, _ := json.Marshal(r.Config)
Expand Down

0 comments on commit 768d3a4

Please sign in to comment.