Skip to content

Commit

Permalink
Merge pull request #297 from projectsyn/fix/remvoe-prodtecte
Browse files Browse the repository at this point in the history
Do not set CI variables as "protected"
  • Loading branch information
HappyTetrahedron authored Jul 26, 2024
2 parents 2ddcc48 + 7f5d47f commit 487988f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion controllers/cluster_compile_pipeline_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func ensureClusterCiVariable(t *synv1alpha1.Tenant, c *synv1alpha1.Cluster) bool
if remove {
list, changed = removeEnvVar(envVarName, template.CIVariables)
} else {
list, changed = updateEnvVarValueFrom(envVarName, c.Spec.GitRepoTemplate.AccessToken.SecretRef, SECRET_KEY_GITLAB_TOKEN, true, template.CIVariables)
list, changed = updateEnvVarValueFrom(envVarName, c.Spec.GitRepoTemplate.AccessToken.SecretRef, SECRET_KEY_GITLAB_TOKEN, template.CIVariables)
}

if changed {
Expand Down
2 changes: 1 addition & 1 deletion controllers/cluster_compile_pipeline_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ func Test_CiVariableUpdated_IfEnabled(t *testing.T) {
assert.Equal(t, mod_tenant.Spec.GitRepoTemplate.CIVariables[0].ValueFrom.SecretKeyRef.Name, "my-secret")
assert.Equal(t, mod_tenant.Spec.GitRepoTemplate.CIVariables[0].ValueFrom.SecretKeyRef.Key, "token")
assert.Equal(t, mod_tenant.Spec.GitRepoTemplate.CIVariables[0].GitlabOptions.Masked, true)
assert.Equal(t, mod_tenant.Spec.GitRepoTemplate.CIVariables[0].GitlabOptions.Protected, true)
assert.Equal(t, mod_tenant.Spec.GitRepoTemplate.CIVariables[0].GitlabOptions.Protected, false)
assert.Equal(t, mod_tenant.Spec.GitRepoTemplate.CIVariables[0].GitlabOptions.Raw, true)
}
func Test_KeepListInAlphabeticalOrder(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion controllers/tenant_compile_pipeline_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (r *TenantCompilePipelineReconciler) ensureCiVariables(t *synv1alpha1.Tenan
changed = ch
list, ch = updateEnvVarValue(CI_VARIABLE_CLUSTERS, clusterList, list)
changed = changed || ch
list, ch = updateEnvVarValueFrom(CI_VARIABLE_API_TOKEN, t.Name, SECRET_KEY_API_TOKEN, false, list)
list, ch = updateEnvVarValueFrom(CI_VARIABLE_API_TOKEN, t.Name, SECRET_KEY_API_TOKEN, list)
changed = changed || ch

if changed {
Expand Down
7 changes: 3 additions & 4 deletions controllers/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,16 @@ func updateEnvVarValue(name string, value string, envVars []synv1alpha1.EnvVar)
}
return envVars, changed
}
func updateEnvVarValueFrom(name string, secret string, key string, protected bool, envVars []synv1alpha1.EnvVar) ([]synv1alpha1.EnvVar, bool) {
func updateEnvVarValueFrom(name string, secret string, key string, envVars []synv1alpha1.EnvVar) ([]synv1alpha1.EnvVar, bool) {
index := envVarIndex(name, envVars)
changed := false
if index < 0 {
changed = true
envVars = append(envVars, synv1alpha1.EnvVar{
Name: name,
GitlabOptions: synv1alpha1.EnvVarGitlabOptions{
Masked: true,
Raw: true,
Protected: protected,
Masked: true,
Raw: true,
},
ValueFrom: &synv1alpha1.EnvVarSource{
SecretKeyRef: &v1.SecretKeySelector{
Expand Down

0 comments on commit 487988f

Please sign in to comment.