Skip to content

Commit

Permalink
Merge pull request #855 from CircleCI-Public/DEVEX-545-print-filled-p…
Browse files Browse the repository at this point in the history
…ipeline-values-on-cli-commands-for-config-validate-process

task: Print filled pipeline values on validate & process
  • Loading branch information
JulesFaucherre authored Mar 3, 2023
2 parents 99ef295 + be54c96 commit 1c116d3
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,19 @@ func validateConfig(opts configOptions, flags *pflag.FlagSet) error {
}

//if no orgId provided use org slug
values := pipeline.LocalPipelineValues()
fmt.Println("Validating config with following values")
printValues(values)

orgID, _ := flags.GetString("org-id")
if strings.TrimSpace(orgID) != "" {
response, err = api.ConfigQuery(opts.cl, path, orgID, nil, pipeline.LocalPipelineValues())
response, err = api.ConfigQuery(opts.cl, path, orgID, nil, values)
if err != nil {
return err
}
} else {
orgSlug, _ := flags.GetString("org-slug")
response, err = api.ConfigQueryLegacy(opts.cl, path, orgSlug, nil, pipeline.LocalPipelineValues())
response, err = api.ConfigQueryLegacy(opts.cl, path, orgSlug, nil, values)
if err != nil {
return err
}
Expand Down Expand Up @@ -192,15 +196,19 @@ func processConfig(opts configOptions, flags *pflag.FlagSet) error {
}

//if no orgId provided use org slug
values := pipeline.LocalPipelineValues()
fmt.Println("Processing config with following values")
printValues(values)

orgID, _ := flags.GetString("org-id")
if strings.TrimSpace(orgID) != "" {
response, err = api.ConfigQuery(opts.cl, opts.args[0], orgID, params, pipeline.LocalPipelineValues())
response, err = api.ConfigQuery(opts.cl, opts.args[0], orgID, params, values)
if err != nil {
return err
}
} else {
orgSlug, _ := flags.GetString("org-slug")
response, err = api.ConfigQueryLegacy(opts.cl, opts.args[0], orgSlug, params, pipeline.LocalPipelineValues())
response, err = api.ConfigQueryLegacy(opts.cl, opts.args[0], orgSlug, params, values)
if err != nil {
return err
}
Expand All @@ -227,3 +235,9 @@ func packConfig(opts configOptions) error {
func migrateConfig(opts configOptions) error {
return proxy.Exec([]string{"config", "migrate"}, opts.args)
}

func printValues(values pipeline.Values) {
for key, value := range values {
fmt.Printf("\t%s:\t%s", key, value)
}
}

0 comments on commit 1c116d3

Please sign in to comment.