Skip to content

Commit

Permalink
update config
Browse files Browse the repository at this point in the history
  • Loading branch information
tashima42 committed Aug 6, 2024
1 parent 6d7c11f commit d4de987
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cmd/release/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"fmt"
"log"
"os"
"strings"
Expand Down Expand Up @@ -38,7 +39,7 @@ func SetVersion(version string) {

func init() {
rootCmd.PersistentFlags().BoolVarP(&debug, "debug", "D", false, "Debug")
rootCmd.PersistentFlags().BoolVarP(&dryRun, "dry-run", "R", false, "Dry Run")
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")
Expand All @@ -55,22 +56,25 @@ func initConfig() {
if stringConfig != "" {
conf, err = config.Read(strings.NewReader(stringConfig))
if err != nil {
panic(err)
fmt.Println(err)
os.Exit(1)
}
} else {
configFile = os.ExpandEnv(configFile)
conf, err = config.Load(configFile)
if err != nil {
log.Println("failed to load config, use 'release config gen' to create a new one at: " + configFile)
panic(err)
fmt.Println(err)
os.Exit(1)
}
}

rootConfig = conf

if !ignoreValidate {
if err := rootConfig.Validate(); err != nil {
panic(err)
fmt.Println(err)
os.Exit(1)
}
}
}

0 comments on commit d4de987

Please sign in to comment.