中的一些定义sig.k8s.io/controller-runtime/pkg/client/config/config.go
:
var (
kubeconfig, apiServerURL string
)
func init() {
flag.StringVar(&kubeconfig, "kubeconfig", "",
"Paths to a kubeconfig. Only required if out-of-cluster.")
}
我的项目,mybinary,与 cobra
var rootCmd = &cobra.Command{
Use: "mybinary",
Run: func(cmd *cobra.Command, args []string) {
somefunc()
}
}
func init() {
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file")
rootCmd.InitDefaultHelpFlag()
}
如果我想使用mybinary --kubeconfig somevalue
来设置参数kubeconfig
定义,我需要做什么config.go
?