r10k 3.0.4 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8cc458f9c6f5fc825c4a915db8ba1f4c62d9f9e3
4
- data.tar.gz: f1bcb084a79e0fc0bcf17352a98b2cd162fc1fa5
3
+ metadata.gz: a60c1ccc9338827361ca4116b58d3619f6ff755b
4
+ data.tar.gz: 7e473d21e8fa5a96e64787191d721790d7403bbf
5
5
  SHA512:
6
- metadata.gz: aa362d85081c4378839c4027f9feffd8411606d55c88f4101c6fe334eb872b0a470bac76a90ec070532f802310588fd3ff66a63b7164f3e986fd7af0ba1dddc7
7
- data.tar.gz: 77b14cd6661fcf9c70d73aec1ad11faccf65ac30479872b08e86055436b0f64fb40ec764e5b5d9174d0ea036ac9430052555057de769d475cee6d07b1f6596f9
6
+ metadata.gz: a48693802bbc801288990cebc451d088b70807dbb1b4e9eb3e9e83594ad096a0233c5f903f2cf454bb0873fa08e3aba51cdb54609b47bbfb1e981444ac14e6d4
7
+ data.tar.gz: 875ce9e183d4f5191b36d0ef45a271b308d891b88a27f994c10c6bd57a66486448b68c96704e1769a87717754505d8d6fdefa43bd52de007449e5e4152766806
data/.travis.yml CHANGED
@@ -1,26 +1,15 @@
1
1
  ---
2
2
  language: ruby
3
- services:
4
- - docker
5
3
  bundler_args: "--without system"
6
4
  script: "bundle exec rspec --color --format documentation spec/unit"
7
5
  notifications:
8
6
  email: false
9
7
  sudo: false
8
+ before_install: gem update bundler
9
+ rvm:
10
+ - "2.5"
11
+ - "2.4"
12
+ - "2.3"
13
+ - "jruby"
10
14
  jdk:
11
15
  - oraclejdk8
12
- before_install: gem install bundler -v '< 2' --no-document
13
- matrix:
14
- include:
15
- - stage: r10k tests
16
- rvm: 2.5.0
17
- - stage: r10k tests
18
- rvm: 2.4.0
19
- - stage: r10k tests
20
- rvm: 2.3.0
21
- - stage: r10k tests
22
- rvm: jruby
23
- - stage: r10k container tests
24
- language: generic
25
- script:
26
- - cd docker && make lint && make build && make test
data/CHANGELOG.mkd CHANGED
@@ -1,60 +1,72 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
- 3.0.4
5
- ----
4
+ 3.1.0
5
+ -----
6
+
7
+ ## New Feature
8
+
9
+ Substitute environments acted on in postrun command.
10
+
11
+ Now post run commands that contain the string "$modifiedenvs"
12
+ (eg. ["/usr/local/bin/my-postrun-cmd", "--verbose", "$modifiedenvs"])
13
+ will have the string substituted with a space separated list
14
+ of environments acted upon (either a single environment if
15
+ specified on the command line or all environments).
16
+
17
+ Specifically this should allow users to easily wrap
18
+ `puppet generate types` and matches the terminology used
19
+ in g10k.
20
+
21
+ Many thanks to @raphink for the contribution.
6
22
 
7
- ### Changes
8
- - Flag for overriding default branch configuration in Puppetfile
9
- - Plumbing for internationalization
10
- - Numerous test fixes and legacy docker work
11
23
 
12
24
  3.0.3
13
25
  ----
14
26
 
15
- ### Changes
27
+ ## Bug Fixes
16
28
 
17
- - (RK-324) Fix Ruby pipe bug affecting Ubuntu
29
+ (RK-324) Fix Ruby pipe bug affecting Ubuntu
18
30
 
19
31
  3.0.2
20
32
  ----
21
33
 
22
- ### Changes
34
+ ## Changes
23
35
 
24
- - Minor test fixes.
36
+ Minor test fixes.
25
37
 
26
38
  3.0.1
27
39
  ----
28
40
 
29
- ### Changes
41
+ ## Changes
30
42
 
31
43
  Because of dependency issues R10K 3.0.0 required Ruby >= 2.3
32
44
  rather than the reported 2.0. This release makes the requirement of
33
45
  Ruby >= 2.3 official and documented.
34
46
 
35
- - (#853) ([RK-327](https://tickets.puppetlabs.com/browse/RK-327) Uninitialized Constant Cri::Error
36
- When resolving the Cri dependency >= 2.13 R10K would fail with an
37
- uninitialized constant error. Thanks to @ostavnaas for the bug report,
38
- @ddfreyne for the fix, and @baurmatt for the review.
47
+ (#853) ([RK-327](https://tickets.puppetlabs.com/browse/RK-327) Uninitialized Constant Cri::Error
48
+ When resolving the Cri dependency >= 2.13 R10K would fail with an
49
+ uninitialized constant error. Thanks to @ostavnaas for the bug report,
50
+ @ddfreyne for the fix, and @baurmatt for the review.
39
51
 
40
52
 
41
53
  3.0.0
42
54
  ----
43
55
 
44
- ### Changes
56
+ ## Changes
45
57
 
46
- #### Known issues
58
+ ### Known issues
47
59
  - Child processes may die unexpectedly when deploying many environments
48
60
  on Ubuntu Bionic. See
49
61
  [RK-324](https://tickets.puppetlabs.com/browse/RK-324).
50
62
 
51
- #### Backwards breaking changes
63
+ ### Backwards breaking changes
52
64
  - Drop support for Ruby < 2.0
53
65
  - Remove support for PUPPETFILE and PUPPETFILE_DIR environment variables
54
66
  when running the `puppetfile` action, please use flags instead.
55
67
  - Fail when duplicate module definitions in Puppetfile
56
68
 
57
- #### Bug fixes
69
+ ### Bug fixes
58
70
  - More reliable pruning of refs on fetch
59
71
  - Improved error messaging when:
60
72
  - Unable to connect to a proxy
@@ -62,32 +74,24 @@ Ruby >= 2.3 official and documented.
62
74
  - Unable to parse Puppetfile
63
75
  - Various perfomance improvements
64
76
 
65
- 2.6.6
66
- ----
67
-
68
- ### Changes
69
- - Flag for overriding default branch configuration in Puppetfile
70
- - Plumbing for internationalization
71
- - Numerous test fixes and legacy docker work
72
77
 
73
78
  2.6.5
74
79
  ----
75
80
 
76
- ### Bug Fix
81
+ ## Bug Fix
77
82
 
78
83
  (RK-324) Fix Ruby pipe bug affecting Ubuntu
79
84
 
80
85
  2.6.4
81
86
  ----
82
87
 
83
- ### Changes
88
+ ## Changes
84
89
 
85
90
  Numerous test fixes.
86
91
 
87
92
  2.6.3
88
93
  ----
89
-
90
- ### Changes
94
+ ## Changes
91
95
 
92
96
  Update specs with new error string.
93
97
 
@@ -96,7 +100,6 @@ when a release is made on that branch.
96
100
 
97
101
  2.6.2
98
102
  -----
99
-
100
103
  ### Changes
101
104
 
102
105
  (RK-311) Yard dependency updated for security fix.
data/azure-pipelines.yml CHANGED
@@ -5,15 +5,9 @@ pool:
5
5
  name: Default
6
6
 
7
7
  variables:
8
- NAMESPACE: puppet
9
-
10
- # completely disables the pipeline
11
- trigger: none
12
- pr: none
8
+ BUILD_REPOSITORY: 127.0.0.1
13
9
 
14
10
  steps:
15
- - checkout: self
16
- clean: true
17
11
  - powershell: |
18
12
  $line = '=' * 80
19
13
  Write-Host "$line`nWindows`n$line`n"
@@ -52,27 +46,27 @@ steps:
52
46
  name: hostinfo
53
47
  - powershell: |
54
48
  . ./docker/ci/build.ps1
55
- Lint-Dockerfile -Path ./docker/r10k/Dockerfile
56
- displayName: Lint r10k Dockerfile
57
- name: lint_dockerfile
49
+ Invoke-ContainerBuildSetup
50
+ displayName: Prepare Build Environment
51
+ name: build_prepare
58
52
  - powershell: |
59
53
  . ./docker/ci/build.ps1
60
- Build-Container -Namespace $ENV:NAMESPACE
61
- displayName: Build r10k Container
62
- name: build_r10k_container
54
+ Build-Container -Name r10k -Repository $ENV:BUILD_REPOSITORY
55
+ displayName: Build r10k
56
+ name: build_r10k
63
57
  - powershell: |
64
58
  . ./docker/ci/build.ps1
65
- Invoke-ContainerTest -Namespace $ENV:NAMESPACE
59
+ Invoke-ContainerTest -Name r10k -Repository $ENV:BUILD_REPOSITORY
66
60
  displayName: Test r10k
67
61
  name: test_r10k
68
62
  - task: PublishTestResults@2
69
63
  displayName: Publish r10k test results
70
64
  inputs:
71
65
  testResultsFormat: 'JUnit'
72
- testResultsFiles: 'docker/TEST-*.xml'
66
+ testResultsFiles: 'docker/**/TEST-*.xml'
73
67
  testRunTitle: r10k Test Results
74
68
  - powershell: |
75
69
  . ./docker/ci/build.ps1
76
- Clear-ContainerBuilds -Name r10k
70
+ Clear-ContainerBuilds
77
71
  displayName: Container Cleanup
78
72
  condition: always()
@@ -183,6 +183,9 @@ postrun: ['/usr/bin/curl', '-F', 'deploy=done', 'http://my-app.site/endpoint']
183
183
 
184
184
  The postrun setting can only be set once.
185
185
 
186
+ Occurrences of the string `$modifiedenvs` in the postrun command will be
187
+ replaced with the current environment(s) being deployed.
188
+
186
189
  ### sources
187
190
 
188
191
  The `sources` setting specifies what repositories should be used for creating
@@ -60,18 +60,6 @@ Update a single environment and force an update of modules:
60
60
  This will update the given environment and update all contained modules. This is
61
61
  useful if you want to make sure that a given environment is fully up to date.
62
62
 
63
- - - -
64
-
65
- Update a single environment and specify a default branch override:
66
-
67
- r10k deploy environment my_working_environment --puppetfile --default-branch-override default_branch_override
68
-
69
- This will update the given environment and update all contained modules, overrideing
70
- the :default_branch entry in the Puppetfile of each module. This is used primarily to allow
71
- automated r10k solutions using the control_branch pattern with a temporary branch deployment to
72
- ensure the deployment is pushed to the correct module repository branch. Note that the :default_branch
73
- is only ever utilized if the desired ref cannot be located.
74
-
75
63
  ### Deploying modules
76
64
 
77
65
  Update a single module across all environments:
data/doc/faq.mkd CHANGED
@@ -1,6 +1,41 @@
1
1
  Frequently Asked Questions
2
2
  ==========================
3
3
 
4
+ ### How can run I `puppet generate types` for each changed environment during deployment?
5
+
6
+ The command `puppet generate types` creates Puppet signatures for custom
7
+ types circumventing the need to load their Ruby code during compilation.
8
+ This prevents the type definitions from "leaking" across environments.
9
+
10
+ Best practice currently is to run this command as part of your Puppet
11
+ code deployment pipeline, and r10k's postrun command ability is a natural
12
+ place to do so.
13
+
14
+ The postrun command will have any occurance of "$modifiedenvs" replaced
15
+ with a space-seperated list of environments the deploy was configured to
16
+ modify. For example creating the script:
17
+
18
+ ```
19
+ $ cat /usr/local/bin/generate-puppet-types.sh
20
+ !#/bin/bash
21
+
22
+ for environment in $1; do
23
+ /opt/puppetlabs/bin/puppet generate types --environment $environment
24
+ done
25
+ ```
26
+
27
+ And configuring r10k such:
28
+ ```
29
+ $ tail -2 /etc/puppetlabs/r10k/r10k.yaml
30
+
31
+ postrun: ["/usr/local/bin/generate-puppet-types.sh", "$modifiedenvs"]
32
+ ```
33
+
34
+ Should provide you with the necessary generate type definitions for
35
+ improved environment isolation.
36
+
37
+
38
+
4
39
  ### The default Git branch is 'master', while the default Puppet environment is 'production'. How do I reconcile this?
5
40
 
6
41
  The default Git branch name is 'master', but this is a somewhat arbitrary name
data/docker/Gemfile CHANGED
@@ -10,5 +10,5 @@ def location_for(place, fake_version = nil)
10
10
  end
11
11
  end
12
12
 
13
- gem 'rspec'
13
+ gem 'puppet_docker_tools', *location_for(ENV['PUPPET_DOCKER_LOCATION'] || '~> 0.2')
14
14
  gem 'rspec_junit_formatter'
data/docker/ci/build.ps1 CHANGED
@@ -19,88 +19,33 @@ function Get-ContainerVersion
19
19
  (git describe) -replace '-.*', ''
20
20
  }
21
21
 
22
- function Lint-Dockerfile($Path)
22
+ # installs gems for build and test and grabs base images
23
+ function Invoke-ContainerBuildSetup
23
24
  {
24
- hadolint --ignore DL3008 --ignore DL3018 --ignore DL4000 --ignore DL4001 $Path
25
+ Push-Location (Get-CurrentDirectory)
26
+ bundle install --path '.bundle/gems'
27
+ bundle exec puppet-docker update-base-images ubuntu:16.04
28
+ Pop-Location
25
29
  }
26
30
 
27
- function Build-Container(
28
- $Namespace = 'puppet',
29
- $Version = (Get-ContainerVersion),
30
- $Vcs_ref = $(git rev-parse HEAD))
31
+ function Build-Container($Name, $Repository = '127.0.0.1', $Version = (Get-ContainerVersion))
31
32
  {
32
33
  Push-Location (Join-Path (Get-CurrentDirectory) '..')
33
-
34
- $build_date = (Get-Date).ToUniversalTime().ToString('o')
35
- $docker_args = @(
36
- '--pull',
37
- '--build-arg', "vcs_ref=$Vcs_ref",
38
- '--build-arg', "build_date=$build_date",
39
- '--build-arg', "version=$Version",
40
- '--file', "r10k/Dockerfile",
41
- '--tag', "$Namespace/r10k:$Version"
42
- )
43
-
44
- docker build $docker_args r10k
45
-
34
+ bundle exec puppet-docker local-lint $Name
35
+ bundle exec puppet-docker build $Name --no-cache --repository $Repository --version $Version --no-latest --build-arg namespace=$Repository
46
36
  Pop-Location
47
37
  }
48
38
 
49
- function Invoke-ContainerTest(
50
- $Namespace = 'puppet',
51
- $Version = (Get-ContainerVersion))
39
+ function Invoke-ContainerTest($Name, $Repository = '127.0.0.1', $Version = (Get-ContainerVersion))
52
40
  {
53
41
  Push-Location (Join-Path (Get-CurrentDirectory) '..')
54
-
55
- bundle install --path .bundle/gems
56
- $ENV:PUPPET_TEST_DOCKER_IMAGE = "$Namespace/r10k:$Version"
57
- bundle exec rspec r10k/spec
58
-
42
+ bundle exec puppet-docker spec $Name --image "$Repository/${Name}:$Version"
59
43
  Pop-Location
60
44
  }
61
45
 
62
- # removes temporary layers / containers / images used during builds
63
- # removes $Namespace/$Name images > 14 days old by default
64
- function Clear-ContainerBuilds(
65
- $Namespace = 'puppet',
66
- $Name,
67
- $OlderThan = [DateTime]::Now.Subtract([TimeSpan]::FromDays(14))
68
- )
46
+ # removes any temporary containers / images used during builds
47
+ function Clear-ContainerBuilds
69
48
  {
70
- Write-Output 'Pruning Containers'
71
49
  docker container prune --force
72
-
73
- # this provides example data which ConvertFrom-String infers parsing structure with
74
- $template = @'
75
- {Version*:1.2.3} {ID:5b84704c1d01} {[DateTime]Created:2019-02-07 18:24:51} +0000 GMT
76
- {Version*:latest} {ID:0123456789ab} {[DateTime]Created:2019-01-29 00:05:33} +0000 GMT
77
- '@
78
- $output = docker images --filter=reference="$Namespace/${Name}" --format "{{.Tag}} {{.ID}} {{.CreatedAt}}"
79
- Write-Output @"
80
-
81
- Found $Namespace/${Name} images:
82
- $($output | Out-String)
83
-
84
- "@
85
-
86
- if ($output -eq $null) { return }
87
-
88
- Write-Output "Filtering removal candidates..."
89
- # docker image prune supports filter until= but not repository like 'puppetlabs/foo'
90
- # must use label= style filtering which is a bit more inconvenient
91
- # that output is also not user-friendly!
92
- # engine doesn't maintain "last used" or "last pulled" metadata, which would be more useful
93
- # https://github.com/moby/moby/issues/4237
94
- $output |
95
- ConvertFrom-String -TemplateContent $template |
96
- ? { $_.Created -lt $OlderThan } |
97
- # ensure 'latest' are listed first
98
- Sort-Object -Property Version -Descending |
99
- % {
100
- Write-Output "Removing Old $Namespace/${Name} Image $($_.Version) ($($_.ID)) Created On $($_.Created)"
101
- docker image rm $_.ID
102
- }
103
-
104
- Write-Output "`nPruning Dangling Images"
105
50
  docker image prune --filter "dangling=true" --force
106
51
  }
data/integration/Gemfile CHANGED
@@ -10,8 +10,8 @@ def location_for(place, fake_version = nil)
10
10
  end
11
11
  end
12
12
 
13
- gem 'beaker', *location_for(ENV['BEAKER_VERSION'] || '~> 4.5')
14
- gem 'beaker-pe', '~> 2.0'
13
+ gem 'beaker', *location_for(ENV['BEAKER_VERSION'] || '~> 3.33')
14
+ gem 'beaker-pe', '~> 1.22'
15
15
  gem 'beaker-answers'
16
16
  gem 'beaker-hostgenerator', *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'] || '~> 1.1')
17
17
  gem 'beaker-abs', *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.4')
data/integration/Rakefile CHANGED
@@ -24,6 +24,7 @@ pre-suite/00_pe_install.rb,
24
24
  component/pre-suite/05_install_dev_r10k.rb,
25
25
  pre-suite/10_git_config.rb,
26
26
  pre-suite/20_pe_r10k.rb,
27
+ pre-suite/30_test_utils.rb,
27
28
  EOS
28
29
  common_setup.gsub!("\n", '')
29
30
 
@@ -1,5 +1,4 @@
1
1
  require 'beaker-pe'
2
-
3
2
  test_name 'CODEMGMT-20 - C48 - Install Puppet Enterprise'
4
3
 
5
4
  step 'Install PE'
@@ -0,0 +1,17 @@
1
+ test_name 'CODEMGMT-62 - C63199 - Install Utilities for r10k Integration Testing'
2
+
3
+ #Init
4
+ filebucket_path = '/opt/filebucket'
5
+ filebucket_script_path = '/etc/profile.d/filebucket_path.sh'
6
+
7
+ filebucket_script = <<-SCRIPT
8
+ #!/bin/bash
9
+ export PATH="${PATH}:#{filebucket_path}"
10
+ SCRIPT
11
+
12
+ step 'Install "filebucket" File Generator'
13
+ create_remote_file(master, filebucket_script_path, filebucket_script)
14
+ on(master, "git clone git://github.com/puppetlabs/filebucket.git #{filebucket_path}")
15
+
16
+ on(master, "chmod 755 #{filebucket_script_path}")
17
+ on(master, "chmod 755 #{filebucket_path}/filebucketapp.py")
@@ -58,8 +58,8 @@ on(master, "mv #{r10k_config_path} #{r10k_config_bak_path}")
58
58
  step 'Update the "r10k" Config'
59
59
  create_remote_file(master, r10k_config_path, r10k_conf)
60
60
 
61
- step 'Download license file from artifactory'
62
- curl_on(master, 'https://artifactory.delivery.puppetlabs.net/artifactory/generic/r10k_test_license.key -o /etc/puppetlabs/license.key')
61
+ step 'Download license file from int-resources'
62
+ curl_on(master, 'http://int-resources.ops.puppetlabs.net/QA_resources/r10k/license.key -o /etc/puppetlabs/license.key')
63
63
 
64
64
  step 'Inject New "site.pp" to the "production" Environment'
65
65
  inject_site_pp(master, site_pp_path, site_pp)
@@ -86,8 +86,8 @@ on(master, "mv #{r10k_config_path} #{r10k_config_bak_path}")
86
86
  step 'Update the "r10k" Config'
87
87
  create_remote_file(master, r10k_config_path, r10k_conf)
88
88
 
89
- step 'Download license file from artifactory'
90
- curl_on(master, 'https://artifactory.delivery.puppetlabs.net/artifactory/generic/r10k_test_license.key -o /etc/puppetlabs/license.key')
89
+ step 'Download license file from int-resources'
90
+ curl_on(master, 'http://int-resources.ops.puppetlabs.net/QA_resources/r10k/license.key -o /etc/puppetlabs/license.key')
91
91
 
92
92
  step 'Checkout "production" Branch'
93
93
  git_on(master, 'checkout production', git_environments_path)
@@ -20,6 +20,17 @@ r10k_config_bak_path = "#{r10k_config_path}.bak"
20
20
 
21
21
  tmpfs_path = '/mnt/tmpfs'
22
22
 
23
+ if on(master, 'which python', :acceptable_exit_codes => [0, 1]).exit_code == 1
24
+ python_bin = 'python3'
25
+ else
26
+ python_bin = 'python'
27
+ end
28
+
29
+ file_bucket_path = '/opt/filebucket'
30
+ file_bucket_command_path = File.join(file_bucket_path, 'filebucketapp.py')
31
+ file_bucket_command = "#{python_bin} #{file_bucket_command_path}"
32
+ pattern_file_path = File.join(file_bucket_path, 'psuedo_random_128k.pat')
33
+
23
34
  test_files_path = File.join(git_environments_path, 'test_files')
24
35
 
25
36
  #In-line files
@@ -62,8 +73,7 @@ on(master, "mount -osize=10m tmpfs #{tmpfs_path} -t tmpfs")
62
73
  step 'Create Large Binary File'
63
74
  create_remote_file(master, File.join(git_environments_path, '.gitattributes'), '*.file binary')
64
75
  on(master, "mkdir -p #{test_files_path}")
65
- # create a 11 mb file to fill the mount
66
- on(master, "dd if=/dev/urandom of=#{test_files_path}.test.file bs=1048576 count=11")
76
+ on(master, "#{file_bucket_command} -s 11 -f #{test_files_path}/test.file -d #{pattern_file_path}")
67
77
 
68
78
  step 'Push Changes'
69
79
  git_add_commit_push(master, 'production', 'Add large file.', git_environments_path)
@@ -21,6 +21,16 @@ helloworld_module_path = File.join(local_files_root_path, 'modules', 'helloworld
21
21
  test_files = 'test_files'
22
22
  test_files_path = File.join(git_environments_path, test_files)
23
23
 
24
+ if on(master, 'which python', :acceptable_exit_codes => [0, 1]).exit_code == 1
25
+ python_bin = 'python3'
26
+ else
27
+ python_bin = 'python'
28
+ end
29
+
30
+ file_bucket_path = '/opt/filebucket'
31
+ file_bucket_command_path = File.join(file_bucket_path, 'filebucketapp.py')
32
+ file_bucket_command = "#{python_bin} #{file_bucket_command_path}"
33
+
24
34
  #Manifest
25
35
  site_pp_path = File.join(git_environments_path, 'manifests', 'site.pp')
26
36
  site_pp = create_site_pp(master_certname, ' include helloworld')
@@ -50,8 +60,7 @@ inject_site_pp(master, site_pp_path, site_pp)
50
60
  step 'Create 10,000 Files'
51
61
  create_remote_file(master, File.join(git_environments_path, '.gitattributes'), '*.file binary')
52
62
  on(master, "mkdir -p #{test_files_path}")
53
- # create 10000 1k files with random text
54
- on(master, "for n in {1..10000}; do dd if=/dev/urandom of=#{test_files_path}/test$( printf %03d \"$n\" ).file bs=1024 count=1; done")
63
+ on(master, "#{file_bucket_command} -k -c 10000 -p #{test_files_path}/test -u .file")
55
64
 
56
65
  step 'Create MD5 Checksum of Files'
57
66
  on(master, "cd #{test_files_path};md5sum *.file > #{checksum_file_name}")
@@ -21,6 +21,17 @@ helloworld_module_path = File.join(local_files_root_path, 'modules', 'helloworld
21
21
  test_files = 'test_files'
22
22
  test_files_path = File.join(git_environments_path, 'test_files')
23
23
 
24
+ if on(master, 'which python', :acceptable_exit_codes => [0, 1]).exit_code == 1
25
+ python_bin = 'python3'
26
+ else
27
+ python_bin = 'python'
28
+ end
29
+
30
+ file_bucket_path = '/opt/filebucket'
31
+ file_bucket_command_path = File.join(file_bucket_path, 'filebucketapp.py')
32
+ pattern_file_path = File.join(file_bucket_path, 'psuedo_random_128k.pat')
33
+ file_bucket_command = "#{python_bin} #{file_bucket_command_path}"
34
+
24
35
  #Manifest
25
36
  site_pp_path = File.join(git_environments_path, 'manifests', 'site.pp')
26
37
  site_pp = create_site_pp(master_certname, ' include helloworld')
@@ -50,8 +61,7 @@ inject_site_pp(master, site_pp_path, site_pp)
50
61
  step 'Create Large Binary Files'
51
62
  create_remote_file(master, File.join(git_environments_path, '.gitattributes'), '*.file binary')
52
63
  on(master, "mkdir -p #{test_files_path}")
53
- # create 10 25 MB files with random characters
54
- on(master, "for n in {1..10}; do dd if=/dev/urandom of=#{test_files_path}/test$( printf %03d \"$n\" ).file bs=1048576 count=25; done")
64
+ on(master, "#{file_bucket_command} -c 10 -s 25 -p #{test_files_path}/test -u .file -d #{pattern_file_path}")
55
65
 
56
66
  step 'Create MD5 Checksum of Files'
57
67
  on(master, "cd #{test_files_path};md5sum *.file > #{checksum_file_name}")
@@ -64,6 +64,11 @@ module R10K
64
64
  end
65
65
  ensure
66
66
  if (postcmd = @settings[:postrun])
67
+ if postcmd.grep('$modifiedenvs').any?
68
+ envs = deployment.environments.map { |e| e.name }
69
+ envs.reject! { |e| !@argv.include?(e) } if @argv.any?
70
+ postcmd = postcmd.map { |e| e.gsub('$modifiedenvs', envs.join(' ')) }
71
+ end
67
72
  subproc = R10K::Util::Subprocess.new(postcmd)
68
73
  subproc.logger = logger
69
74
  subproc.execute
@@ -109,7 +114,7 @@ module R10K
109
114
  end
110
115
 
111
116
  def visit_puppetfile(puppetfile)
112
- puppetfile.load(@opts[:'default-branch-override'])
117
+ puppetfile.load
113
118
 
114
119
  yield
115
120
 
@@ -146,7 +151,7 @@ module R10K
146
151
  end
147
152
 
148
153
  def allowed_initialize_opts
149
- super.merge(puppetfile: :self, cachedir: :self, :'no-force' => :self, :'default-branch-override' => :self)
154
+ super.merge(puppetfile: :self, cachedir: :self, :'no-force' => :self)
150
155
  end
151
156
  end
152
157
  end
@@ -53,7 +53,6 @@ scheduled. On subsequent deployments, Puppetfile deployment will default to off.
53
53
  DESCRIPTION
54
54
 
55
55
  flag :p, :puppetfile, 'Deploy modules from a puppetfile'
56
- required nil, :'default-branch-override', 'Specify a branchname to override the default branch in the puppetfile'
57
56
 
58
57
  runner R10K::Action::CriRunner.wrap(R10K::Action::Deploy::Environment)
59
58
  end
@@ -23,11 +23,6 @@ class R10K::Module::Git < R10K::Module::Base
23
23
  # @return [String]
24
24
  attr_reader :desired_ref
25
25
 
26
- # @!attribute [r] default_ref
27
- # @api private
28
- # @return [String]
29
- attr_reader :default_ref
30
-
31
26
  def initialize(title, dirname, args, environment=nil)
32
27
  super
33
28
 
@@ -58,20 +58,17 @@ class Puppetfile
58
58
  @loaded = false
59
59
  end
60
60
 
61
- def load(default_branch_override = nil)
61
+ def load
62
62
  if File.readable? @puppetfile_path
63
- self.load!(default_branch_override)
63
+ self.load!
64
64
  else
65
65
  logger.debug _("Puppetfile %{path} missing or unreadable") % {path: @puppetfile_path.inspect}
66
66
  end
67
67
  end
68
68
 
69
- def load!(default_branch_override = nil)
70
- @default_branch_override = default_branch_override
71
-
69
+ def load!
72
70
  dsl = R10K::Puppetfile::DSL.new(self)
73
71
  dsl.instance_eval(puppetfile_contents, @puppetfile_path)
74
-
75
72
  validate_no_duplicate_names(@modules)
76
73
  @loaded = true
77
74
  rescue SyntaxError, LoadError, ArgumentError, NameError => e
@@ -116,10 +113,6 @@ class Puppetfile
116
113
  install_path = @moduledir
117
114
  end
118
115
 
119
- if args.is_a?(Hash) && @default_branch_override != nil
120
- args[:default_branch] = @default_branch_override
121
- end
122
-
123
116
  # Keep track of all the content this Puppetfile is managing to enable purging.
124
117
  @managed_content[install_path] = Array.new unless @managed_content.has_key?(install_path)
125
118
 
data/lib/r10k/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module R10K
2
- VERSION = '3.0.4'
2
+ VERSION = '3.1.0'
3
3
  end
@@ -19,10 +19,6 @@ describe R10K::Action::Deploy::Environment do
19
19
  described_class.new({puppetfile: true}, [])
20
20
  end
21
21
 
22
- it "can accept a default_branch_override option" do
23
- described_class.new({:'default-branch-override' => 'default_branch_override_name'}, [])
24
- end
25
-
26
22
  it "can accept a no-force option" do
27
23
  described_class.new({:'no-force' => true}, [])
28
24
  end
@@ -69,6 +65,90 @@ describe R10K::Action::Deploy::Environment do
69
65
  end
70
66
  end
71
67
 
68
+ describe "postrun" do
69
+ context "basic postrun hook" do
70
+ let(:settings) { { postrun: ["/path/to/executable", "arg1", "arg2"] } }
71
+ let(:deployment) { R10K::Deployment.new(mock_config.merge(settings)) }
72
+
73
+ before do
74
+ expect(R10K::Deployment).to receive(:new).and_return(deployment)
75
+ end
76
+
77
+ subject do
78
+ described_class.new( {config: "/some/nonexistent/path" },
79
+ %w[first],
80
+ settings )
81
+ end
82
+
83
+ it "is passed to Subprocess" do
84
+ mock_subprocess = double
85
+ allow(mock_subprocess).to receive(:logger=)
86
+ expect(mock_subprocess).to receive(:execute)
87
+
88
+ expect(R10K::Util::Subprocess).to receive(:new).
89
+ with(["/path/to/executable", "arg1", "arg2"]).
90
+ and_return(mock_subprocess)
91
+
92
+ subject.call
93
+ end
94
+ end
95
+
96
+ context "supports environments" do
97
+ context "when one environment" do
98
+ let(:settings) { { postrun: ["/generate/types/wrapper", "$modifiedenvs"] } }
99
+ let(:deployment) { R10K::Deployment.new(mock_config.merge(settings)) }
100
+
101
+ before do
102
+ expect(R10K::Deployment).to receive(:new).and_return(deployment)
103
+ end
104
+
105
+ subject do
106
+ described_class.new( {config: "/some/nonexistent/path" },
107
+ %w[first],
108
+ settings )
109
+ end
110
+
111
+ it "properly substitutes the environment" do
112
+ mock_subprocess = double
113
+ allow(mock_subprocess).to receive(:logger=)
114
+ expect(mock_subprocess).to receive(:execute)
115
+
116
+ expect(R10K::Util::Subprocess).to receive(:new).
117
+ with(["/generate/types/wrapper", "first"]).
118
+ and_return(mock_subprocess)
119
+
120
+ subject.call
121
+ end
122
+ end
123
+ context "when many environments" do
124
+ let(:settings) { { postrun: ["/generate/types/wrapper", "$modifiedenvs"] } }
125
+ let(:deployment) { R10K::Deployment.new(mock_config.merge(settings)) }
126
+
127
+ before do
128
+ expect(R10K::Deployment).to receive(:new).and_return(deployment)
129
+ end
130
+
131
+ subject do
132
+ described_class.new( {config: "/some/nonexistent/path" },
133
+ [],
134
+ settings )
135
+ end
136
+
137
+ it "properly substitutes the environment" do
138
+ mock_subprocess = double
139
+ allow(mock_subprocess).to receive(:logger=)
140
+ expect(mock_subprocess).to receive(:execute)
141
+
142
+ expect(R10K::Util::Subprocess).to receive(:new).
143
+ with(["/generate/types/wrapper", "first second third"]).
144
+ and_return(mock_subprocess)
145
+
146
+ subject.call
147
+ end
148
+ end
149
+ end
150
+ end
151
+
72
152
  describe "purge_levels" do
73
153
  let(:settings) { { deploy: { purge_levels: purge_levels } } }
74
154
 
@@ -227,25 +227,6 @@ describe R10K::Puppetfile do
227
227
  subject = described_class.new(path)
228
228
  expect { subject.load! }.not_to raise_error
229
229
  end
230
-
231
- it "creates a git module and applies the default branch sepcified in the Puppetfile" do
232
- path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'default-branch-override')
233
- pf_path = File.join(path, 'Puppetfile')
234
- subject = described_class.new(path)
235
- expect { subject.load! }.not_to raise_error
236
- git_module = subject.modules[0]
237
- expect(git_module.default_ref).to eq 'here_lies_the_default_branch'
238
- end
239
-
240
- it "creates a git module and applies the provided default_branch_override" do
241
- path = File.join(PROJECT_ROOT, 'spec', 'fixtures', 'unit', 'puppetfile', 'default-branch-override')
242
- pf_path = File.join(path, 'Puppetfile')
243
- subject = described_class.new(path)
244
- default_branch_override = 'default_branch_override_name'
245
- expect { subject.load!(default_branch_override) }.not_to raise_error
246
- git_module = subject.modules[0]
247
- expect(git_module.default_ref).to eq default_branch_override
248
- end
249
230
  end
250
231
 
251
232
  describe "accepting a visitor" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r10k
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Thebo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-16 00:00:00.000000000 Z
11
+ date: 2018-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored
@@ -187,7 +187,6 @@ files:
187
187
  - doc/git/providers.mkd
188
188
  - doc/puppetfile.mkd
189
189
  - doc/updating-your-puppetfile.mkd
190
- - docker/.gitignore
191
190
  - docker/.rspec
192
191
  - docker/Gemfile
193
192
  - docker/Makefile
@@ -217,6 +216,7 @@ files:
217
216
  - integration/pre-suite/00_pe_install.rb
218
217
  - integration/pre-suite/10_git_config.rb
219
218
  - integration/pre-suite/20_pe_r10k.rb
219
+ - integration/pre-suite/30_test_utils.rb
220
220
  - integration/pre-suite/README.mkd
221
221
  - integration/scripts/README.mkd
222
222
  - integration/scripts/setup_r10k_env_centos5.sh
@@ -403,7 +403,6 @@ files:
403
403
  - spec/fixtures/module/forge/eight_hundred/Modulefile
404
404
  - spec/fixtures/module/forge/eight_hundred/metadata.json
405
405
  - spec/fixtures/unit/puppetfile/argument-error/Puppetfile
406
- - spec/fixtures/unit/puppetfile/default-branch-override/Puppetfile
407
406
  - spec/fixtures/unit/puppetfile/duplicate-module-error/Puppetfile
408
407
  - spec/fixtures/unit/puppetfile/invalid-syntax/Puppetfile
409
408
  - spec/fixtures/unit/puppetfile/load-error/Puppetfile
data/docker/.gitignore DELETED
@@ -1 +0,0 @@
1
- TEST-rspec.xml
@@ -1,5 +0,0 @@
1
- mod 'cd4pe',
2
- :git => 'test@randomurl.com:something/some_module.git',
3
- :ref => 'expected_ref',
4
- :default_branch => 'here_lies_the_default_branch'
5
-