onceover 3.2.8 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +2 -2
  3. data/.rubocop.yml +73 -59
  4. data/Rakefile +3 -7
  5. data/features/init.feature +4 -5
  6. data/features/run.feature +13 -4
  7. data/features/show.feature +28 -0
  8. data/features/step_definitions/common.rb +7 -4
  9. data/features/step_definitions/init.rb +4 -0
  10. data/features/step_definitions/run.rb +9 -0
  11. data/features/support/command_helper.rb +1 -1
  12. data/features/support/controlrepo_helper.rb +17 -3
  13. data/lib/onceover/controlrepo.rb +8 -4
  14. data/lib/onceover/logger.rb +1 -1
  15. data/lib/onceover/testconfig.rb +18 -2
  16. data/onceover.gemspec +2 -1
  17. data/spec/fixtures/{controlrepo_basic → controlrepos/basic}/Puppetfile +3 -3
  18. data/spec/fixtures/{controlrepo_basic → controlrepos/basic}/environment.conf +0 -0
  19. data/spec/fixtures/{controlrepo_basic → controlrepos/basic}/hieradata/common.yaml +0 -0
  20. data/spec/fixtures/{controlrepo_basic → controlrepos/basic}/hieradata/nodes/example-node.yaml +0 -0
  21. data/spec/fixtures/{controlrepo_basic → controlrepos/basic}/manifests/site.pp +0 -0
  22. data/spec/fixtures/{controlrepo_basic → controlrepos/basic}/site/profile/manifests/base.pp +0 -0
  23. data/spec/fixtures/{controlrepo_basic → controlrepos/basic}/site/profile/manifests/example.pp +0 -0
  24. data/spec/fixtures/{controlrepo_basic → controlrepos/basic}/site/role/manifests/database_server.pp +0 -0
  25. data/spec/fixtures/{controlrepo_basic → controlrepos/basic}/site/role/manifests/example.pp +0 -0
  26. data/spec/fixtures/{controlrepo_basic → controlrepos/basic}/site/role/manifests/webserver.pp +0 -0
  27. data/spec/fixtures/controlrepos/control_branch/Puppetfile +18 -0
  28. data/spec/fixtures/{controlrepo_minimal → controlrepos/control_branch}/environment.conf +0 -0
  29. data/spec/fixtures/controlrepos/minimal/environment.conf +2 -0
  30. data/spec/onceover/controlrepo_spec.rb +1 -1
  31. data/templates/Gemfile.erb +0 -2
  32. metadata +17 -14
  33. data/spec/acceptance/controlrepo_spec.rb +0 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2c62563cf5b896213394193150a990cceaa671c
4
- data.tar.gz: 6872e6d67a0f3863745e5713ca33611f03978afa
3
+ metadata.gz: 5e3d01548767f7131506d6a421d7c87d38fbd85b
4
+ data.tar.gz: 17bb3e2bf387bd4dbb7032f2dddb8f0ed23b0215
5
5
  SHA512:
6
- metadata.gz: 4816f05bf7055452336ff743b177feffdb8b3d75bda749b148b85edd63655c82a9d3348e1f3c36469538dbc33f581f8d8e45910bb74ceb5a085e6a799c34f745
7
- data.tar.gz: '0883183e90d99f4ae800bbc8b843edb2202b9e744f88a053fdbabffe92ecb27a3c9ec65bcaee273c026230d5d252b175828f3a33a4a22353bb71115adae4f6f7'
6
+ metadata.gz: e8c006df260af3879470b5a9593ef00b02ca76746fadf95cb3d923b52a254b12e652c51f2cec2f116db325c8dbe32af2f40d124044acbdfa627e1a17d9a53490
7
+ data.tar.gz: 6941572c2ab56aaec5c572f8fa786d3b4bd6437c6cb8bf4efd4c90e9350d3299df2c33e470cb241a8b5740aeddad87469674243c231d6dea4dc88cf828ed50d0
@@ -1,4 +1,4 @@
1
- [submodule "spec/fixtures/puppet_controlrepo"]
2
- path = spec/fixtures/puppet_controlrepo
1
+ [submodule "spec/fixtures/controlrepos/puppet_controlrepo"]
2
+ path = spec/fixtures/controlrepos/puppet_controlrepo
3
3
  url = https://github.com/dylanratcliffe/puppet_controlrepo.git
4
4
  branch = production
@@ -61,7 +61,7 @@ Lint/AssignmentInCondition:
61
61
  Enabled: false
62
62
 
63
63
  # DISABLED - not useful
64
- Style/SpaceBeforeComment:
64
+ Layout/SpaceBeforeComment:
65
65
  Enabled: false
66
66
 
67
67
  # DISABLED - not useful
