kontena-cli 0.13.4 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/kontena-cli.gemspec +2 -0
  4. data/lib/kontena/cli/app_command.rb +2 -0
  5. data/lib/kontena/cli/apps/common.rb +80 -74
  6. data/lib/kontena/cli/apps/config_command.rb +29 -0
  7. data/lib/kontena/cli/apps/deploy_command.rb +12 -81
  8. data/lib/kontena/cli/apps/docker_helper.rb +3 -3
  9. data/lib/kontena/cli/apps/init_command.rb +0 -3
  10. data/lib/kontena/cli/apps/list_command.rb +2 -3
  11. data/lib/kontena/cli/apps/logs_command.rb +2 -3
  12. data/lib/kontena/cli/apps/monitor_command.rb +3 -4
  13. data/lib/kontena/cli/apps/remove_command.rb +4 -4
  14. data/lib/kontena/cli/apps/restart_command.rb +2 -3
  15. data/lib/kontena/cli/apps/scale_command.rb +3 -5
  16. data/lib/kontena/cli/apps/service_generator.rb +123 -0
  17. data/lib/kontena/cli/apps/service_generator_v2.rb +26 -0
  18. data/lib/kontena/cli/apps/show_command.rb +1 -2
  19. data/lib/kontena/cli/apps/start_command.rb +2 -3
  20. data/lib/kontena/cli/apps/stop_command.rb +2 -3
  21. data/lib/kontena/cli/apps/yaml/reader.rb +150 -0
  22. data/lib/kontena/cli/apps/yaml/service_extender.rb +60 -0
  23. data/lib/kontena/cli/apps/yaml/validations.rb +79 -0
  24. data/lib/kontena/cli/apps/yaml/validator.rb +55 -0
  25. data/lib/kontena/cli/apps/yaml/validator_v2.rb +74 -0
  26. data/lib/kontena/cli/common.rb +23 -0
  27. data/lib/kontena/cli/etcd/remove_command.rb +2 -0
  28. data/lib/kontena/cli/grids/remove_command.rb +2 -0
  29. data/lib/kontena/cli/grids/users/remove_command.rb +3 -0
  30. data/lib/kontena/cli/master/azure/create_command.rb +0 -2
  31. data/lib/kontena/cli/master/packet/create_command.rb +42 -0
  32. data/lib/kontena/cli/master/packet_command.rb +14 -0
  33. data/lib/kontena/cli/master/upcloud/create_command.rb +39 -0
  34. data/lib/kontena/cli/master/upcloud_command.rb +13 -0
  35. data/lib/kontena/cli/master/users/remove_command.rb +3 -0
  36. data/lib/kontena/cli/master/users/roles/remove_command.rb +2 -0
  37. data/lib/kontena/cli/master_command.rb +4 -0
  38. data/lib/kontena/cli/node_command.rb +4 -0
  39. data/lib/kontena/cli/nodes/azure/create_command.rb +0 -2
  40. data/lib/kontena/cli/nodes/list_command.rb +4 -8
  41. data/lib/kontena/cli/nodes/packet/create_command.rb +35 -0
  42. data/lib/kontena/cli/nodes/packet/restart_command.rb +17 -0
  43. data/lib/kontena/cli/nodes/packet/terminate_command.rb +20 -0
  44. data/lib/kontena/cli/nodes/packet_command.rb +15 -0
  45. data/lib/kontena/cli/nodes/remove_command.rb +2 -0
  46. data/lib/kontena/cli/nodes/show_command.rb +3 -1
  47. data/lib/kontena/cli/nodes/upcloud/create_command.rb +33 -0
  48. data/lib/kontena/cli/nodes/upcloud/restart_command.rb +20 -0
  49. data/lib/kontena/cli/nodes/upcloud/terminate_command.rb +20 -0
  50. data/lib/kontena/cli/nodes/upcloud_command.rb +15 -0
  51. data/lib/kontena/cli/registry/remove_command.rb +3 -0
  52. data/lib/kontena/cli/services/remove_command.rb +2 -0
  53. data/lib/kontena/cli/services/services_helper.rb +1 -0
  54. data/lib/kontena/cli/vault/list_command.rb +2 -0
  55. data/lib/kontena/cli/vault/read_command.rb +2 -0
  56. data/lib/kontena/cli/vault/remove_command.rb +4 -0
  57. data/lib/kontena/cli/vault/update_command.rb +8 -1
  58. data/lib/kontena/cli/vault/write_command.rb +2 -0
  59. data/lib/kontena/cli/vpn/remove_command.rb +3 -0
  60. data/lib/kontena/machine/azure/master_provisioner.rb +2 -2
  61. data/lib/kontena/machine/azure/node_provisioner.rb +7 -4
  62. data/lib/kontena/machine/digital_ocean/node_provisioner.rb +1 -1
  63. data/lib/kontena/machine/packet.rb +17 -0
  64. data/lib/kontena/machine/packet/cloudinit.yml +66 -0
  65. data/lib/kontena/machine/packet/cloudinit_master.yml +118 -0
  66. data/lib/kontena/machine/packet/master_provisioner.rb +93 -0
  67. data/lib/kontena/machine/packet/node_destroyer.rb +42 -0
  68. data/lib/kontena/machine/packet/node_provisioner.rb +77 -0
  69. data/lib/kontena/machine/packet/node_restarter.rb +41 -0
  70. data/lib/kontena/machine/packet/packet_common.rb +89 -0
  71. data/lib/kontena/machine/upcloud.rb +9 -0
  72. data/lib/kontena/machine/upcloud/cloudinit.yml +64 -0
  73. data/lib/kontena/machine/upcloud/cloudinit_master.yml +118 -0
  74. data/lib/kontena/machine/upcloud/master_provisioner.rb +136 -0
  75. data/lib/kontena/machine/upcloud/node_destroyer.rb +82 -0
  76. data/lib/kontena/machine/upcloud/node_provisioner.rb +119 -0
  77. data/lib/kontena/machine/upcloud/node_restarter.rb +47 -0
  78. data/lib/kontena/machine/upcloud/upcloud_common.rb +70 -0
  79. data/lib/kontena/scripts/completer +8 -3
  80. data/spec/fixtures/docker-compose_v2.yml +10 -0
  81. data/spec/fixtures/kontena-invalid.yml +4 -0
  82. data/spec/fixtures/kontena-with-variables.yml +19 -0
  83. data/spec/fixtures/kontena.yml +2 -2
  84. data/spec/fixtures/kontena_v2.yml +35 -0
  85. data/spec/kontena/cli/app/common_spec.rb +39 -101
  86. data/spec/kontena/cli/app/deploy_command_spec.rb +37 -388
  87. data/spec/kontena/cli/app/docker_helper_spec.rb +4 -4
  88. data/spec/kontena/cli/app/service_generator_spec.rb +374 -0
  89. data/spec/kontena/cli/app/service_generator_v2_spec.rb +74 -0
  90. data/spec/kontena/cli/app/yaml/reader_spec.rb +249 -0
  91. data/spec/kontena/cli/app/yaml/service_extender_spec.rb +104 -0
  92. data/spec/kontena/cli/app/yaml/validator_spec.rb +263 -0
  93. data/spec/kontena/cli/app/yaml/validator_v2_spec.rb +309 -0
  94. data/spec/kontena/cli/common_spec.rb +39 -1
  95. data/spec/kontena/cli/master/users/remove_command_spec.rb +9 -0
  96. data/spec/kontena/cli/master/users/roles/remove_command_spec.rb +2 -0
  97. metadata +86 -2
