Skip to content

Commit

Permalink
Merge pull request #861 from wyardley/wyardley/860
Browse files Browse the repository at this point in the history
feat: add verbose flag for pipeline values
  • Loading branch information
elliotforbes authored Mar 23, 2023
2 parents d3a9440 + dc43137 commit 651f295
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"net/url"
"os"
"strings"

"github.com/CircleCI-Public/circleci-cli/api/rest"
Expand Down Expand Up @@ -33,6 +34,7 @@ type configOptions struct {
// Used to for compatibility with `circleci config validate --path`
var configPath string
var ignoreDeprecatedImages bool // should we ignore deprecated images warning
var verboseOutput bool // Enable extra debugging output

var configAnnotations = map[string]string{
"<path>": "The path to your config (use \"-\" for STDIN)",
Expand Down Expand Up @@ -86,6 +88,7 @@ func newConfigCommand(config *settings.Config) *cobra.Command {
}
validateCommand.Annotations["<path>"] = configAnnotations["<path>"]
validateCommand.PersistentFlags().StringVarP(&configPath, "config", "c", ".circleci/config.yml", "path to config file")
validateCommand.PersistentFlags().BoolVarP(&verboseOutput, "verbose", "v", false, "Enable verbose output")
validateCommand.PersistentFlags().BoolVar(&ignoreDeprecatedImages, "ignore-deprecated-images", false, "ignores the deprecated images error")
if err := validateCommand.PersistentFlags().MarkHidden("config"); err != nil {
panic(err)
Expand Down Expand Up @@ -153,8 +156,9 @@ 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)
if verboseOutput {
printValues(values)
}

var orgID string
orgID, _ = flags.GetString("org-id")
Expand Down Expand Up @@ -217,7 +221,6 @@ 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")
Expand Down Expand Up @@ -262,8 +265,9 @@ func migrateConfig(opts configOptions) error {
}

func printValues(values pipeline.Values) {
fmt.Fprintln(os.Stderr, "Processing config with following values:")
for key, value := range values {
fmt.Printf("\t%s:\t%s", key, value)
fmt.Fprintf(os.Stderr, "%-18s %s\n", key+":", value)
}
}

Expand Down

0 comments on commit 651f295

Please sign in to comment.