This is an automated email from the ASF dual-hosted git repository.
squakez pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/main by this push:
new db06fdaac fix(registry): only create secret when var provided
db06fdaac is described below
commit db06fdaac873bf3b02f890cc9eedc63d7731d03a
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Fri Oct 9 08:41:12 2026 +0200
fix(registry): only create secret when var provided
---
.github/actions/registry-setting/registry.yaml | 2 ++
pkg/install/registry.go | 23 +++++++++++++++--------
pkg/install/registry_test.go | 22 ++++++++++++++++------
pkg/resources/resources/registry/deploy.yaml | 4 +++-
4 files changed, 36 insertions(+), 15 deletions(-)
diff --git a/.github/actions/registry-setting/registry.yaml
b/.github/actions/registry-setting/registry.yaml
index 3e11f8284..18a34e2b9 100644
--- a/.github/actions/registry-setting/registry.yaml
+++ b/.github/actions/registry-setting/registry.yaml
@@ -61,6 +61,8 @@ spec:
- name: registry
image: registry:3
env:
+ - name: REGISTRY_LOG_LEVEL
+ value: info
- name: REGISTRY_HTTP_ADDR
value: 0.0.0.0:443
- name: REGISTRY_HTTP_TLS_CERTIFICATE
diff --git a/pkg/install/registry.go b/pkg/install/registry.go
index 1247db3de..45bf82ddc 100644
--- a/pkg/install/registry.go
+++ b/pkg/install/registry.go
@@ -42,6 +42,9 @@ import (
const serviceRegistryClusterIPTimeout = 30 * time.Second
const serviceRegistryClusterIPPollingTime = 500 * time.Millisecond
+//nolint:gosec // not a secret
+const registrySecretDefaultName = "ck-dev-registry"
+
type registryConf struct {
clusterIP string
insecure string
@@ -145,19 +148,23 @@ func OperatorStartupRegistry(ctx context.Context, c
client.Client, withSecret bo
return nil, fmt.Errorf("could not get development container
registry Service IP: %w", err)
}
- dockerRegistrySecret, err := kubernetes.DockerRegistrySecret(ctx,
deployNamespace, "ck-dev-registry", clusterIP, "admin", "password")
- if err != nil {
- return nil, fmt.Errorf("could not generate development
container registry push secret: %w", err)
- }
- dockerRegistrySecret.SetOwnerReferences([]metav1.OwnerReference{*ref})
- if err := replace(ctx, c, dockerRegistrySecret); err != nil {
- return nil, fmt.Errorf("could not create development container
registry push secret: %w", err)
+ dockerRegistrySecretName := ""
+ if withSecret {
+ dockerRegistrySecret, err :=
kubernetes.DockerRegistrySecret(ctx, deployNamespace,
registrySecretDefaultName, clusterIP, "admin", "password")
+ if err != nil {
+ return nil, fmt.Errorf("could not generate development
container registry push secret: %w", err)
+ }
+
dockerRegistrySecret.SetOwnerReferences([]metav1.OwnerReference{*ref})
+ if err := replace(ctx, c, dockerRegistrySecret); err != nil {
+ return nil, fmt.Errorf("could not create development
container registry push secret: %w", err)
+ }
+ dockerRegistrySecretName = dockerRegistrySecret.GetName()
}
return ®istryConf{
clusterIP: clusterIP,
insecure: "false",
- dockerRegistrySecretName: dockerRegistrySecret.GetName(),
+ dockerRegistrySecretName: dockerRegistrySecretName,
}, nil
}
diff --git a/pkg/install/registry_test.go b/pkg/install/registry_test.go
index 4fc39ed31..cd8c1836b 100644
--- a/pkg/install/registry_test.go
+++ b/pkg/install/registry_test.go
@@ -248,14 +248,20 @@ func TestReplace(t *testing.T) {
})
}
+func TestOperatorStartupRegistryWithSecret(t *testing.T) {
+ testOperatorStartupRegistry(t, true)
+}
+
func TestOperatorStartupRegistry(t *testing.T) {
+ testOperatorStartupRegistry(t, false)
+}
+
+func testOperatorStartupRegistry(t *testing.T, withSecret bool) {
t.Setenv("NAMESPACE", "camel-k")
crtSecret := &corev1.Secret{
- ObjectMeta: metav1.ObjectMeta{
- Name: "fake-secret",
- Namespace: "camel-k",
- },
+ Name: "fake-secret",
+ Namespace: "camel-k",
Data: map[string][]byte{
"foo": []byte("bar"),
},
@@ -271,7 +277,7 @@ func TestOperatorStartupRegistry(t *testing.T) {
conf, err := OperatorStartupRegistry(
context.Background(),
fakeClient,
- false,
+ withSecret,
crtSecret,
)
@@ -280,7 +286,11 @@ func TestOperatorStartupRegistry(t *testing.T) {
assert.Equal(t, "10.96.0.20", conf.clusterIP)
assert.Equal(t, "false", conf.insecure)
- assert.Equal(t, "ck-dev-registry", conf.dockerRegistrySecretName)
+ if withSecret {
+ assert.Equal(t, "ck-dev-registry",
conf.dockerRegistrySecretName)
+ } else {
+ assert.Equal(t, "", conf.dockerRegistrySecretName)
+ }
}
// Useful to simulate Kubernetes IP assignment.
diff --git a/pkg/resources/resources/registry/deploy.yaml
b/pkg/resources/resources/registry/deploy.yaml
index 51d8e61d1..9a57d7b88 100644
--- a/pkg/resources/resources/registry/deploy.yaml
+++ b/pkg/resources/resources/registry/deploy.yaml
@@ -32,6 +32,8 @@ spec:
- name: registry
image: registry:3
env:
+ - name: REGISTRY_LOG_LEVEL
+ value: info
- name: REGISTRY_HTTP_ADDR
value: 0.0.0.0:443
- name: REGISTRY_HTTP_TLS_CERTIFICATE
@@ -48,7 +50,7 @@ spec:
# - name: REGISTRY_AUTH_HTPASSWD_REALM
# value: Registry Realm
# - name: REGISTRY_AUTH_HTPASSWD_PATH
- # value: /auth/htpasswd
+ # value: /auth/htpasswd
ports:
- containerPort: 5000
name: registry