From 799730dbaeb4026c77d601a9b867c42565c06bab Mon Sep 17 00:00:00 2001 From: Pedro Tashima <23709916+tashima42@users.noreply.github.com> Date: Fri, 2 Aug 2024 01:03:11 -0300 Subject: [PATCH] fix flags --- README.md | 16 ++++++++++++++++ cmd/release/cmd/generate.go | 2 +- cmd/release/cmd/root.go | 22 +++++++++++++--------- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 115a96e0..79057912 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,22 @@ ECM Distro Tools is a collection of utilities that provide for easier administration, management, and interaction with the great Rancher ecosystems, including RKE2 and K3s. +## Release CLI +### Configuration +**New Configuration File** +```bash +release config gen > $HOME/.ecm-distro-tools/config.json +``` +**Load config from custom path** +```bash +release config view -c ./config.json +``` +**Load config from string +```bash +release generate rancher missing-images-list v2.7.15 -C '{"rancher": { "versions": {"v2.7.15": {"check_images": ["rancher/rancher:v2.7.15"]}}}}' -i "https://prime.ribs.rancher.io/rancher/v2.7.15/rancher-images.txt" --ignore-validate +``` + + ## Building There's a mix of code in this repository. The shell scripts and shell libraries reside in the `bin` directory and are ready to use. The Go programs are rooted in the `cmd` directory and need to be compiled. diff --git a/cmd/release/cmd/generate.go b/cmd/release/cmd/generate.go index 18b646ac..c062dc98 100644 --- a/cmd/release/cmd/generate.go +++ b/cmd/release/cmd/generate.go @@ -201,7 +201,7 @@ func init() { } // rancher generate missing-images-list - rancherGenerateMissingImagesListSubCmd.Flags().IntVarP(&concurrencyLimit, "concurrency-limit", "c", 3, "Concurrency Limit") + rancherGenerateMissingImagesListSubCmd.Flags().IntVarP(&concurrencyLimit, "concurrency-limit", "l", 3, "Concurrency Limit") rancherGenerateMissingImagesListSubCmd.Flags().BoolVarP(&rancherMissingImagesJSONOutput, "json", "j", false, "JSON Output") rancherGenerateMissingImagesListSubCmd.Flags().StringVarP(&imagesListURL, "images-list-url", "i", "", "URL of the artifact containing all images for a given version 'rancher-images.txt' (required)") if err := rancherGenerateMissingImagesListSubCmd.MarkFlagRequired("images-list-url"); err != nil { diff --git a/cmd/release/cmd/root.go b/cmd/release/cmd/root.go index 22febd1c..3d6537b0 100644 --- a/cmd/release/cmd/root.go +++ b/cmd/release/cmd/root.go @@ -10,11 +10,12 @@ import ( ) var ( - debug bool - dryRun bool - rootConfig *config.Config - configFile string - stringConfig string + debug bool + dryRun bool + ignoreValidate bool + rootConfig *config.Config + configFile string + stringConfig string ) // rootCmd represents the base command when called without any subcommands @@ -38,8 +39,9 @@ func SetVersion(version string) { } func init() { - rootCmd.PersistentFlags().BoolVarP(&debug, "debug", "d", false, "Debug") - rootCmd.PersistentFlags().BoolVarP(&dryRun, "dry-run", "r", false, "Drun Run") + rootCmd.PersistentFlags().BoolVarP(&debug, "debug", "D", false, "Debug") + rootCmd.PersistentFlags().BoolVarP(&dryRun, "dry-run", "R", false, "Drun Run") + rootCmd.PersistentFlags().BoolVarP(&ignoreValidate, "ignore-validate", "I", false, "Ignore the validate config step") rootCmd.PersistentFlags().StringVarP(&configFile, "config-file", "c", "$HOME/.ecm-distro-tools/config.json", "Path for the config.json file") rootCmd.PersistentFlags().StringVarP(&stringConfig, "config", "C", "", "JSON config string") } @@ -68,7 +70,9 @@ func initConfig() { rootConfig = conf - if err := rootConfig.Validate(); err != nil { - panic(err) + if !ignoreValidate { + if err := rootConfig.Validate(); err != nil { + panic(err) + } } }