@@ -81,6 +81,9 @@ Style/RedundantSelf:
81
81
  Metrics/MethodLength:
82
82
  Enabled: false
83
83
 
84
+ Metrics/BlockLength:
85
+ Enabled: false
86
+
84
87
  # DISABLED - not useful
85
88
  Style/WhileUntilModifier:
86
89
  Enabled: false
@@ -90,8 +93,9 @@ Lint/AmbiguousRegexpLiteral:
90
93
  Enabled: false
91
94
 
92
95
  # DISABLED
93
- Lint/Eval:
96
+ Security/Eval:
94
97
  Enabled: false
98
+
95
99
  # DISABLED
96
100
  Lint/BlockAlignment:
97
101
  Enabled: false
@@ -140,7 +144,7 @@ Lint/UselessAssignment:
140
144
  Lint/Void:
141
145
  Enabled: false
142
146
 
143
- Style/AccessModifierIndentation:
147
+ Layout/AccessModifierIndentation:
144
148
  Enabled: false
145
149
 
146
150
  Style/AccessorMethodName:
@@ -149,13 +153,16 @@ Style/AccessorMethodName:
149
153
  Style/Alias:
150
154
  Enabled: false
151
155
 
152
- Style/AlignArray:
156
+ Layout/AlignArray:
157
+ Enabled: false
158
+
159
+ Layout/AlignHash:
153
160
  Enabled: false
154
161
 
155
- Style/AlignHash:
162
+ Layout/AlignParameters:
156
163
  Enabled: false
157
164
 
158
- Style/AlignParameters:
165
+ Layout/IndentHeredoc:
159
166
  Enabled: false
160
167
 
161
168
  Metrics/BlockNesting:
@@ -173,7 +180,16 @@ Style/BracesAroundHashParameters:
173
180
  Style/CaseEquality:
174
181
  Enabled: false
175
182
 
176
- Style/CaseIndentation:
183
+ Style/SymbolArray:
184
+ Enabled: false
185
+
186
+ Style/EmptyCaseCondition:
187
+ Enabled: false
188
+
189
+ Layout/CaseIndentation:
190
+ Enabled: false
191
+
192
+ Layout/MultilineMethodCallBraceLayout:
177
193
  Enabled: false
178
194
 
179
195
  Style/CharacterLiteral:
@@ -208,65 +224,65 @@ Style/WordArray:
208
224
  Style/UnneededPercentQ:
209
225
  Enabled: false
210
226
 
211
- Style/Tab:
227
+ Layout/Tab:
212
228
  Enabled: false
213
229
 
214
- Style/SpaceBeforeSemicolon:
230
+ Layout/SpaceBeforeSemicolon:
215
231
  Enabled: false
216
232
 
217
- Style/TrailingBlankLines:
233
+ Layout/TrailingBlankLines:
218
234
  Enabled: false
219
235
 
220
- Style/SpaceInsideBlockBraces:
236
+ Layout/SpaceInsideBlockBraces:
221
237
  Enabled: false
222
238
 
223
- Style/SpaceInsideBrackets:
239
+ Layout/SpaceInsideBrackets:
224
240
  Enabled: false
225
241
 
226
- Style/SpaceInsideHashLiteralBraces:
242
+ Layout/SpaceInsideHashLiteralBraces:
227
243
  Enabled: false
228
244
 
229
- Style/SpaceInsideParens:
245
+ Layout/SpaceInsideParens:
230
246
  Enabled: false
231
247
 
232
- Style/LeadingCommentSpace:
248
+ Layout/LeadingCommentSpace:
233
249
  Enabled: false
234
250
 
235
- Style/SpaceAfterColon:
251
+ Layout/SpaceAfterColon:
236
252
  Enabled: false
237
253
 
238
- Style/SpaceAfterComma:
254
+ Layout/SpaceAfterComma:
239
255
  Enabled: false
240
256
 
241
- Style/SpaceAroundKeyword:
257
+ Layout/SpaceAroundKeyword:
242
258
  Enabled: false
243
259
 
244
- Style/SpaceAfterMethodName:
260
+ Layout/SpaceAfterMethodName:
245
261
  Enabled: false
246
262
 
247
- Style/SpaceAfterNot:
263
+ Layout/SpaceAfterNot:
248
264
  Enabled: false
249
265
 
250
- Style/SpaceAfterSemicolon:
266
+ Layout/SpaceAfterSemicolon:
251
267
  Enabled: false
252
268
 
253
- Style/SpaceAroundEqualsInParameterDefault:
269
+ Layout/SpaceAroundEqualsInParameterDefault:
254
270
  Enabled: false
255
271
 
256
- Style/SpaceAroundOperators:
272
+ Layout/SpaceAroundOperators:
257
273
  Enabled: false
258
274
 
259
- Style/SpaceBeforeBlockBraces:
275
+ Layout/SpaceBeforeBlockBraces:
260
276
  Enabled: false
261
277
 
262
- Style/SpaceBeforeComma:
278
+ Layout/SpaceBeforeComma:
263
279
  Enabled: false
264
280
 
265
281
 
266
282
  Style/CollectionMethods:
267
283
  Enabled: false
268
284
 
269
- Style/CommentIndentation:
285
+ Layout/CommentIndentation:
270
286
  Enabled: false
271
287
 
272
288
  Style/ColonMethodCall:
@@ -287,10 +303,10 @@ Style/Documentation:
287
303
  Style/DefWithParentheses:
288
304
  Enabled: false
289
305
 
290
- Style/DeprecatedHashMethods:
306
+ Style/PreferredHashMethods:
291
307
  Enabled: false
292
308
 
293
- Style/DotPosition:
309
+ Layout/DotPosition:
294
310
  Enabled: false
295
311
 
296
312
  # DISABLED - used for converting to bool
@@ -300,25 +316,25 @@ Style/DoubleNegation:
300
316
  Style/EachWithObject:
301
317
  Enabled: false
302
318
 
303
- Style/EmptyLineBetweenDefs:
319
+ Layout/EmptyLineBetweenDefs:
304
320
  Enabled: false
305
321
 
306
- Style/IndentArray:
322
+ Layout/IndentArray:
307
323
  Enabled: false
308
324
 
309
- Style/IndentHash:
325
+ Layout/IndentHash:
310
326
  Enabled: false
311
327
 
312
- Style/IndentationConsistency:
328
+ Layout/IndentationConsistency:
313
329
  Enabled: false
314
330
 
315
- Style/IndentationWidth:
331
+ Layout/IndentationWidth:
316
332
  Enabled: false
317
333
 
318
- Style/EmptyLines:
334
+ Layout/EmptyLines:
319
335
  Enabled: false
320
336
 
321
- Style/EmptyLinesAroundAccessModifier:
337
+ Layout/EmptyLinesAroundAccessModifier:
322
338
  Enabled: false
323
339
 
324
340
  Style/EmptyLiteral:
@@ -327,7 +343,7 @@ Style/EmptyLiteral:
327
343
  Metrics/LineLength:
328
344
  Enabled: false
329
345
 
330
- Style/MethodCallParentheses:
346
+ Style/MethodCallWithoutArgsParentheses:
331
347
  Enabled: false
332
348
 
333
349
  Style/MethodDefParentheses:
@@ -336,7 +352,7 @@ Style/MethodDefParentheses:
336
352
  Style/LineEndConcatenation:
337
353
  Enabled: false
338
354
 
339
- Style/TrailingWhitespace:
355
+ Layout/TrailingWhitespace:
340
356
  Enabled: false
341
357
 
342
358
  Style/StringLiterals:
@@ -487,7 +503,7 @@ Metrics/ParameterLists:
487
503
  Lint/RequireParentheses:
488
504
  Enabled: false
489
505
 
490
- Style/SpaceBeforeFirstArg:
506
+ Layout/SpaceBeforeFirstArg:
491
507
  Enabled: false
492
508
 
493
509
  Style/ModuleFunction:
@@ -508,7 +524,7 @@ Metrics/PerceivedComplexity:
508
524
  Style/SymbolProc:
509
525
  Enabled: false
510
526
 
511
- Style/SpaceInsideRangeLiteral:
527
+ Layout/SpaceInsideRangeLiteral:
512
528
  Enabled: false
513
529
 
514
530
  Style/InfiniteLoop:
@@ -520,7 +536,7 @@ Style/BarePercentLiterals:
520
536
  Style/PercentQLiterals:
521
537
  Enabled: false
522
538
 
523
- Style/MultilineBlockLayout:
539
+ Layout/MultilineBlockLayout:
524
540
  Enabled: false
525
541
 
526
542
  Metrics/AbcSize:
@@ -532,22 +548,22 @@ Style/MutableConstant:
532
548
  Style/BlockDelimiters:
533
549
  Enabled: false
534
550
 
535
- Style/EmptyLinesAroundClassBody:
551
+ Layout/EmptyLinesAroundClassBody:
536
552
  Enabled: false
537
553
 
538
554
  Style/ConditionalAssignment:
539
555
  Enabled: false
540
556
 
541
- Style/ExtraSpacing:
557
+ Layout/ExtraSpacing:
542
558
  Enabled: false
543
559
 
544
- Style/EmptyLinesAroundBlockBody:
560
+ Layout/EmptyLinesAroundBlockBody:
545
561
  Enabled: false
546
562
 
547
- Style/EmptyLinesAroundModuleBody:
563
+ Layout/EmptyLinesAroundModuleBody:
548
564
  Enabled: false
549
565
 
550
- Style/MultilineOperationIndentation:
566
+ Layout/MultilineOperationIndentation:
551
567
  Enabled: false
552
568
 
553
569
  Style/EmptyElse:
@@ -556,13 +572,13 @@ Style/EmptyElse:
556
572
  Style/StringLiteralsInInterpolation:
557
573
  Enabled: false
558
574
 
559
- Style/MultilineMethodCallIndentation:
575
+ Layout/MultilineMethodCallIndentation:
560
576
  Enabled: false
561
577
 
562
578
  Metrics/ModuleLength:
563
579
  Enabled: false
564
580
 
565
- Style/EmptyLinesAroundMethodBody:
581
+ Layout/EmptyLinesAroundMethodBody:
566
582
  Enabled: false
567
583
 
568
584
  Lint/IneffectiveAccessModifier:
@@ -571,28 +587,28 @@ Lint/IneffectiveAccessModifier:
571
587
  Performance/StringReplacement:
572
588
  Enabled: false
573
589
 
574
- Style/ClosingParenthesisIndentation:
590
+ Layout/ClosingParenthesisIndentation:
575
591
  Enabled: false
576
592
 
577
593
  Style/UnneededInterpolation:
578
594
  Enabled: false
579
595
 
580
- Style/ElseAlignment:
596
+ Layout/ElseAlignment:
581
597
  Enabled: false
582
598
 
583
599
  Style/FrozenStringLiteralComment:
584
600
  Enabled: false
585
601
 
586
- Style/FirstParameterIndentation:
602
+ Layout/FirstParameterIndentation:
587
603
  Enabled: false
588
604
 
589
605
  Style/IfInsideElse:
590
606
  Enabled: false
591
607
 
592
- Style/IndentAssignment:
608
+ Layout/IndentAssignment:
593
609
  Enabled: false
594
610
 
595
- Style/SpaceAroundBlockParameters:
611
+ Layout/SpaceAroundBlockParameters:
596
612
  Enabled: false
597
613
 
598
614
  Style/ParallelAssignment:
@@ -616,7 +632,7 @@ Performance/Casecmp:
616
632
  Lint/NestedMethodDefinition:
617
633
  Enabled: false
618
634
 
619
- Style/SpaceInsideStringInterpolation:
635
+ Layout/SpaceInsideStringInterpolation:
620
636
  Enabled: false
621
637
 
622
638
  Performance/RedundantMerge:
@@ -637,7 +653,7 @@ Performance/Count:
637
653
  Style/NestedParenthesizedCalls:
638
654
  Enabled: false
639
655
 
640
- Style/RescueEnsureAlignment:
656
+ Layout/RescueEnsureAlignment:
641
657
  Enabled: false
642
658
 
643
659
  Lint/DuplicateMethods:
@@ -649,9 +665,6 @@ Performance/RangeInclude:
649
665
  Style/TrailingUnderscoreVariable:
650
666
  Enabled: false
651
667
 
652
- Lint/LiteralInInterpolation:
653
- Enabled: false
654
-
655
668
  Performance/DoubleStartEndWith:
656
669
  Enabled: false
657
670
 
@@ -661,7 +674,7 @@ Performance/RedundantSortBy:
661
674
  Performance/TimesMap:
662
675
  Enabled: false
663
676
 
664
- Style/InitialIndentation:
677
+ Layout/InitialIndentation:
665
678
  Enabled: false
666
679
 
667
680
  Style/StructInheritance:
@@ -676,4 +689,5 @@ Style/IfUnlessModifierOfIfUnless:
676
689
  Style/ZeroLengthPredicate:
677
690
  Enabled: false
678
691
 
679
-
692
+ Bundler/OrderedGems:
693
+ Enabled: false
data/Rakefile CHANGED
@@ -20,16 +20,13 @@ desc "Run unit tests"
20
20
  task rspec_unit_tests: [:syntax, :rubocop, :spec]
21
21
 
22
22
  desc "Run acceptance cucumber tests"
23
- task cucumber_acceptance_tests: [:syntax, :rubocop, :cucumber]
24
-
25
- desc "Run acceptance rspec tests"
26
- task rspec_acceptance_tests: [:syntax, :rubocop, :fixtures, :acceptance]
23
+ task cucumber_acceptance_tests: [:syntax, :rubocop, :fixtures, :cucumber]
27
24
 
28
25
  desc "Run full set of tests"
29
- task full_tests: [:rspec_unit_tests, :rspec_acceptance_tests, :cucumber_acceptance_tests]
26
+ task full_tests: [:rspec_unit_tests, :cucumber_acceptance_tests]
30
27
 
31
28
  task :syntax do
32
- paths = ['lib', 'spec/onceover', 'spec/acceptance', 'features']
29
+ paths = ['lib', 'spec/onceover', 'features']
33
30
  require 'find'
34
31
  Find.find(*paths) do |path|
35
32
  next unless path =~ /\.rb$/
@@ -48,4 +45,3 @@ task :fixtures do
48
45
  system 'git submodule init && git submodule update --recursive'
49
46
  raise "Couldn't clone controlrepo to fixtures directory" unless $?.success?
50
47
  end
51
-
@@ -6,14 +6,13 @@ Feature: Initialize Onceover application
6
6
  Background:
7
7
  Given onceover executable
8
8
 
9
- Scenario: Initialize basic repo
10
- Given control repo "controlrepo_basic"
9
+ Scenario: Initialize basic repo
10
+ Given control repo "basic"
11
11
  When I run onceover command "init"
12
12
  Then I should not see any errors
13
13
  And I should see generated all necessary files and folders
14
14
 
15
- Scenario: Initialize repo with missing environment.conf file
16
- Given control repo "controlrepo_basic" without "environment.conf"
15
+ Scenario: Initialize repo with missing environment.conf file
16
+ Given control repo "basic" without "environment.conf"
17
17
  When I run onceover command "init"
18
18
  Then I should see error with message pattern "No such file or directory.*environment.conf"
19
-
@@ -6,14 +6,23 @@ Feature: Run rspec and acceptance test suits
6
6
  Background:
7
7
  Given onceover executable
8
8
 
9
- Scenario: Run correct spec tests
10
- Given initialized control repo "controlrepo_basic"
9
+ Scenario: Run correct spec tests
10
+ Given initialized control repo "basic"
11
11
  When I run onceover command "run spec"
12
12
  Then I should not see any errors
13
13
 
14
- Scenario: Run spec tests with misspelled module in Puppetfile
15
- Given initialized control repo "controlrepo_basic"
14
+ Scenario: Run spec tests with misspelled module in Puppetfile
15
+ Given initialized control repo "basic"
16
16
  And in Puppetfile is misspelled module's name
17
17
  When I run onceover command "run spec"
18
18
  Then I should see error with message pattern "The module acme-not_exists does not exist"
19
19
 
20
+ Scenario: Run advanced spec tests
21
+ Given control repo "puppet_controlrepo"
22
+ When I run onceover command "run spec"
23
+ Then I should not see any errors
24
+
25
+ Scenario: Check that control_branch functionality works
26
+ Given initialized control repo "control_branch"
27
+ When I run onceover command "run spec"
28
+ Then the temporary Puppetfile should contain the git branch
@@ -0,0 +1,28 @@
1
+ Feature: Show the state of things
2
+ For a correct controlrepo I would like to see details of the Puppetfile and
3
+ the things that have been detedted by onceover in the controlrepo.
4
+
5
+ Background:
6
+ Given onceover executable
7
+
8
+ Scenario: Show info for basic repo
9
+ Given initialized control repo "basic"
10
+ When I run onceover command "show repo"
11
+ Then I should not see any errors
12
+
13
+ Scenario: Detect roles and profiles
14
+ Given initialized control repo "basic"
15
+ When I run onceover command "show repo"
16
+ Then I should not see any errors
17
+ And I should see message pattern "roles.*role::database_server"
18
+ And I should see message pattern "roles.*role::webserver"
19
+ And I should see message pattern "roles.*role::example"
20
+ And I should see message pattern "profiles.*profile::example"
21
+ And I should see message pattern "profiles.*profile::base"
22
+
23
+ Scenario: Detect modules
24
+ Given initialized control repo "basic"
25
+ When I run onceover command "show puppetfile"
26
+ Then I should not see any errors
27
+ And I should see message pattern "puppetlabs-stdlib\s+\|\s+4\.11\.0"
28
+ And I should see message pattern "apache\s+\|\s+N/A"
@@ -6,8 +6,8 @@ Given(/^control repo "([^"]*)"$/) do |controlrepo_name|
6
6
  @repo = ControlRepo_Helper.new( controlrepo_name )
7
7
  @cmd.controlrepo = @repo
8
8
  FileUtils.rm_rf @repo.root_folder
9
- FileUtils.mkdir_p 'tmp'
10
- FileUtils.cp_r "spec/fixtures/#{controlrepo_name}", 'tmp'
9
+ FileUtils.mkdir_p @repo.tmp_folder
10
+ FileUtils.cp_r "spec/fixtures/controlrepos/#{controlrepo_name}", @repo.tmp_folder
11
11
  end
12
12
 
13
13
  Given(/^initialized control repo "([^"]*)"$/) do |controlrepo_name|
@@ -45,6 +45,9 @@ Then(/^I should see error with message pattern "([^"]*)"$/) do |err_msg_regexp|
45
45
  expect(@cmd.output.match err_msg_regexp).to_not be nil
46
46
  end
47
47
 
48
- Given(/^in Puppetfile is misspelled module's name$/) do
49
- @repo.add_line_to_puppetfile %Q(mod "acme/not_exists", "7.7.7")
48
+ Then(/^I should see message pattern "([^"]*)"$/) do |err_msg_regexp|
49
+ expect(@cmd.success?).to be true
50
+ puts @cmd.output unless @cmd.success?
51
+ expect(@cmd.output).to match(err_msg_regexp)
52
+ puts @cmd.output.match(err_msg_regexp).to_s
50
53
  end
@@ -1,3 +1,7 @@
1
+ Given(/^in Puppetfile is misspelled module's name$/) do
2
+ @repo.add_line_to_puppetfile %Q(mod "acme/not_exists", "7.7.7")
3
+ end
4
+
1
5
  Then(/^I should see generated all necessary files and folders$/) do
2
6
  files = [ 'spec/onceover.yaml', 'Rakefile', 'Gemfile' ].map { |x| @repo.root_folder + x }
3
7
  folders = [ 'spec/factsets', 'spec/pre_conditions'].map! { |x| @repo.root_folder + x}
@@ -0,0 +1,9 @@
1
+ Then(/^the temporary Puppetfile should contain \/(.*)\/$/) do |regex|
2
+ puppetfile = File.read(@repo.onceover_temp_puppetfile)
3
+ expect(puppetfile).to match(Regexp.new(regex))
4
+ end
5
+
6
+ Then(/^the temporary Puppetfile should contain the git branch/) do
7
+ git_branch = `git rev-parse --abbrev-ref HEAD`.chomp
8
+ step %Q(the temporary Puppetfile should contain /#{git_branch}/)
9
+ end
@@ -19,7 +19,7 @@ class Command_Helper
19
19
  end
20
20
 
21
21
  def generate_command
22
- controlrepo_param = @controlrepo ? "--path #{@controlrepo.root_folder}" : ''
22
+ controlrepo_param = @controlrepo ? "--path #{File.expand_path(@controlrepo.root_folder)}" : ''
23
23
  return "#{@executable} #{@command} #{controlrepo_param}"
24
24
  end
25
25
 
@@ -1,16 +1,30 @@
1
1
  class ControlRepo_Helper
2
2
 
3
+ attr_reader :tmp_folder
4
+
3
5
  def initialize( name )
4
- @name = name
5
- @tmp_folder = 'tmp/'
6
+ @name = name
7
+ @tmp_folder = '.cucumber/tmp/'
6
8
  end
7
9
 
8
10
  def root_folder
9
11
  return @tmp_folder + @name + '/'
10
12
  end
11
13
 
14
+ def puppetfile
15
+ return root_folder + "Puppetfile"
16
+ end
17
+
18
+ def onceover_temp_root_folder
19
+ return root_folder + '.onceover/etc/puppetlabs/code/environments/production/'
20
+ end
21
+
22
+ def onceover_temp_puppetfile
23
+ return onceover_temp_root_folder + "Puppetfile"
24
+ end
25
+
12
26
  def add_line_to_puppetfile( line )
13
- open(root_folder + 'Puppetfile', 'a') { |f| f.puts line }
27
+ open(puppetfile, 'a') { |f| f.puts line }
14
28
  end
15
29
 
16
30
  end
@@ -439,16 +439,20 @@ class Onceover
439
439
  #Onceover::Controlrepo.init_write_file(generate_nodesets(repo),repo.nodeset_file)
440
440
  init_write_file(
441
441
  evaluate_template('pre_conditions_README.md.erb', binding),
442
- File.expand_path('./pre_conditions/README.md', repo.spec_dir))
442
+ File.expand_path('./pre_conditions/README.md', repo.spec_dir)
443
+ )
443
444
  init_write_file(
444
445
  evaluate_template('factsets_README.md.erb', binding),
445
- File.expand_path('./factsets/README.md', repo.spec_dir))
446
+ File.expand_path('./factsets/README.md', repo.spec_dir)
447
+ )
446
448
  init_write_file(
447
449
  evaluate_template('Rakefile.erb', binding),
448
- File.expand_path('./Rakefile', repo.root))
450
+ File.expand_path('./Rakefile', repo.root)
451
+ )
449
452
  init_write_file(
450
453
  evaluate_template('Gemfile.erb', binding),
451
- File.expand_path('./Gemfile', repo.root))
454
+ File.expand_path('./Gemfile', repo.root)
455
+ )
452
456
 
453
457
  # Add .onceover to Gitignore