@@ -119,6 +119,7 @@ describe Kontena::Cli::Apps::DeployCommand do
119
119
  end
120
120
 
121
121
  it 'reads given yml file' do
122
+ allow(subject).to receive(:project_name_from_yaml).and_return nil
122
123
  expect(File).to receive(:read).with("#{Dir.getwd}/custom.yml").and_return(kontena_yml)
123
124
  subject.run(["--file", "custom.yml"])
124
125
  end
@@ -133,22 +134,17 @@ describe Kontena::Cli::Apps::DeployCommand do
133
134
  context 'when yml file has multiple env files' do
134
135
  it 'merges environment variables correctly' do
135
136
  allow(subject).to receive(:current_dir).and_return("kontena-test")
136
- allow(YAML).to receive(:load).and_return(services)
137
137
  services['wordpress']['environment'] = ['MYSQL_ADMIN_PASSWORD=password']
138
138
  services['wordpress']['env_file'] = %w(/path/to/env_file .env)
139
+ allow(YAML).to receive(:load).and_return(services)
139
140
 
140
141
  expect(File).to receive(:readlines).with('/path/to/env_file').and_return(env_vars)
141
142
  expect(File).to receive(:readlines).with('.env').and_return(dot_env)
142
143
 
143
144
  data = {
144
- :name =>"kontena-test-wordpress",
145
- :image=>"wordpress:latest",
146
- :env=>["MYSQL_ADMIN_PASSWORD=password", "TEST_ENV_VAR=test", "TEST_ENV_VAR2=test3"],
147
- :container_count=>2,
148
- :stateful=>false,
149
- :strategy=>'ha',
150
- :links=>[{:name=>"kontena-test-mysql", :alias=>"db"}],
151
- :ports=>[{:container_port=>"80", :node_port=>"80", :protocol=>"tcp"}]
145
+ 'name' => 'kontena-test-wordpress',
146
+ 'image' => 'wordpress:latest',
147
+ 'env' => ['MYSQL_ADMIN_PASSWORD=password', 'TEST_ENV_VAR=test', 'TEST_ENV_VAR2=test3'],
152
148
  }
