@@ -150,7 +150,7 @@ func NewCreateClusterCommand(cmdFactory cmdutil.Factory, streams genericclioptio
150150}
151151
152152func (options * CreateClusterOptions ) Complete (cmd * cobra.Command , args []string ) error {
153- namespace , err := cmd . Flags ().GetString ( "namespace" )
153+ namespace , _ , err := options . cmdFactory . ToRawKubeConfigLoader ().Namespace ();
154154 if err != nil {
155155 return fmt .Errorf ("failed to get namespace: %w" , err )
156156 }
@@ -241,7 +241,10 @@ func (options *CreateClusterOptions) resolveClusterName() (string, error) {
241241
242242// resolveNamespace resolves the namespace from the CLI flag and the config file
243243func (options * CreateClusterOptions ) resolveNamespace () (string , error ) {
244- namespace := "default"
244+ namespace , _ , err := options .cmdFactory .ToRawKubeConfigLoader ().Namespace ()
245+ if err != nil {
246+ return "" , fmt .Errorf ("failed to get current namespace: %w" , err )
247+ }
245248
246249 if options .rayClusterConfig .Namespace != nil && * options .rayClusterConfig .Namespace != "" && options .namespace != "" && options .namespace != * options .rayClusterConfig .Namespace {
247250 return "" , fmt .Errorf ("the namespace in the config file %q does not match the namespace %q. You must pass --namespace=%s to perform this operation" , * options .rayClusterConfig .Namespace , options .namespace , * options .rayClusterConfig .Namespace )
@@ -268,16 +271,12 @@ func (options *CreateClusterOptions) Run(ctx context.Context, k8sClient client.C
268271 }
269272 options .rayClusterConfig .Name = & name
270273
271- namespace , err := options .resolveNamespace ()
274+ namespace , err := options .resolveNamespace ();
272275 if err != nil {
273276 return err
274277 }
275278 options .rayClusterConfig .Namespace = & namespace
276279 } else {
277- if options .namespace == "" {
278- options .namespace = "default"
279- }
280-
281280 options .rayClusterConfig = & generation.RayClusterConfig {
282281 Namespace : & options .namespace ,
283282 Name : & options .clusterName ,
0 commit comments