454
458
  gitignore_path = File.expand_path('.gitignore', repo.root)
@@ -4,7 +4,7 @@ module Onceover::Logger
4
4
  def logger
5
5
  unless $logger
6
6
  # here we setup a color scheme called 'bright'
7
- Logging.color_scheme( 'bright',
7
+ Logging.color_scheme('bright',
8
8
  :levels => {
9
9
  :debug => :cyan,
10
10
  :info => :green,
@@ -28,7 +28,7 @@ class Onceover
28
28
 
29
29
  def initialize(file, opts = {})
30
30
  begin
31
- config = YAML.load(File.read(file))
31
+ config = YAML.safe_load(File.read(file))
32
32
  rescue Errno::ENOENT
33
33
  raise "Could not find #{file}"
34
34
  rescue Psych::SyntaxError
@@ -153,7 +153,7 @@ class Onceover
153
153
  logger.debug "Reading pre_conditions from #{condition_file}"
154
154
  puppetcode << File.read(condition_file)
155
155
  end
156
- return nil if puppetcode.count == 0
156
+ return nil if puppetcode.count.zero?
157
157
  puppetcode.join("\n")
158
158
  end
159
159
 
@@ -203,6 +203,22 @@ class Onceover
203
203
  files_to_copy.each do |file|
204
204
  FileUtils.cp(file,"#{temp_controlrepo}/#{(Pathname(file).relative_path_from(Pathname(repo.root))).to_s}")
205
205
  end
206
+
207
+ # When using puppetfile vs deploy with r10k, we want to respect the :control_branch
208
+ # located in the Puppetfile. To accomplish that, we use git and find the current
209
+ # branch name, then replace strings within the staged puppetfile, prior to copying.
210
+
211
+ logger.debug "Checking current working branch"
212
+ git_branch = `git rev-parse --abbrev-ref HEAD`.chomp
213
+
214
+ logger.debug "found #{git_branch} as current working branch"
215
+ puppetfile_contents = File.read("#{temp_controlrepo}/Puppetfile")
216
+
217
+ logger.debug "replacing :control_branch mentions in the Puppetfile with #{git_branch}"
218
+ new_puppetfile_contents = puppetfile_contents.gsub(/:control_branch/, "'#{git_branch}'")
219
+ File.write("#{temp_controlrepo}/Puppetfile", new_puppetfile_contents)
220
+
221
+
206
222
  FileUtils.mkdir_p("#{repo.tempdir}/#{repo.environmentpath}/production")
207
223
 
208
224
  logger.debug "Copying #{temp_controlrepo} to #{repo.tempdir}/#{repo.environmentpath}/production"
@@ -1,9 +1,10 @@
1
1
  # -*- encoding: utf-8 -*-
2
+
2
3
  $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
3
4
 
4
5
  Gem::Specification.new do |s|
5
6
  s.name = "onceover"
6
- s.version = "3.2.8"
7
+ s.version = "3.3.0"
7
8
  s.authors = ["Dylan Ratcliffe"]
8
9
  s.email = ["dylan.ratcliffe@puppet.com"]
9
10
  s.homepage = "https://github.com/dylanratcliffe/onceover"
@@ -8,9 +8,9 @@ mod "puppetlabs/stdlib", '4.11.0'
8
8
 
9
9
  # Modules from Git
10
10
  # Examples: https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd#examples
11
- #mod 'apache',
12
- # :git => 'https://github.com/puppetlabs/puppetlabs-apache',
13
- # :commit => '83401079053dca11d61945bd9beef9ecf7576cbf'
11
+ mod 'apache',
12
+ :git => 'https://github.com/puppetlabs/puppetlabs-apache',
13
+ :commit => '83401079053dca11d61945bd9beef9ecf7576cbf'
14
14
 
15
15
  #mod 'apache',
16
16
  # :git => 'https://github.com/puppetlabs/puppetlabs-apache',
@@ -0,0 +1,18 @@
1
+ forge "http://forge.puppetlabs.com"
2
+ #
3
+ # I want to download some modules to check if r10k feature in Onceover works correctly.
4
+ #
5
+
6
+ # Versions should be updated to be the latest at the time you start
7
+ mod "puppetlabs/stdlib", '4.11.0'
8
+
9
+ # Modules from Git
10
+ # Examples: https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd#examples
11
+ #mod 'apache',
12
+ # :git => 'https://github.com/puppetlabs/puppetlabs-apache',
13
+ # :commit => '83401079053dca11d61945bd9beef9ecf7576cbf'
14
+
15
+ mod 'apache',
16
+ :git => 'https://github.com/puppetlabs/puppetlabs-apache',
17
+ :branch => :control_branch,
18
+ :default_branch => 'master'
@@ -0,0 +1,2 @@
1
+ modulepath = site:modules:$basemodulepath
2
+ config_version = 'scripts/config_version.sh $environmentpath $environment'
@@ -6,7 +6,7 @@ describe "Onceover::Controlrepo" do
6
6
  before do
7
7
  @repo = Onceover::Controlrepo.new(
8
8
  {
9
- path:'spec/fixtures/controlrepo_minimal'
9
+ path:'spec/fixtures/controlrepos/minimal'
10
10
  }
11
11
  )
12
12
  end
@@ -1,5 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gem 'onceover'
4
- gem 'beaker', '~> 2.0'
5
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onceover
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.8
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Ratcliffe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-11 00:00:00.000000000 Z
11
+ date: 2018-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -344,8 +344,10 @@ files:
344
344
  - features/help.feature
345
345
  - features/init.feature
346
346
  - features/run.feature
347
+ - features/show.feature
347
348
  - features/step_definitions/common.rb
348
349
  - features/step_definitions/init.rb
350
+ - features/step_definitions/run.rb
349
351
  - features/support/command_helper.rb
350
352
  - features/support/controlrepo_helper.rb
351
353
  - features/support/env.rb
@@ -367,18 +369,19 @@ files:
367
369
  - lib/onceover/test.rb
368
370
  - lib/onceover/testconfig.rb
369
371
  - onceover.gemspec
370
- - spec/acceptance/controlrepo_spec.rb
371
- - spec/fixtures/controlrepo_basic/Puppetfile
372
- - spec/fixtures/controlrepo_basic/environment.conf
373
- - spec/fixtures/controlrepo_basic/hieradata/common.yaml
374
- - spec/fixtures/controlrepo_basic/hieradata/nodes/example-node.yaml
375
- - spec/fixtures/controlrepo_basic/manifests/site.pp
376
- - spec/fixtures/controlrepo_basic/site/profile/manifests/base.pp
377
- - spec/fixtures/controlrepo_basic/site/profile/manifests/example.pp
378
- - spec/fixtures/controlrepo_basic/site/role/manifests/database_server.pp
379
- - spec/fixtures/controlrepo_basic/site/role/manifests/example.pp
380
- - spec/fixtures/controlrepo_basic/site/role/manifests/webserver.pp
381
- - spec/fixtures/controlrepo_minimal/environment.conf
372
+ - spec/fixtures/controlrepos/basic/Puppetfile
373
+ - spec/fixtures/controlrepos/basic/environment.conf
374
+ - spec/fixtures/controlrepos/basic/hieradata/common.yaml
375
+ - spec/fixtures/controlrepos/basic/hieradata/nodes/example-node.yaml
376
+ - spec/fixtures/controlrepos/basic/manifests/site.pp
377
+ - spec/fixtures/controlrepos/basic/site/profile/manifests/base.pp
378
+ - spec/fixtures/controlrepos/basic/site/profile/manifests/example.pp
379
+ - spec/fixtures/controlrepos/basic/site/role/manifests/database_server.pp
380
+ - spec/fixtures/controlrepos/basic/site/role/manifests/example.pp
381
+ - spec/fixtures/controlrepos/basic/site/role/manifests/webserver.pp
382
+ - spec/fixtures/controlrepos/control_branch/Puppetfile
383
+ - spec/fixtures/controlrepos/control_branch/environment.conf
384
+ - spec/fixtures/controlrepos/minimal/environment.conf
382
385
  - spec/onceover/controlrepo_spec.rb
383
386
  - spec/spec_helper.rb
384
387
  - templates/.fixtures.yml.erb
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
- require 'onceover/controlrepo'
3
-
4
- describe "Onceover::Controlrepo" do
5
- context "in a complex repo" do
6
- before do
7
- @repo = Onceover::Controlrepo.new(
8
- {
9
- path:'spec/fixtures/puppet_controlrepo'
10
- }
11
- )
12
- end
13
-
14
- context "when initialising the object" do
15
- it { expect(@repo).not_to be_nil }
16
- end
17
-
18
- context "when running the tests" do
19
- it "doesn't die horribly" do
20
- expect{
21
- Dir.chdir('spec/fixtures/puppet_controlrepo') do
22
- require 'onceover/controlrepo'
23
- require 'onceover/cli'
24
- require 'onceover/runner'
25
- require 'onceover/testconfig'
26
- require 'onceover/logger'
27
-
28
- repo = Onceover::Controlrepo.new({})
29
- runner = Onceover::Runner.new(repo,Onceover::TestConfig.new(repo.onceover_yaml, {}), :spec)
30
- runner.prepare!
31
- runner.run_spec!
32
- end
33
- }.not_to raise_error
34
- end
35
- end
36
- end
37
- end