153
149
 
154
150
  expect(subject).to receive(:create_service).with('1234567', '1', hash_including(data))
@@ -159,21 +155,16 @@ describe Kontena::Cli::Apps::DeployCommand do
159
155
  context 'when yml file has one env file' do
160
156
  it 'merges environment variables correctly' do
161
157
  allow(subject).to receive(:current_dir).and_return("kontena-test")
162
- allow(YAML).to receive(:load).and_return(services)
163
158
  services['wordpress']['environment'] = ['MYSQL_ADMIN_PASSWORD=password']
164
159
  services['wordpress']['env_file'] = '/path/to/env_file'
160
+ allow(YAML).to receive(:load).and_return(services)
165
161
 
166
162
  expect(File).to receive(:readlines).with('/path/to/env_file').and_return(env_vars)
167
163
 
168
164
  data = {
169
- :name =>"kontena-test-wordpress",
170
- :image=>"wordpress:latest",
171
- :env=>["MYSQL_ADMIN_PASSWORD=password", "TEST_ENV_VAR=test"],
172
- :container_count=>2,
173
- :stateful=>false,
174
- :strategy=>'ha',
175
- :links=>[{:name=>"kontena-test-mysql", :alias=>"db"}],
176
- :ports=>[{:container_port=>"80", :node_port=>"80", :protocol=>"tcp"}]
165
+ 'name' => 'kontena-test-wordpress',
166
+ 'image' => 'wordpress:latest',
167
+ 'env' => ['MYSQL_ADMIN_PASSWORD=password', 'TEST_ENV_VAR=test']
177
168
  }
178
169
 
179
170
  expect(subject).to receive(:create_service).with('1234567', '1', hash_including(data))
@@ -183,17 +174,21 @@ describe Kontena::Cli::Apps::DeployCommand do
183
174
 
184
175
  it 'merges external links to links' do
