File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -205,6 +205,20 @@ func main() {
205205
206206func configureDefaultNamespace () {
207207 * kubeconfigArgs .Namespace = rootArgs .defaults .Namespace
208+
209+ // First check if we should use the namespace from the current context
210+ if os .Getenv ("FLUX_SYSTEM_NAMESPACE_FROM_CONTEXT" ) == "true" {
211+ // Get the current context's namespace from kubeconfig
212+ config , err := kubeconfigArgs .ToRawKubeConfigLoader ().RawConfig ()
213+ if err == nil {
214+ if ctx , exists := config .Contexts [config .CurrentContext ]; exists && ctx .Namespace != "" {
215+ kubeconfigArgs .Namespace = & ctx .Namespace
216+ return
217+ }
218+ }
219+ }
220+
221+ // Fall back to environment variable if set
208222 fromEnv := os .Getenv ("FLUX_SYSTEM_NAMESPACE" )
209223 if fromEnv != "" {
210224 // namespace must be a valid DNS label. Assess against validation
You can’t perform that action at this time.
0 commit comments