Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add verbose flag for pipeline values #861

Merged
merged 1 commit into from
Mar 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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