@@ -127,6 +127,10 @@ func CreateSecretForGitResolver(secretData string) {
127127 cmd .MustSucceed ("oc" , "create" , "secret" , "generic" , "github-auth-secret" , "--from-literal" , "github-auth-key=" + secretData , "-n" , "openshift-pipelines" )
128128}
129129
130+ func CreateSecretInNamespace (secretData , secretName , namespace string ) {
131+ cmd .MustSucceed ("oc" , "create" , "secret" , "generic" , secretName , "--from-literal" , "private-repo-token=" + secretData , "-n" , namespace )
132+ }
133+
130134func CreateSecretForWebhook (tokenSecretData , webhookSecretData , namespace string ) {
131135 cmd .MustSucceed ("oc" , "create" , "secret" , "generic" , "gitlab-webhook-config" , "--from-literal" , "provider.token=" + tokenSecretData , "--from-literal" , "webhook.secret=" + webhookSecretData , "-n" , namespace )
132136}
@@ -168,18 +172,4 @@ func CopySecret(secretName string, sourceNamespace string, destNamespace string)
168172 cmdOutput := cmd .MustSucceed ("bash" , "-c" , fmt .Sprintf (`echo '%s' | jq 'del(.metadata["namespace", "creationTimestamp", "resourceVersion", "selfLink", "uid", "annotations"]) | .data |= with_entries(if .key == "github-auth-key" then .key = "token" else . end)'` , secretJson )).Stdout ()
169173 cmd .MustSucceed ("bash" , "-c" , fmt .Sprintf (`echo '%s' | kubectl apply -n %s -f -` , cmdOutput , destNamespace ))
170174 log .Printf ("Successfully copied secret %s from %s to %s" , secretName , sourceNamespace , destNamespace )
171- }
172-
173- func CopySecretWithNewName (secretName string , sourceNamespace string , destNamespace string , newSecretName string ) {
174- secretJson := cmd .MustSucceed ("oc" , "get" , "secret" , secretName , "-n" , sourceNamespace , "-o" , "json" ).Stdout ()
175- cmdOutput := cmd .MustSucceed ("bash" , "-c" , fmt .Sprintf (`echo '%s' | jq 'del(.metadata["namespace", "creationTimestamp", "resourceVersion", "selfLink", "uid", "annotations"]) | .metadata.name = "%s"'` , secretJson , newSecretName )).Stdout ()
176- cmd .MustSucceed ("bash" , "-c" , fmt .Sprintf (`echo '%s' | kubectl apply -n %s -f -` , cmdOutput , destNamespace ))
177- log .Printf ("Successfully copied secret %s from %s to %s as %s" , secretName , sourceNamespace , destNamespace , newSecretName )
178- }
179-
180- func PatchSecretTokenKey (secretName string , namespace string , tokenKey string ) {
181- secretJson := cmd .MustSucceed ("oc" , "get" , "secret" , secretName , "-n" , namespace , "-o" , "json" ).Stdout ()
182- cmdOutput := cmd .MustSucceed ("bash" , "-c" , fmt .Sprintf (`echo '%s' | jq '.data |= with_entries(if .key == "github-auth-key" or .key == "token" then .key = "%s" else . end)'` , secretJson , tokenKey )).Stdout ()
183- cmd .MustSucceed ("bash" , "-c" , fmt .Sprintf (`echo '%s' | kubectl apply -n %s -f -` , cmdOutput , namespace ))
184- log .Printf ("Successfully patched secret %s in namespace %s to set token key to %s" , secretName , namespace , tokenKey )
185- }
175+ }
0 commit comments