From 31140d97e4c85c94c46bab054a871030a6a314c8 Mon Sep 17 00:00:00 2001 From: iwilltry42 Date: Mon, 15 Jul 2024 16:42:40 +0200 Subject: [PATCH] fix: config --- cmd/cluster/clusterCreate.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/cluster/clusterCreate.go b/cmd/cluster/clusterCreate.go index 8fbd28fa..67fa1a6f 100644 --- a/cmd/cluster/clusterCreate.go +++ b/cmd/cluster/clusterCreate.go @@ -69,10 +69,12 @@ var ( ppViper = viper.New() ) -func initConfig() error { +func initConfig(cmd *cobra.Command) error { // Viper for pre-processed config options ppViper.SetEnvPrefix("K3D") + _ = ppViper.BindPFlag("config", cmd.Flags().Lookup("config")) + if l.Log().GetLevel() >= logrus.DebugLevel { c, _ := yaml.Marshal(ppViper.AllSettings()) l.Log().Debugf("Additional CLI Configuration:\n%s", c) @@ -89,9 +91,7 @@ func NewCmdClusterCreate() *cobra.Command { Short: "Create a new cluster", Long: clusterCreateDescription, Args: cobra.RangeArgs(0, 1), // exactly one cluster name can be set (default: k3d.DefaultClusterName) - PreRunE: func(cmd *cobra.Command, args []string) error { - return initConfig() - }, + Run: func(cmd *cobra.Command, args []string) { /************************* * Compute Configuration * @@ -204,6 +204,9 @@ func NewCmdClusterCreate() *cobra.Command { }, } + cmd.PreRunE = func(cmd *cobra.Command, args []string) error { + return initConfig(cmd) + } /*************** * Config File * ***************/ -- 2.34.1