Skip to content
Snippets Groups Projects
Unverified Commit f2de7e04 authored by Stefan Prodan's avatar Stefan Prodan
Browse files

Set default ns with FLUX_SYSTEM_NAMESPACE env var

parent 8b3e3b1d
No related branches found
No related tags found
No related merge requests found
......@@ -107,7 +107,8 @@ type rootFlags struct {
var rootArgs = NewRootFlags()
func init() {
rootCmd.PersistentFlags().StringVarP(&rootArgs.namespace, "namespace", "n", rootArgs.defaults.Namespace, "the namespace scope for this operation")
rootCmd.PersistentFlags().StringVarP(&rootArgs.namespace, "namespace", "n", rootArgs.defaults.Namespace,
"the namespace scope for this operation, can be set with FLUX_SYSTEM_NAMESPACE env var")
rootCmd.RegisterFlagCompletionFunc("namespace", resourceNamesCompletionFunc(corev1.SchemeGroupVersion.WithKind("Namespace")))
rootCmd.PersistentFlags().DurationVar(&rootArgs.timeout, "timeout", 5*time.Minute, "timeout for this operation")
......@@ -134,6 +135,7 @@ func NewRootFlags() rootFlags {
func main() {
log.SetFlags(0)
configureKubeconfig()
configureDefaultNamespace()
if err := rootCmd.Execute(); err != nil {
logger.Failuref("%v", err)
os.Exit(1)
......@@ -152,6 +154,13 @@ func configureKubeconfig() {
}
}
func configureDefaultNamespace() {
fromEnv := os.Getenv("FLUX_SYSTEM_NAMESPACE")
if fromEnv != "" && rootArgs.namespace == rootArgs.defaults.Namespace {
rootArgs.namespace = fromEnv
}
}
func homeDir() string {
if h := os.Getenv("HOME"); h != "" {
return h
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment