Skip to content

Commit

Permalink
move setting of encrypted variables to a function
Browse files Browse the repository at this point in the history
  • Loading branch information
ilia-medvedev-codefresh committed Mar 10, 2024
1 parent 38c1e4c commit 148bebb
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions codefresh/resource_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,11 +754,7 @@ func mapPipelineToResource(pipeline cfclient.Pipeline, d *schema.ResourceData) e

if ok {
if len(encryptedVariables) > 0 {
// Iterate over variables and set the value from resource data
for k := range encryptedVariables {
encryptedVariables[k] =
d.Get(fmt.Sprintf("spec.0.trigger.%d.encrypted_variables.%s", triggerIndex, k)).(string)
}
setEncryptedVariablesValuesFromResource(d, encryptedVariables, fmt.Sprintf("spec.0.trigger.%d.encrypted_variables",triggerIndex))
}
}
}
Expand Down Expand Up @@ -1238,3 +1234,15 @@ func convertOnCreateBranchAttributeToPipelineFormat(src string) string {
return "_" + strings.ToLower(w)
})
}

func setEncryptedVariablesValuesFromResource(d *schema.ResourceData, flattenedVariables map[string]string, schemaPath string) error {

if len(flattenedVariables) > 0 {
// Iterate over variables and set the value from resource data
for k := range flattenedVariables {
flattenedVariables[k] = d.Get(fmt.Sprintf("%s.%s", schemaPath, k)).(string)
}
}

return nil
}

0 comments on commit 148bebb

Please sign in to comment.