185
176
  allow(subject).to receive(:current_dir).and_return("kontena-test")
186
- allow(YAML).to receive(:load).and_return(services)
187
177
  services['wordpress']['external_links'] = ['loadbalancer:loadbalancer']
178
+ allow(YAML).to receive(:load).and_return(services)
188
179
  data = {
189
- :name =>"kontena-test-wordpress",
190
- :image=>"wordpress:latest",
191
- :env=> nil,
192
- :container_count=>2,
193
- :stateful=>false,
194
- :strategy=>'ha',
195
- :links=>[{:name => "kontena-test-mysql", :alias => "db"}, {:name => "loadbalancer", :alias => "loadbalancer"}],
196
- :ports=>[{:container_port => "80", :node_port => "80", :protocol => "tcp"}]
180
+ 'name' => 'kontena-test-wordpress',
181
+ 'image' => 'wordpress:latest',
182
+ 'links' => [
183
+ {
184
+ 'name' => 'kontena-test-mysql',
185
+ 'alias' => 'db'
186
+ },
187
+ {
188
+ 'name' => 'loadbalancer',
189
+ 'alias' => 'loadbalancer'
190
+ }
191
+ ]
197
192
  }
198
193
 
199
194
  expect(subject).to receive(:create_service).with('1234567', '1', hash_including(data))
@@ -203,11 +198,11 @@ describe Kontena::Cli::Apps::DeployCommand do
203
198
  it 'creates mysql service before wordpress' do
204
199
  allow(subject).to receive(:current_dir).and_return("kontena-test")
205
200
  data = {
206
- :name =>"kontena-test-mysql",
207
- :image=>'mysql:5.6',
208
- :env=>["MYSQL_ROOT_PASSWORD=kontena-test_secret"],
209
- :container_count=>nil,
210
- :stateful=>true,
201
+ 'name' => 'kontena-test-mysql',
202
+ 'image' => 'mysql:5.6',
203
+ 'env' => ['MYSQL_ROOT_PASSWORD=kontena-test_secret'],
204
+ 'container_count' => nil,
205
+ 'stateful' => true,
211
206
  }
212
207
  expect(subject).to receive(:create_service).with('1234567', '1', hash_including(data))
213
208
 
@@ -215,17 +210,17 @@ describe Kontena::Cli::Apps::DeployCommand do
215
210
  end
216
211
 
217
212
  it 'creates wordpress service' do
218
- allow(subject).to receive(:current_dir).and_return("kontena-test")
213
+ allow(subject).to receive(:current_dir).and_return('kontena-test')
219
214
 
220
215
  data = {
221
- :name =>"kontena-test-wordpress",
222
- :image=>"wordpress:4.1",
223
- :env=>["WORDPRESS_DB_PASSWORD=kontena-test_secret"],
224
- :container_count=>2,
225
- :stateful=>true,
226
- :strategy=>'ha',
227
- :links=>[{:name=>"kontena-test-mysql", :alias=>"mysql"}],
228
- :ports=>[{:container_port=>"80", :node_port=>"80", :protocol=>"tcp"}]
216
+ 'name' => 'kontena-test-wordpress',
217
+ 'image' => 'wordpress:4.1',
218
+ 'env' => ['WORDPRESS_DB_PASSWORD=kontena-test_secret'],
219
+ 'container_count' => 2,
220
+ 'stateful' => true,
221
+ 'strategy' => 'ha',
222
+ 'links' => [{ 'name' => 'kontena-test-mysql', 'alias' => 'mysql' }],
223
+ 'ports' => [{ 'container_port' => '80', 'node_port' => '80', 'protocol' => 'tcp' }]
229
224
  }
230
225
  expect(subject).to receive(:create_service).with('1234567', '1', hash_including(data))
231
226
 
@@ -233,7 +228,7 @@ describe Kontena::Cli::Apps::DeployCommand do
233
228
  end
