88 "os"
99 "path/filepath"
1010 "strings"
11-
11+
1212 "github.com/loft-sh/devspace/pkg/devspace/config/loader/variable"
13-
13+
1414 "github.com/loft-sh/devspace/cmd"
1515 "github.com/loft-sh/devspace/cmd/flags"
1616 "github.com/loft-sh/devspace/e2e/framework"
@@ -25,55 +25,55 @@ var _ = DevSpaceDescribe("init", func() {
2525 if err != nil {
2626 panic (err )
2727 }
28-
28+
2929 // create a new factory
3030 var (
3131 f * framework.DefaultFactory
3232 kubeClient * kube.KubeHelper
3333 )
34-
34+
3535 ginkgo .BeforeEach (func () {
3636 f = framework .NewDefaultFactory ()
37-
37+
3838 kubeClient , err = kube .NewKubeHelper ()
3939 framework .ExpectNoError (err )
4040 })
41-
41+
4242 ginkgo .It ("should create devspace.yml without registry details" , func () {
4343 tempDir , err := framework .CopyToTempDir ("tests/init/testdata/new" )
4444 framework .ExpectNoError (err )
4545 defer framework .CleanupTempDir (initialDir , tempDir )
46-
46+
4747 // set the question answer func here
4848 f .SetAnswerFunc (func (params * survey.QuestionOptions ) (string , error ) {
4949 if strings .Contains (params .Question , "How do you want to deploy this project?" ) {
5050 return cmd .DeployOptionHelm , nil
5151 }
52-
52+
5353 if strings .Contains (params .Question , "If you were to push any images, which container registry would you want to push to?" ) {
5454 return "Skip Registry" , nil
5555 }
56-
56+
5757 if strings .Contains (params .Question , "How should DevSpace build the container image for this project?" ) {
5858 return "Skip / I don't know" , nil
5959 }
60-
60+
6161 return params .DefaultValue , nil
6262 })
63-
63+
6464 initCmd := & cmd.InitCmd {GlobalFlags : & flags.GlobalFlags {}}
6565 err = initCmd .Run (f )
6666 framework .ExpectNoError (err )
67-
67+
6868 config , _ , err := framework .LoadConfig (f , kubeClient .Client (), filepath .Join (tempDir , "devspace.yaml" ))
6969 framework .ExpectNoError (err )
70-
70+
7171 framework .ExpectEqual (len (config .Variables ()), len (variable .AlwaysResolvePredefinedVars ))
72-
72+
7373 ns , err := kubeClient .CreateNamespace ("init" )
7474 framework .ExpectNoError (err )
7575 defer framework .ExpectDeleteNamespace (kubeClient , ns )
76-
76+
7777 done := make (chan error )
7878 go func () {
7979 devCmd := & cmd.RunPipelineCmd {
@@ -85,46 +85,46 @@ var _ = DevSpaceDescribe("init", func() {
8585 }
8686 done <- devCmd .RunDefault (f )
8787 }()
88-
88+
8989 err = <- done
9090 framework .ExpectNoError (err )
9191 })
92-
92+
9393 ginkgo .It ("should create devspace.yml without registry details and manifests deploy" , func () {
9494 tempDir , err := framework .CopyToTempDir ("tests/init/testdata/new" )
9595 framework .ExpectNoError (err )
9696 defer framework .CleanupTempDir (initialDir , tempDir )
97-
97+
9898 // set the question answer func here
9999 f .SetAnswerFunc (func (params * survey.QuestionOptions ) (string , error ) {
100100 if strings .Contains (params .Question , "Which registry would you want to use to push images to?" ) {
101101 return "Skip Registry" , nil
102102 }
103-
103+
104104 if strings .Contains (params .Question , "How do you want to deploy this project?" ) {
105105 return cmd .DeployOptionKubectl , nil
106106 }
107-
107+
108108 if strings .Contains (params .Question , "Please enter the paths to your Kubernetes manifests" ) {
109109 return "manifests/**" , nil
110110 }
111-
111+
112112 return params .DefaultValue , nil
113113 })
114-
114+
115115 initCmd := & cmd.InitCmd {GlobalFlags : & flags.GlobalFlags {}}
116116 err = initCmd .Run (f )
117117 framework .ExpectNoError (err )
118-
118+
119119 config , _ , err := framework .LoadConfig (f , kubeClient .Client (), filepath .Join (tempDir , "devspace.yaml" ))
120120 framework .ExpectNoError (err )
121-
121+
122122 framework .ExpectEqual (len (config .Variables ()), len (variable .AlwaysResolvePredefinedVars ))
123-
123+
124124 ns , err := kubeClient .CreateNamespace ("init" )
125125 framework .ExpectNoError (err )
126126 defer framework .ExpectDeleteNamespace (kubeClient , ns )
127-
127+
128128 devCmd := & cmd.RunPipelineCmd {
129129 GlobalFlags : & flags.GlobalFlags {
130130 NoWarn : true ,
@@ -136,42 +136,42 @@ var _ = DevSpaceDescribe("init", func() {
136136 err = devCmd .RunDefault (f )
137137 framework .ExpectNoError (err )
138138 })
139-
139+
140140 ginkgo .It ("should create devspace.yml without registry details and kustomize deploy" , func () {
141141 tempDir , err := framework .CopyToTempDir ("tests/init/testdata/new" )
142142 framework .ExpectNoError (err )
143143 defer framework .CleanupTempDir (initialDir , tempDir )
144-
144+
145145 // set the question answer func here
146146 f .SetAnswerFunc (func (params * survey.QuestionOptions ) (string , error ) {
147147 if strings .Contains (params .Question , "Which registry would you want to use to push images to?" ) {
148148 return "Skip Registry" , nil
149149 }
150-
150+
151151 if strings .Contains (params .Question , "How do you want to deploy this project?" ) {
152152 return cmd .DeployOptionKustomize , nil
153153 }
154-
154+
155155 if strings .Contains (params .Question , "Please enter path to your Kustomization folder" ) {
156156 return "./kustomization" , nil
157157 }
158-
158+
159159 return params .DefaultValue , nil
160160 })
161-
161+
162162 initCmd := & cmd.InitCmd {GlobalFlags : & flags.GlobalFlags {}}
163163 err = initCmd .Run (f )
164164 framework .ExpectNoError (err )
165-
165+
166166 config , _ , err := framework .LoadConfig (f , kubeClient .Client (), filepath .Join (tempDir , "devspace.yaml" ))
167167 framework .ExpectNoError (err )
168-
168+
169169 framework .ExpectEqual (len (config .Variables ()), len (variable .AlwaysResolvePredefinedVars ))
170-
170+
171171 ns , err := kubeClient .CreateNamespace ("init" )
172172 framework .ExpectNoError (err )
173173 defer framework .ExpectDeleteNamespace (kubeClient , ns )
174-
174+
175175 done := make (chan error )
176176 go func () {
177177 devCmd := & cmd.RunPipelineCmd {
@@ -183,50 +183,50 @@ var _ = DevSpaceDescribe("init", func() {
183183 }
184184 done <- devCmd .RunDefault (f )
185185 }()
186-
186+
187187 err = <- done
188188 framework .ExpectNoError (err )
189189 })
190-
190+
191191 ginkgo .It ("should create devspace.yml without registry details and local helm chart deploy" , func () {
192192 tempDir , err := framework .CopyToTempDir ("tests/init/testdata/new" )
193193 framework .ExpectNoError (err )
194194 defer framework .CleanupTempDir (initialDir , tempDir )
195-
195+
196196 // set the question answer func here
197197 f .SetAnswerFunc (func (params * survey.QuestionOptions ) (string , error ) {
198198 if strings .Contains (params .Question , "Which registry would you want to use to push images to?" ) {
199199 return "Skip Registry" , nil
200200 }
201-
201+
202202 if strings .Contains (params .Question , "How do you want to deploy this project?" ) {
203203 return cmd .DeployOptionHelm , nil
204204 }
205-
205+
206206 if strings .Contains (params .Question , "Which Helm chart do you want to use?" ) {
207207 return `Use a local Helm chart (e.g. ./helm/chart/)` , nil
208208 }
209-
209+
210210 if strings .Contains (params .Question , "Please enter the relative path to your local Helm chart" ) {
211211 return "./chart" , nil
212212 }
213-
213+
214214 return params .DefaultValue , nil
215215 })
216-
216+
217217 initCmd := & cmd.InitCmd {GlobalFlags : & flags.GlobalFlags {}}
218218 err = initCmd .Run (f )
219219 framework .ExpectNoError (err )
220-
220+
221221 config , _ , err := framework .LoadConfig (f , kubeClient .Client (), filepath .Join (tempDir , "devspace.yaml" ))
222222 framework .ExpectNoError (err )
223-
223+
224224 framework .ExpectEqual (len (config .Variables ()), len (variable .AlwaysResolvePredefinedVars ))
225-
225+
226226 ns , err := kubeClient .CreateNamespace ("init" )
227227 framework .ExpectNoError (err )
228228 defer framework .ExpectDeleteNamespace (kubeClient , ns )
229-
229+
230230 done := make (chan error )
231231 go func () {
232232 devCmd := & cmd.RunPipelineCmd {
@@ -238,42 +238,42 @@ var _ = DevSpaceDescribe("init", func() {
238238 }
239239 done <- devCmd .RunDefault (f )
240240 }()
241-
241+
242242 err = <- done
243243 framework .ExpectNoError (err )
244244 })
245-
245+
246246 ginkgo .It ("should create devspace.yml from docker-compose.yaml" , func () {
247247 tempDir , err := framework .CopyToTempDir ("tests/init/testdata/docker-compose" )
248248 framework .ExpectNoError (err )
249249 defer framework .CleanupTempDir (initialDir , tempDir )
250-
250+
251251 ns , err := kubeClient .CreateNamespace ("init" )
252252 framework .ExpectNoError (err )
253253 defer func () {
254254 err := kubeClient .DeleteNamespace (ns )
255255 framework .ExpectNoError (err )
256256 }()
257-
257+
258258 // Answer all questions with the default
259259 f .SetAnswerFunc (func (params * survey.QuestionOptions ) (string , error ) {
260260 return params .DefaultValue , nil
261261 })
262-
262+
263263 initCmd := & cmd.InitCmd {
264264 Reconfigure : true ,
265265 }
266266 err = initCmd .Run (f )
267267 framework .ExpectNoError (err )
268-
268+
269269 // Created a devspace.yaml
270270 _ , _ , err = framework .LoadConfig (f , kubeClient .Client (), filepath .Join (tempDir , "devspace.yaml" ))
271271 framework .ExpectNoError (err )
272-
272+
273273 // Created a .gitignore
274274 _ , err = os .Stat (filepath .Join (tempDir , ".gitignore" ))
275275 framework .ExpectNoError (err )
276-
276+
277277 // Print the config to verify the expected deployment
278278 var configBuffer bytes.Buffer
279279 printCmd := & cmd.PrintCmd {
@@ -283,18 +283,18 @@ var _ = DevSpaceDescribe("init", func() {
283283 },
284284 Out : & configBuffer ,
285285 }
286-
286+
287287 err = printCmd .Run (f )
288288 framework .ExpectNoError (err )
289-
289+
290290 generatedConfig := & latest.Config {}
291291 err = yaml .Unmarshal (configBuffer .Bytes (), generatedConfig )
292292 framework .ExpectNoError (err )
293-
293+
294294 // validate config
295295 framework .ExpectEqual (len (generatedConfig .Deployments ), 1 )
296296 framework .ExpectHaveKey (generatedConfig .Deployments , "db" )
297-
297+
298298 // ensure valid configuration by deploying the application
299299 deployCmd := & cmd.RunPipelineCmd {
300300 GlobalFlags : & flags.GlobalFlags {
@@ -306,7 +306,7 @@ var _ = DevSpaceDescribe("init", func() {
306306 SkipPush : true ,
307307 }
308308 err = deployCmd .RunDefault (f )
309-
309+
310310 framework .ExpectNoError (err )
311311 })
312312})
0 commit comments