@@ -347,17 +347,59 @@ func (cmd *InitCmd) initDevspace(f factory.Factory, configLoader loader.ConfigLo
347347 return errors .Wrap (err , "error parsing images" )
348348 }
349349
350- if len (images ) == 0 {
351- return fmt .Errorf ("no images found for the selected deployments" )
350+ imageManual := "Manually enter the image I want to work on"
351+ imageSkip := "Skip (do not add dev configuration for any images)"
352+ imageAnswer := ""
353+
354+ if len (images ) > 0 {
355+ imageAnswer , err = cmd .log .Question (& survey.QuestionOptions {
356+ Question : "Which image do you want to develop with DevSpace?" ,
357+ DefaultValue : images [0 ],
358+ Options : append (images , []string {imageManual , imageSkip }... ),
359+ })
360+ if err != nil {
361+ return err
362+ }
363+ } else {
364+ imageAnswer , err = cmd .log .Question (& survey.QuestionOptions {
365+ Question : "Couldn’t find any images in your manifests/helm charts. Do you want to skip this step?" ,
366+ Options : []string {imageManual , imageSkip },
367+ })
368+ if err != nil {
369+ return err
370+ }
352371 }
353372
354- image , err = cmd .log .Question (& survey.QuestionOptions {
355- Question : "Which image do you want to develop with DevSpace?" ,
356- DefaultValue : images [0 ],
357- Options : images ,
358- })
359- if err != nil {
360- return err
373+ if imageAnswer == imageSkip {
374+ break
375+ } else if imageAnswer == imageManual {
376+ imageQuestion := "What is the main container image of this project?"
377+
378+ if selectedDeploymentOption == DeployOptionHelm {
379+ imageQuestion = "What is the main container image of this project which is deployed by this Helm chart? (e.g. ecr.io/project/image)"
380+ }
381+
382+ if selectedDeploymentOption == DeployOptionKubectl {
383+ imageQuestion = "What is the main container image of this project which is deployed by these manifests? (e.g. ecr.io/project/image)"
384+ }
385+
386+ if selectedDeploymentOption == DeployOptionKustomize {
387+ imageQuestion = "What is the main container image of this project which is deployed by this Kustomization? (e.g. ecr.io/project/image)"
388+ }
389+
390+ image , err = cmd .log .Question (& survey.QuestionOptions {
391+ Question : imageQuestion ,
392+ ValidationMessage : "Please enter a valid container image from a Kubernetes pod (e.g. myregistry.tld/project/image)" ,
393+ ValidationFunc : func (name string ) error {
394+ _ , _ , err := dockerfile .GetStrippedDockerImageName (strings .ToLower (name ))
395+ return err
396+ },
397+ })
398+ if err != nil {
399+ return err
400+ }
401+ } else {
402+ image = imageAnswer
361403 }
362404 }
363405
@@ -371,27 +413,29 @@ func (cmd *InitCmd) initDevspace(f factory.Factory, configLoader loader.ConfigLo
371413 }
372414 }
373415
374- image = config .Images [imageName ].Image
375-
376416 // Determine app port
377417 portString := ""
378418
379- // Try to get ports from dockerfile
380- ports , err := dockerfile .GetPorts (config .Images [imageName ].Dockerfile )
381- if err == nil {
382- if len (ports ) == 1 {
383- portString = strconv .Itoa (ports [0 ])
384- } else if len (ports ) > 1 {
385- portString , err = cmd .log .Question (& survey.QuestionOptions {
386- Question : "Which port is your application listening on?" ,
387- DefaultValue : strconv .Itoa (ports [0 ]),
388- })
389- if err != nil {
390- return err
391- }
419+ if len (config .Images ) > 0 {
420+ image = config .Images [imageName ].Image
392421
393- if portString == "" {
422+ // Try to get ports from dockerfile
423+ ports , err := dockerfile .GetPorts (config .Images [imageName ].Dockerfile )
424+ if err == nil {
425+ if len (ports ) == 1 {
394426 portString = strconv .Itoa (ports [0 ])
427+ } else if len (ports ) > 1 {
428+ portString , err = cmd .log .Question (& survey.QuestionOptions {
429+ Question : "Which port is your application listening on?" ,
430+ DefaultValue : strconv .Itoa (ports [0 ]),
431+ })
432+ if err != nil {
433+ return err
434+ }
435+
436+ if portString == "" {
437+ portString = strconv .Itoa (ports [0 ])
438+ }
395439 }
396440 }
397441 }
@@ -722,7 +766,7 @@ func (cmd *InitCmd) render(f factory.Factory, config *latest.Config) (string, er
722766 err := loader .Save (renderPath , config )
723767 defer os .Remove (renderPath )
724768 if err != nil {
725- return "" , err
769+ return "" , errors . Wrap ( err , "temp render.yaml" )
726770 }
727771
728772 // Use the render command to render it.
@@ -741,8 +785,7 @@ func (cmd *InitCmd) render(f factory.Factory, config *latest.Config) (string, er
741785 }
742786 err = renderCmd .RunDefault (f )
743787 if err != nil {
744- f .GetLog ().Debugf ("error rendering chart: %v" , err )
745- return "" , nil
788+ return "" , errors .Wrap (err , "devspace render" )
746789 }
747790
748791 return writer .String (), nil
0 commit comments