@@ -2,16 +2,15 @@ package kubectl
22
33import (
44 "context"
5+ "fmt"
56 "github.com/loft-sh/devspace/pkg/devspace/config/localcache"
7+ "github.com/loft-sh/devspace/pkg/devspace/kubectl/util"
8+ "github.com/loft-sh/devspace/pkg/devspace/upgrade"
69 "io"
710 "net"
811 "net/url"
912 "os"
1013 "sort"
11- "time"
12-
13- "github.com/loft-sh/devspace/pkg/devspace/kubectl/util"
14- "github.com/loft-sh/devspace/pkg/devspace/upgrade"
1514
1615 "github.com/loft-sh/devspace/pkg/util/kubeconfig"
1716 "github.com/loft-sh/devspace/pkg/util/log"
@@ -176,7 +175,7 @@ func NewClientBySelect(allowPrivate bool, switchContext bool, kubeLoader kubecon
176175 }
177176}
178177
179- // Returns the underlying kube client config
178+ // ClientConfig returns the underlying kube client config
180179func (client * client ) ClientConfig () clientcmd.ClientConfig {
181180 return client .clientConfig
182181}
@@ -273,12 +272,25 @@ func CheckKubeContext(client Client, localCache localcache.Cache, noWarning, aut
273272 }
274273
275274 // Warn if using default namespace unless previous deployment was also to default namespace
276- if log .GetLevel () >= logrus .InfoLevel && currentConfigContext .Namespace == metav1 .NamespaceDefault &&
277- (lastConfigContext == nil ||
278- lastConfigContext .Namespace != metav1 .NamespaceDefault ) {
279- log .Warn ("Deploying into the 'default' namespace is usually not a good idea as this namespace cannot be deleted\n " )
280- log .Info ("Will continue in 5 seconds..." )
281- time .Sleep (5 * time .Second )
275+ if isTerminalIn &&
276+ log .GetLevel () >= logrus .InfoLevel &&
277+ currentConfigContext .Namespace == metav1 .NamespaceDefault &&
278+ (lastConfigContext == nil || lastConfigContext .Namespace != metav1 .NamespaceDefault ) {
279+ log .Warn ("Deploying into the 'default' namespace is usually not a good idea as this namespace cannot be deleted" )
280+ log .Warn ("Please use 'devspace use namespace my-namespace' to select a different one\n " )
281+ useDefault , err := log .Question (& survey.QuestionOptions {
282+ Question : "Are you sure you want to use the 'default' namespace?" ,
283+ DefaultValue : "No" ,
284+ Options : []string {
285+ "No" ,
286+ "Yes" ,
287+ },
288+ })
289+ if err != nil {
290+ return client , err
291+ } else if useDefault == "No" {
292+ return nil , fmt .Errorf ("please run 'devspace use namespace my-namespace' to select a different namespace before rerunning" )
293+ }
282294 }
283295 }
284296
0 commit comments