From 64cd3dfe89035ff82aed56167547818ddfd15497 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Sun, 12 Jun 2022 17:04:40 +1000 Subject: [PATCH] fix: make ignoreflag persistent (global) and only print error for compose validate --- cmd/root.go | 2 +- cmd/validate_compose.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index b569c404..e16dbc19 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -116,7 +116,7 @@ func init() { "The fastly service ID to use") rootCmd.Flags().StringVarP(&fastlyAPISecretPrefix, "fastly-api-secret-prefix", "A", "fastly-api-", "The fastly secret prefix to use") - rootCmd.Flags().BoolVarP(&ignoreNonStringKeyErrors, "ignore-non-string-key-errors", "", true, + rootCmd.PersistentFlags().BoolVarP(&ignoreNonStringKeyErrors, "ignore-non-string-key-errors", "", true, "Ignore non-string-key docker-compose errors (true by default, subject to change).") } diff --git a/cmd/validate_compose.go b/cmd/validate_compose.go index 650ae9fb..12e4ab8b 100644 --- a/cmd/validate_compose.go +++ b/cmd/validate_compose.go @@ -15,14 +15,14 @@ var ( var validateDockerCompose = &cobra.Command{ Use: "docker-compose", - Aliases: []string{"compose", "docker", "dc"}, + Aliases: []string{"compose", "dc"}, Short: "Verify docker-compose file for compatability with this tool", Run: func(cmd *cobra.Command, args []string) { // @TODO: ignoreNonStringKeyErrors is `true` by default because Lagoon doesn't enforce // docker-compose compliance yet err := ValidateDockerCompose(dockerComposeFile, ignoreNonStringKeyErrors) if err != nil { - fmt.Println(fmt.Sprintf("There is an issue with the docker-compose file, see errors below\n%s", err.Error())) + fmt.Println(err.Error()) os.Exit(1) } },