234
229
 
235
230
  it 'deploys services' do
236
- allow(subject).to receive(:current_dir).and_return("kontena-test")
231
+ allow(subject).to receive(:current_dir).and_return('kontena-test')
237
232
  expect(subject).to receive(:deploy_service).with('1234567', 'kontena-test-mysql', {})
238
233
  expect(subject).to receive(:deploy_service).with('1234567', 'kontena-test-wordpress', {})
239
234
  subject.run([])
@@ -251,350 +246,4 @@ describe Kontena::Cli::Apps::DeployCommand do
251
246
  end
252
247
  end
253
248
  end
254
-
255
- describe '#parse_data' do
256
-
257
- context 'volumes' do
258
- it 'returns volumes if set' do
259
- data = {
260
- 'image' => 'foo/bar:latest',
261
- 'volumes' => [
262
- 'mongodb-1'
263
- ]
264
- }
265
- result = subject.send(:parse_data, data)
266
- expect(result[:volumes]).to eq(data['volumes'])
267
- end
268
-
269
- it 'returns empty volumes if not set' do
270
- data = {
271
- 'image' => 'foo/bar:latest'
272
- }
273
- result = subject.send(:parse_data, data)
274
- expect(result[:volumes]).to eq([])
275
- end
276
- end
277
-
278
- context 'volumes_from' do
279
- it 'returns volumes_from if set' do
280
- data = {
281
- 'image' => 'foo/bar:latest',
282
- 'volumes_from' => [
283
- 'mongodb-1'
284
- ]
285
- }
286
- result = subject.send(:parse_data, data)
287
- expect(result[:volumes_from]).to eq(data['volumes_from'])
288
- end
289
-
290
- it 'returns empty volumes_from if not set' do
291
- data = {
292
- 'image' => 'foo/bar:latest'
293
- }
294
- result = subject.send(:parse_data, data)
295
- expect(result[:volumes_from]).to eq([])
296
- end
297
- end
298
-
299
- context 'command' do
300
- it 'returns cmd array if set' do
301
- data = {
302
- 'image' => 'foo/bar:latest',
303
- 'command' => 'ls -la'
304
- }
305
- result = subject.send(:parse_data, data)
306
- expect(result[:cmd]).to eq(data['command'].split(' '))
307
- end
308
-
309
- it 'does not return cmd if not set' do
310
- data = {
311
- 'image' => 'foo/bar:latest'
312
- }
313
- result = subject.send(:parse_data, data)
314
- expect(result.has_key?(:cmd)).to be_falsey
315
- end
316
- end
317
-
318
- context 'affinity' do
319
- it 'returns affinity if set' do
320
- data = {
321
- 'image' => 'foo/bar:latest',
322
- 'affinity' => [
323
- 'label==az=b'
324
- ]
325
- }
326
- result = subject.send(:parse_data, data)
327
- expect(result[:affinity]).to eq(data['affinity'])
328
- end
329
-
330
- it 'returns affinity as empty array if not set' do
331
- data = {
332
- 'image' => 'foo/bar:latest'
333
- }
334
- result = subject.send(:parse_data, data)
335
- expect(result.has_key?(:affinity)).to be_truthy
336
- expect(result[:affinity]).to eq([])
337
- end
338
- end
339
-
340
- context 'user' do
341
- it 'returns user if set' do
342
- data = {
343
- 'image' => 'foo/bar:latest',
344
- 'user' => 'user'
345
- }
346
- result = subject.send(:parse_data, data)
347
- expect(result[:user]).to eq('user')
348
- end
349
-
350
- it 'does not return user if not set' do
351
- data = {
352
- 'image' => 'foo/bar:latest'
353
- }
354
- result = subject.send(:parse_data, data)
355
- expect(result.has_key?(:user)).to be_falsey
356
- end
357
- end
358
-
359
- context 'stateful' do
360
- it 'returns stateful if set' do
361
- data = {
362
- 'image' => 'foo/bar:latest',
363
- 'stateful' => true
364
- }
365
- result = subject.send(:parse_data, data)
366
- expect(result[:stateful]).to eq(true)
367
- end
368
-
369
- it 'returns stateful as false if not set' do
370
- data = {
371
- 'image' => 'foo/bar:latest'
372
- }
373
- result = subject.send(:parse_data, data)
374
- expect(result[:stateful]).to eq(false)
375
- end
376
- end
377
-
378
- context 'privileged' do
379
- it 'returns privileged if set' do
380
- data = {
381
- 'image' => 'foo/bar:latest',
382
- 'privileged' => false
383
- }
384
- result = subject.send(:parse_data, data)
385
- expect(result[:privileged]).to eq(false)
386
- end
387
-
388
- it 'does not return privileged if not set' do
389
- data = {
390
- 'image' => 'foo/bar:latest'
391
- }
392
- result = subject.send(:parse_data, data)
393
- expect(result[:privileged]).to be_nil
394
- end
395
- end
396
-
397
- context 'cap_add' do
398
- it 'returns cap_drop if set' do
399
- data = {
400
- 'image' => 'foo/bar:latest',
401
- 'cap_add' => [
402
- 'NET_ADMIN'
403
- ]
404
- }
405
- result = subject.send(:parse_data, data)
406
- expect(result[:cap_add]).to eq(data['cap_add'])
407
- end
408
-
409
- it 'does not return cap_add if not set' do
410
- data = {
411
- 'image' => 'foo/bar:latest'
412
- }
413
- result = subject.send(:parse_data, data)
414
- expect(result[:cap_add]).to be_nil
415
- end
416
- end
417
-
418
- context 'cap_drop' do
419
- it 'returns cap_drop if set' do
420
- data = {
421
- 'image' => 'foo/bar:latest',
422
- 'cap_drop' => [
423
- 'NET_ADMIN'
424
- ]
425
- }
426
- result = subject.send(:parse_data, data)
427
- expect(result[:cap_drop]).to eq(data['cap_drop'])
428
- end
429
-
430
- it 'does not return cap_drop if not set' do
431
- data = {
432
- 'image' => 'foo/bar:latest'
433
- }
434
- result = subject.send(:parse_data, data)
435
- expect(result[:cap_drop]).to be_nil
436
- end
437
- end
438
-
439
- context 'net' do
440
- it 'returns net if set' do
441
- data = {
442
- 'image' => 'foo/bar:latest',
443
- 'net' => 'host'
444
- }
445
- result = subject.send(:parse_data, data)
446
- expect(result[:net]).to eq('host')
447
- end
448
-
449
- it 'does not return pid if not set' do
450
- data = {
451
- 'image' => 'foo/bar:latest'
452
- }
453
- result = subject.send(:parse_data, data)
454
- expect(result[:net]).to be_nil
455
- end
456
- end
457
-
458
- context 'pid' do
459
- it 'returns pid if set' do
460
- data = {
461
- 'image' => 'foo/bar:latest',
462
- 'pid' => 'host'
463
- }
464
- result = subject.send(:parse_data, data)
465
- expect(result[:pid]).to eq('host')
466
- end
467
-
468
- it 'does not return pid if not set' do
469
- data = {
470
- 'image' => 'foo/bar:latest'
471
- }
472
- result = subject.send(:parse_data, data)
473
- expect(result[:pid]).to be_nil
474
- end
475
- end
476
-
477
- context 'log_driver' do
478
- it 'returns log_driver if set' do
479
- data = {
480
- 'image' => 'foo/bar:latest',
481
- 'log_driver' => 'syslog'
482
- }
483
- result = subject.send(:parse_data, data)
484
- expect(result[:log_driver]).to eq('syslog')
485
- end
486
-
487
- it 'does not return log_driver if not set' do
488
- data = {
489
- 'image' => 'foo/bar:latest'
490
- }
491
- result = subject.send(:parse_data, data)
492
- expect(result[:log_driver]).to be_nil
493
- end
494
- end
495
-
496
- context 'log_opt' do
497
- it 'returns log_opts hash if log_opt is set' do
498
- data = {
499
- 'image' => 'foo/bar:latest',
500
- 'log_driver' => 'fluentd',
501
- 'log_opt' => {
502
- 'fluentd-address' => '192.168.99.1:24224',
503
- 'fluentd-tag' => 'docker.{{.Name}}'
504
- }
505
- }
506
- result = subject.send(:parse_data, data)
507
- expect(result[:log_opts]).to eq(data['log_opt'])
508
- end
509
-
510
- it 'does not return log_opts if log_opt is not set' do
511
- data = {
512
- 'image' => 'foo/bar:latest'
513
- }
514
- result = subject.send(:parse_data, data)
515
- expect(result[:log_opts]).to be_nil
516
- end
517
- end
518
-
519
- context 'deploy_opts' do
520
- it 'returns deploy_opts if deploy.wait_for_port is defined' do
521
- data = {
522
- 'image' => 'foo/bar:latest',
523
- 'deploy' => {
524
- 'wait_for_port' => '8080'
525
- }
526
- }
527
- result = subject.send(:parse_data, data)
528
- expect(result[:deploy_opts][:wait_for_port]).to eq('8080')
529
- end
530
-
531
- it 'returns deploy_opts if deploy.min_health is defined' do
532
- data = {
533
- 'image' => 'foo/bar:latest',
534
- 'deploy' => {
535
- 'min_health' => '0.5'
536
- }
537
- }
538
- result = subject.send(:parse_data, data)
539
- expect(result[:deploy_opts][:min_health]).to eq('0.5')
540
- end
541
-
542
- it 'sets strategy if deploy.strategy is defined' do
543
- data = {
544
- 'image' => 'foo/bar:latest',
545
- 'deploy' => {
546
- 'strategy' => 'daemon'
547
- }
548
- }
549
- result = subject.send(:parse_data, data)
550
- expect(result[:strategy]).to eq('daemon')
551
- end
552
-
553
- it 'does not return deploy_opts if no deploy options are defined' do
554
- data = {
555
- 'image' => 'foo/bar:latest'
556
- }
557
- result = subject.send(:parse_data, data)
558
- expect(result[:deploy_opts]).to be_nil
559
- end
560
- end
561
-
562
- context 'hooks' do
563
- it 'returns hooks hash if defined' do
564
- data = {
565
- 'image' => 'foo/bar:latest',
566
- 'hooks' => {
567
- 'post_start' => []
568
- }
569
- }
570
- result = subject.send(:parse_data, data)
571
- expect(result[:hooks]).to eq(data['hooks'])
572
- end
573
-
574
- it 'does returns empty hook hash if not defined' do
575
- data = {'image' => 'foo/bar:latest'}
576
- result = subject.send(:parse_data, data)
577
- expect(result[:hooks]).to eq({})
578
- end
579
- end
580
-
581
- context 'secrets' do
582
- it 'returns secrets array if defined' do
583
- data = {
584
- 'image' => 'foo/bar:latest',
585
- 'secrets' => [
586
- {'secret' => 'MYSQL_ADMIN_PASSWORD', 'name' => 'WORDPRESS_DB_PASSWORD', 'type' => 'env'}
587
- ]
588
- }
589
- result = subject.send(:parse_data, data)
590
- expect(result[:secrets]).to eq(data['secrets'])
591
- end
592
-
593
- it 'does not return secrets if not defined' do
594
- data = {'image' => 'foo/bar:latest'}
595
- result = subject.send(:parse_data, data)
596
- expect(result[:secrets]).to be_nil
597
- end
598
- end
599
- end
600
249
  end