Skip to content

Commit 7c8645a

Browse files
fix: use insecureSkipTLS in generated OCI secret
1 parent 62ec443 commit 7c8645a

2 files changed

Lines changed: 37 additions & 7 deletions

File tree

internal/cmd/cli/apply/apply.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -758,13 +758,13 @@ func newOCISecret(manifestID string, bundle *fleet.Bundle, opts ocistorage.OCIOp
758758
},
759759
},
760760
Data: map[string][]byte{
761-
ocistorage.OCISecretReference: []byte(opts.Reference),
762-
ocistorage.OCISecretUsername: []byte(opts.Username),
763-
ocistorage.OCISecretPassword: []byte(opts.Password),
764-
ocistorage.OCISecretAgentUsername: []byte(opts.AgentUsername),
765-
ocistorage.OCISecretAgentPassword: []byte(opts.AgentPassword),
766-
ocistorage.OCISecretBasicHTTP: []byte(strconv.FormatBool(opts.BasicHTTP)),
767-
ocistorage.OCISecretInsecure: []byte(strconv.FormatBool(opts.InsecureSkipTLS)),
761+
ocistorage.OCISecretReference: []byte(opts.Reference),
762+
ocistorage.OCISecretUsername: []byte(opts.Username),
763+
ocistorage.OCISecretPassword: []byte(opts.Password),
764+
ocistorage.OCISecretAgentUsername: []byte(opts.AgentUsername),
765+
ocistorage.OCISecretAgentPassword: []byte(opts.AgentPassword),
766+
ocistorage.OCISecretBasicHTTP: []byte(strconv.FormatBool(opts.BasicHTTP)),
767+
ocistorage.OCISecretInsecureSkipTLS: []byte(strconv.FormatBool(opts.InsecureSkipTLS)),
768768
},
769769
Type: fleet.SecretTypeOCIStorage,
770770
}

internal/cmd/cli/apply/apply_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ package apply
33
import (
44
"testing"
55

6+
"github.com/rancher/fleet/internal/ocistorage"
67
fleet "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1"
8+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
9+
"k8s.io/apimachinery/pkg/types"
710
)
811

912
func Test_getKindNS(t *testing.T) {
@@ -87,3 +90,30 @@ data:
8790
})
8891
}
8992
}
93+
94+
func Test_newOCISecret_usesInsecureSkipTLSKey(t *testing.T) {
95+
bundle := &fleet.Bundle{
96+
ObjectMeta: metav1.ObjectMeta{
97+
Name: "bundle",
98+
Namespace: "fleet-local",
99+
UID: types.UID("bundle-uid"),
100+
},
101+
}
102+
103+
secret := newOCISecret("manifest-id", bundle, ocistorage.OCIOpts{
104+
Reference: "registry.example.com/test",
105+
Username: "user",
106+
Password: "pass",
107+
AgentUsername: "agent-user",
108+
AgentPassword: "agent-pass",
109+
InsecureSkipTLS: true,
110+
})
111+
112+
if got := string(secret.Data[ocistorage.OCISecretInsecureSkipTLS]); got != "true" {
113+
t.Fatalf("expected insecureSkipTLS=true, got %q", got)
114+
}
115+
116+
if _, ok := secret.Data[ocistorage.OCISecretInsecure]; ok {
117+
t.Fatal("did not expect legacy insecure key in generated secret")
118+
}
119+
}

0 commit comments

Comments
 (0)