@@ -10,7 +10,6 @@ import (
1010 "github.com/covexo/devspace/pkg/devspace/generator"
1111 "github.com/covexo/devspace/pkg/util/log"
1212 "github.com/covexo/devspace/pkg/util/randutil"
13- "github.com/covexo/devspace/pkg/util/yamlutil"
1413 "github.com/imdario/mergo"
1514 homedir "github.com/mitchellh/go-homedir"
1615
@@ -124,7 +123,6 @@ func (cmd *InitCmd) Run(cobraCmd *cobra.Command, args []string) {
124123 User : & v1.User {},
125124 },
126125 })
127- cmd .initChartGenerator ()
128126
129127 createChart := cmd .flags .overwrite
130128
@@ -145,18 +143,25 @@ func (cmd *InitCmd) Run(cobraCmd *cobra.Command, args []string) {
145143 }
146144
147145 if createChart {
148- cmd .determineAppConfig ()
146+ cmd .initChartGenerator ()
147+ cmd .determineLanguage ()
148+ cmd .createChart ()
149+ cmd .configureDevSpace ()
149150
150151 cmd .config .Image .Name = cmd .config .DevSpace .Release .Name
151152 }
152153
153154 if cmd .flags .reconfigure || ! configExists {
154- cmd .reconfigure ()
155- }
155+ cmd .configureKubernetes ()
156+ cmd .configureDevSpaceRelease ()
157+ cmd .configureTiller ()
158+ cmd .configureRegistry ()
156159
157- if createChart {
158- cmd .determineLanguage ()
159- cmd .createChart ()
160+ err := configutil .SaveConfig ()
161+
162+ if err != nil {
163+ log .With (err ).Fatalf ("Config error: %s" , err .Error ())
164+ }
160165 }
161166}
162167
@@ -177,7 +182,7 @@ func (cmd *InitCmd) initChartGenerator() {
177182 }
178183}
179184
180- func (cmd * InitCmd ) determineAppConfig () {
185+ func (cmd * InitCmd ) configureDevSpace () {
181186 _ , chartDirNotFound := os .Stat (cmd .chartGenerator .Path + "/chart" )
182187
183188 if chartDirNotFound == nil {
@@ -278,16 +283,17 @@ func (cmd *InitCmd) addDefaultSyncConfig() {
278283 cmd .config .DevSpace .Sync = & syncConfig
279284}
280285
281- func (cmd * InitCmd ) reconfigure () {
282- clusterConfig := cmd .config .Cluster
283- tillerConfig := cmd .config .Services .Tiller
284- tillerRelease := tillerConfig .Release
285-
286+ func (cmd * InitCmd ) configureDevSpaceRelease () {
286287 cmd .config .DevSpace .Release .Namespace = stdinutil .GetFromStdin (& stdinutil.GetFromStdinParams {
287288 Question : "Which Kubernetes namespace should your application run in?" ,
288289 DefaultValue : * cmd .config .DevSpace .Release .Namespace ,
289290 ValidationRegexPattern : v1 .Kubernetes .RegexPatterns .Name ,
290291 })
292+ }
293+
294+ func (cmd * InitCmd ) configureTiller () {
295+ tillerConfig := cmd .config .Services .Tiller
296+ tillerRelease := tillerConfig .Release
291297
292298 if tillerRelease .Namespace == nil {
293299 tillerRelease .Namespace = cmd .config .DevSpace .Release .Namespace
@@ -297,6 +303,10 @@ func (cmd *InitCmd) reconfigure() {
297303 DefaultValue : * tillerRelease .Namespace ,
298304 ValidationRegexPattern : v1 .Kubernetes .RegexPatterns .Name ,
299305 })
306+ }
307+
308+ func (cmd * InitCmd ) configureKubernetes () {
309+ clusterConfig := cmd .config .Cluster
300310 useKubeConfig := false
301311 homeDir , homeErr := homedir .Dir ()
302312
@@ -344,16 +354,9 @@ func (cmd *InitCmd) reconfigure() {
344354 InputTerminationString : "-----END RSA PRIVATE KEY-----" ,
345355 })
346356 }
347- cmd .reconfigureRegistry ()
348-
349- err := configutil .SaveConfig ()
350-
351- if err != nil {
352- log .With (err ).Fatalf ("Config error: %s" , err .Error ())
353- }
354357}
355358
356- func (cmd * InitCmd ) reconfigureRegistry () {
359+ func (cmd * InitCmd ) configureRegistry () {
357360 overwriteConfig := configutil .GetOverwriteConfig ()
358361 registryConfig := cmd .config .Services .Registry
359362
@@ -501,14 +504,13 @@ func (cmd *InitCmd) createChart() {
501504 log .Fatalf ("Error while creating Helm chart and Dockerfile: %s" , err .Error ())
502505 }
503506
507+ /*TODO
504508 createdChartYaml := map[interface{}]interface{}{}
505509 createdChartValuesYaml := map[interface{}]interface{}{}
506510
507511 yamlutil.ReadYamlFromFile(cmd.chartGenerator.Path+"/chart/Chart.yaml", &createdChartYaml)
508512 yamlutil.ReadYamlFromFile(cmd.chartGenerator.Path+"/chart/values.yaml", &createdChartValuesYaml)
509513
510- createdChartYaml ["name" ] = cmd .config .DevSpace .Release .Name
511- /*TODO
512514 containerValues, chartHasContainerValues := createdChartValuesYaml["container"].(map[interface{}]interface{})
513515
514516 if !chartHasContainerValues && containerValues != nil {
@@ -523,7 +525,7 @@ func (cmd *InitCmd) createChart() {
523525 externalValues["domain"] = cmd.appConfig.External.Domain
524526 createdChartValuesYaml["external"] = externalValues
525527 }
526- */
527528 yamlutil.WriteYamlToFile(createdChartYaml, cmd.chartGenerator.Path+"/chart/Chart.yaml")
528529 yamlutil.WriteYamlToFile(createdChartValuesYaml, cmd.chartGenerator.Path+"/chart/values.yaml")
530+ */
529531}
0 commit comments