@@ -11,6 +11,7 @@ import (
1111 "regexp"
1212 "strings"
1313
14+ "github.com/Masterminds/semver/v3"
1415 "github.com/defenseunicorns/zarf/src/types/extensions"
1516 fluxHelmCtrl "github.com/fluxcd/helm-controller/api/v2beta1"
1617 fluxSrcCtrl "github.com/fluxcd/source-controller/api/v1beta2"
@@ -20,18 +21,7 @@ import (
2021
2122var nonAlphnumeric = regexp .MustCompile ("[^a-zA-Z0-9]+" )
2223
23- func manifestZarfCredentials () corev1.Secret {
24- return corev1.Secret {
25- TypeMeta : metav1.TypeMeta {
26- Kind : "Secret" ,
27- APIVersion : "v1" ,
28- },
29- ObjectMeta : metav1.ObjectMeta {
30- Namespace : bb ,
31- Name : "zarf-credentials" ,
32- },
33- StringData : map [string ]string {
34- "values.yaml" : `
24+ const bbV1ZarfCredentialsValues = `
3525registryCredentials:
3626 registry: "###ZARF_REGISTRY###"
3727 username: "zarf-pull"
4232 # -- HTTP git credentials, both username and password must be provided
4333 username: "###ZARF_GIT_PUSH###"
4434 password: "###ZARF_GIT_AUTH_PUSH###"
35+ # -- Big Bang v1 Kyverno Support
4536kyvernopolicies:
4637 values:
4738 exclude:
4839 any:
4940 - resources:
5041 namespaces:
51- - zarf # don't have kyverno prevent zarf from doing zarf things
52- ` ,
42+ - zarf # don't have Kyverno prevent Zarf from doing zarf things
43+ `
44+
45+ const bbV2ZarfCredentialsValues = `
46+ registryCredentials:
47+ registry: "###ZARF_REGISTRY###"
48+ username: "zarf-pull"
49+ password: "###ZARF_REGISTRY_AUTH_PULL###"
50+ git:
51+ existingSecret: "private-git-server" # -- Chart created secrets with user defined values
52+ credentials:
53+ # -- HTTP git credentials, both username and password must be provided
54+ username: "###ZARF_GIT_PUSH###"
55+ password: "###ZARF_GIT_AUTH_PUSH###"
56+ # -- Big Bang v2 Kyverno Support
57+ kyvernoPolicies:
58+ values:
59+ exclude:
60+ any:
61+ - resources:
62+ namespaces:
63+ - zarf # don't have Kyverno prevent Zarf from doing zarf things
64+ `
65+
66+ func manifestZarfCredentials (version string ) corev1.Secret {
67+ values := bbV1ZarfCredentialsValues
68+
69+ semverVersion , err := semver .NewVersion (version )
70+ if err != nil && semverVersion .Major () == 2 {
71+ values = bbV2ZarfCredentialsValues
72+ }
73+
74+ return corev1.Secret {
75+ TypeMeta : metav1.TypeMeta {
76+ Kind : "Secret" ,
77+ APIVersion : "v1" ,
78+ },
79+ ObjectMeta : metav1.ObjectMeta {
80+ Namespace : bb ,
81+ Name : "zarf-credentials" ,
82+ },
83+ StringData : map [string ]string {
84+ "values.yaml" : values ,
5385 },
5486 }
5587}
0 commit comments