@@ -334,82 +334,99 @@ func (cmd *InitCmd) initDevspace(f factory.Factory, configLoader loader.ConfigLo
334334 break
335335 }
336336
337- image := ""
338- for {
339- if ! mustAddComponentChart {
340- manifests , err := cmd .render (f , config )
341- if err != nil {
342- return errors .Wrap (err , "error rendering deployment" )
343- }
344-
345- images , err := parseImages (manifests )
346- if err != nil {
347- return errors .Wrap (err , "error parsing images" )
348- }
349-
350- imageManual := "Manually enter the image I want to work on"
351- imageSkip := "Skip (do not add dev configuration for any images)"
352- imageAnswer := ""
337+ developProject := "I want to develop this project and my current working dir contains the source code"
338+ deployProject := "I just want to deploy this project"
339+ defaultProjectAction := deployProject
340+ if ! configureManager .IsRemoteDeployment (imageName ) {
341+ defaultProjectAction = developProject
342+ }
343+ developOrDeployProject , err := cmd .log .Question (& survey.QuestionOptions {
344+ Question : "Do you want to develop this project with DevSpace or just deploy it? [Use arrows to move, type to filter]" ,
345+ Options : []string {developProject , deployProject },
346+ DefaultValue : defaultProjectAction ,
347+ })
348+ if err != nil {
349+ return err
350+ }
353351
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- })
352+ image := ""
353+ if developOrDeployProject == developProject {
354+ for {
355+ if ! mustAddComponentChart {
356+ manifests , err := cmd .render (f , config )
360357 if err != nil {
361- return err
358+ return errors . Wrap ( err , "error rendering deployment" )
362359 }
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- })
360+
361+ images , err := parseImages (manifests )
368362 if err != nil {
369- return err
363+ return errors . Wrap ( err , "error parsing images" )
370364 }
371- }
372365
373- if imageAnswer == imageSkip {
374- break
375- } else if imageAnswer == imageManual {
376- imageQuestion := "What is the main container image of this project?"
366+ imageManual := "Manually enter the image I want to work on"
367+ imageSkip := "Skip (do not add dev configuration for any images)"
368+ imageAnswer := ""
377369
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)"
370+ if len (images ) > 0 {
371+ imageAnswer , err = cmd .log .Question (& survey.QuestionOptions {
372+ Question : "Which image do you want to develop with DevSpace?" ,
373+ DefaultValue : images [0 ],
374+ Options : append (images , []string {imageManual , imageSkip }... ),
375+ })
376+ if err != nil {
377+ return err
378+ }
379+ } else {
380+ imageAnswer , err = cmd .log .Question (& survey.QuestionOptions {
381+ Question : "Couldn’t find any images in your manifests/helm charts. Do you want to skip this step?" ,
382+ Options : []string {imageManual , imageSkip },
383+ })
384+ if err != nil {
385+ return err
386+ }
380387 }
381388
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- }
389+ if imageAnswer == imageSkip {
390+ break
391+ } else if imageAnswer == imageManual {
392+ imageQuestion := "What is the main container image of this project?"
385393
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- }
394+ if selectedDeploymentOption == DeployOptionHelm {
395+ imageQuestion = "What is the main container image of this project which is deployed by this Helm chart? (e.g. ecr.io/project/image)"
396+ }
397+
398+ if selectedDeploymentOption == DeployOptionKubectl {
399+ imageQuestion = "What is the main container image of this project which is deployed by these manifests? (e.g. ecr.io/project/image)"
400+ }
389401
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 ))
402+ if selectedDeploymentOption == DeployOptionKustomize {
403+ imageQuestion = "What is the main container image of this project which is deployed by this Kustomization? (e.g. ecr.io/project/image)"
404+ }
405+
406+ image , err = cmd .log .Question (& survey.QuestionOptions {
407+ Question : imageQuestion ,
408+ ValidationMessage : "Please enter a valid container image from a Kubernetes pod (e.g. myregistry.tld/project/image)" ,
409+ ValidationFunc : func (name string ) error {
410+ _ , _ , err := dockerfile .GetStrippedDockerImageName (strings .ToLower (name ))
411+ return err
412+ },
413+ })
414+ if err != nil {
395415 return err
396- },
397- })
398- if err != nil {
399- return err
416+ }
417+ } else {
418+ image = imageAnswer
400419 }
401- } else {
402- image = imageAnswer
403420 }
404- }
405421
406- err = configureManager .AddImage (imageName , image , projectNamespace + "/" + projectName , cmd .Dockerfile )
407- if err != nil {
408- if err .Error () != "" {
409- cmd .log .Errorf ("Error: %s" , err .Error ())
422+ err = configureManager .AddImage (imageName , image , projectNamespace + "/" + projectName , cmd .Dockerfile )
423+ if err != nil {
424+ if err .Error () != "" {
425+ cmd .log .Errorf ("Error: %s" , err .Error ())
426+ }
427+ } else {
428+ break
410429 }
411- } else {
412- break
413430 }
414431 }
415432
0 commit comments