|
6 | 6 | "path/filepath" |
7 | 7 | "strings" |
8 | 8 |
|
| 9 | + "github.com/covexo/devspace/pkg/devspace/config/generated" |
| 10 | + "github.com/covexo/devspace/pkg/devspace/kubectl" |
| 11 | + |
9 | 12 | "github.com/covexo/devspace/pkg/util/kubeconfig" |
10 | 13 |
|
11 | 14 | "github.com/covexo/devspace/pkg/devspace/cloud" |
@@ -116,24 +119,21 @@ func (cmd *InitCmd) Run(cobraCmd *cobra.Command, args []string) { |
116 | 119 | // Delete config & overwrite config |
117 | 120 | os.Remove(filepath.Join(workdir, configutil.ConfigPath)) |
118 | 121 | os.Remove(filepath.Join(workdir, configutil.OverwriteConfigPath)) |
| 122 | + os.Remove(filepath.Join(workdir, generated.ConfigPath)) |
119 | 123 |
|
| 124 | + // Create config |
120 | 125 | config = configutil.InitConfig() |
121 | 126 |
|
122 | 127 | // Set intial deployments |
123 | 128 | config.DevSpace.Deployments = &[]*v1.DeploymentConfig{ |
124 | 129 | { |
125 | 130 | Name: configutil.String(DefaultDevspaceDeploymentName), |
126 | | - Namespace: configutil.String("default"), |
| 131 | + Namespace: configutil.String(""), |
127 | 132 | Helm: &v1.HelmConfig{ |
128 | 133 | ChartPath: configutil.String("./chart"), |
129 | 134 | }, |
130 | 135 | }, |
131 | 136 | } |
132 | | - |
133 | | - // Set initial tiller namespace |
134 | | - config.Tiller = &v1.TillerConfig{ |
135 | | - Namespace: configutil.String("default"), |
136 | | - } |
137 | 137 | } |
138 | 138 |
|
139 | 139 | configutil.Merge(config, &v1.Config{ |
@@ -218,13 +218,6 @@ func (cmd *InitCmd) configureKubernetes() { |
218 | 218 |
|
219 | 219 | // Check if devspace cloud should be used |
220 | 220 | if cmd.useCloudProvider() == false { |
221 | | - currentContext, err := kubeconfig.GetCurrentContext() |
222 | | - if err != nil { |
223 | | - log.Fatalf("Couldn't determine current kubernetes context: %v", err) |
224 | | - } |
225 | | - |
226 | | - clusterConfig.KubeContext = ¤tContext |
227 | | - |
228 | 221 | cmd.configureDevSpace() |
229 | 222 | } |
230 | 223 |
|
@@ -310,16 +303,20 @@ func (cmd *InitCmd) useCloudProvider() bool { |
310 | 303 | } |
311 | 304 |
|
312 | 305 | func (cmd *InitCmd) configureDevSpace() { |
313 | | - config := configutil.GetConfig() |
| 306 | + currentContext, err := kubeconfig.GetCurrentContext() |
| 307 | + if err != nil { |
| 308 | + log.Fatalf("Couldn't determine current kubernetes context: %v", err) |
| 309 | + } |
| 310 | + |
314 | 311 | namespace := stdinutil.GetFromStdin(&stdinutil.GetFromStdinParams{ |
315 | 312 | Question: "Which Kubernetes namespace should your application run in?", |
316 | 313 | DefaultValue: "default", |
317 | 314 | ValidationRegexPattern: v1.Kubernetes.RegexPatterns.Name, |
318 | 315 | }) |
319 | 316 |
|
320 | | - deployments := *config.DevSpace.Deployments |
321 | | - deployments[0].Namespace = namespace |
322 | | - config.Tiller.Namespace = namespace |
| 317 | + config := configutil.GetConfig() |
| 318 | + config.Cluster.KubeContext = ¤tContext |
| 319 | + config.Cluster.Namespace = namespace |
323 | 320 | } |
324 | 321 |
|
325 | 322 | func (cmd *InitCmd) addDefaultSyncConfig() { |
@@ -347,7 +344,6 @@ func (cmd *InitCmd) addDefaultSyncConfig() { |
347 | 344 | syncConfig := append(*config.DevSpace.Sync, &v1.SyncConfig{ |
348 | 345 | ContainerPath: configutil.String("/app"), |
349 | 346 | LocalSubPath: configutil.String("./"), |
350 | | - ResourceType: nil, |
351 | 347 | LabelSelector: &map[string]*string{ |
352 | 348 | "release": configutil.String(DefaultDevspaceDeploymentName), |
353 | 349 | }, |
@@ -375,34 +371,37 @@ func (cmd *InitCmd) configureRegistry() { |
375 | 371 | } |
376 | 372 | } |
377 | 373 | } else { |
378 | | - deployments := *config.DevSpace.Deployments |
379 | | - |
380 | 374 | // Set default build engine to kaniko, if no docker is installed |
381 | 375 | cmd.defaultImage.Build = &v1.BuildConfig{ |
382 | 376 | Kaniko: &v1.KanikoConfig{ |
383 | | - Namespace: deployments[0].Namespace, |
384 | 377 | Cache: configutil.Bool(true), |
| 378 | + Namespace: configutil.String(""), |
385 | 379 | }, |
386 | 380 | } |
387 | 381 | } |
388 | 382 |
|
389 | | - createInternalRegistry := stdinutil.GetFromStdin(&stdinutil.GetFromStdinParams{ |
390 | | - Question: "Should we create a private registry within your Kubernetes cluster for you? (yes | no)", |
391 | | - DefaultValue: createInternalRegistryDefaultAnswer, |
392 | | - ValidationRegexPattern: "^(yes)|(no)$", |
393 | | - }) |
| 383 | + // Only deploy registry in minikube |
| 384 | + if kubectl.IsMinikube() { |
| 385 | + createInternalRegistry := stdinutil.GetFromStdin(&stdinutil.GetFromStdinParams{ |
| 386 | + Question: "Should we create a private registry within your Kubernetes cluster for you? (yes | no)", |
| 387 | + DefaultValue: createInternalRegistryDefaultAnswer, |
| 388 | + ValidationRegexPattern: "^(yes)|(no)$", |
| 389 | + }) |
394 | 390 |
|
395 | | - if *createInternalRegistry == "no" { |
396 | | - err := configure.ImageName(dockerUsername) |
397 | | - if err != nil { |
398 | | - log.Fatal(err) |
399 | | - } |
400 | | - } else { |
401 | | - err := configure.InternalRegistry() |
402 | | - if err != nil { |
403 | | - log.Fatal(err) |
| 391 | + if *createInternalRegistry == "yes" { |
| 392 | + err := configure.InternalRegistry() |
| 393 | + if err != nil { |
| 394 | + log.Fatal(err) |
| 395 | + } |
| 396 | + |
| 397 | + return |
404 | 398 | } |
405 | 399 | } |
| 400 | + |
| 401 | + err = configure.ImageName(dockerUsername) |
| 402 | + if err != nil { |
| 403 | + log.Fatal(err) |
| 404 | + } |
406 | 405 | } |
407 | 406 |
|
408 | 407 | func (cmd *InitCmd) determineLanguage() { |
|
0 commit comments