r10k 3.1.0 → 3.1.1

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: a60c1ccc9338827361ca4116b58d3619f6ff755b
4
- data.tar.gz: 7e473d21e8fa5a96e64787191d721790d7403bbf
3
+ metadata.gz: 84930e8294eba7ee0bb6891b043c7b5c50adc06b
4
+ data.tar.gz: 941551e36b98e187c52afbbc1c20e98c4b869ae8
5
5
  SHA512:
6
- metadata.gz: a48693802bbc801288990cebc451d088b70807dbb1b4e9eb3e9e83594ad096a0233c5f903f2cf454bb0873fa08e3aba51cdb54609b47bbfb1e981444ac14e6d4
7
- data.tar.gz: 875ce9e183d4f5191b36d0ef45a271b308d891b88a27f994c10c6bd57a66486448b68c96704e1769a87717754505d8d6fdefa43bd52de007449e5e4152766806
6
+ metadata.gz: 9eef55519460f134d9e2a376e64cab9e04a63836c9a4aa7a46f3d220576b29beed54215fc9710057f6d932a9892b9abeb7e91cfe9f2caa29a2846fed951de662
7
+ data.tar.gz: 53f5d878d87b1db35402539a0ca21d97ab22f230f84b583885dd67fa4c162a0c6ec1b05c71e535f116015583e49b76c87fd6642e8e7311d16c7a7addd08e1343
data/.gitattributes CHANGED
@@ -1 +1,2 @@
1
- docker/r10k/* text eol=lf
1
+ docker/r10k/* text eol=lf
2
+ docker/r10k/docker-entrypoint.d/* text eol=lf
data/.travis.yml CHANGED
@@ -1,15 +1,26 @@
1
1
  ---
2
2
  language: ruby
3
+ services:
4
+ - docker
3
5
  bundler_args: "--without system"
4
6
  script: "bundle exec rspec --color --format documentation spec/unit"
5
7
  notifications:
6
8
  email: false
7
9
  sudo: false
8
- before_install: gem update bundler
9
- rvm:
10
- - "2.5"
11
- - "2.4"
12
- - "2.3"
13
- - "jruby"
14
10
  jdk:
15
11
  - 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,6 +1,13 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
+ 3.1.1
5
+ -----
6
+
7
+ ## Bug Fixes
8
+
9
+ (RK-335) Postrun `modifiedenvs` doesn't include environment prefixes
10
+
4
11
  3.1.0
5
12
  -----
6
13
 
data/azure-pipelines.yml CHANGED
@@ -5,9 +5,11 @@ pool:
5
5
  name: Default
6
6
 
7
7
  variables:
8
- BUILD_REPOSITORY: 127.0.0.1
8
+ NAMESPACE: puppet
9
9
 
10
10
  steps:
11
+ - checkout: self
12
+ clean: true
11
13
  - powershell: |
12
14
  $line = '=' * 80
13
15
  Write-Host "$line`nWindows`n$line`n"
@@ -46,27 +48,27 @@ steps:
46
48
  name: hostinfo
47
49
  - powershell: |
48
50
  . ./docker/ci/build.ps1
49
- Invoke-ContainerBuildSetup
50
- displayName: Prepare Build Environment
51
- name: build_prepare
51
+ Lint-Dockerfile -Path ./docker/r10k/Dockerfile
52
+ displayName: Lint r10k Dockerfile
53
+ name: lint_dockerfile
52
54
  - powershell: |
53
55
  . ./docker/ci/build.ps1
54
- Build-Container -Name r10k -Repository $ENV:BUILD_REPOSITORY
55
- displayName: Build r10k
56
- name: build_r10k
56
+ Build-Container -Namespace $ENV:NAMESPACE
57
+ displayName: Build r10k Container
58
+ name: build_r10k_container
57
59
  - powershell: |
58
60
  . ./docker/ci/build.ps1
59
- Invoke-ContainerTest -Name r10k -Repository $ENV:BUILD_REPOSITORY
61
+ Invoke-ContainerTest -Namespace $ENV:NAMESPACE
60
62
  displayName: Test r10k
61
63
  name: test_r10k
62
64
  - task: PublishTestResults@2
63
65
  displayName: Publish r10k test results
64
66
  inputs:
65
67
  testResultsFormat: 'JUnit'
66
- testResultsFiles: 'docker/**/TEST-*.xml'
68
+ testResultsFiles: 'docker/TEST-*.xml'
67
69
  testRunTitle: r10k Test Results
68
70
  - powershell: |
69
71
  . ./docker/ci/build.ps1
70
- Clear-ContainerBuilds
72
+ Clear-ContainerBuilds -Name r10k
71
73
  displayName: Container Cleanup
72
74
  condition: always()
data/docker/.gitignore ADDED
@@ -0,0 +1 @@
1
+ TEST-rspec.xml
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 'puppet_docker_tools', *location_for(ENV['PUPPET_DOCKER_LOCATION'] || '~> 0.2')
13
+ gem 'rspec'
14
14
  gem 'rspec_junit_formatter'
data/docker/Makefile CHANGED
@@ -1,3 +1,4 @@
1
+ PUPPERWARE_ANALYTICS_STREAM ?= dev
1
2
  git_describe = $(shell git describe)
2
3
  vcs_ref := $(shell git rev-parse HEAD)
3
4
  build_date := $(shell date -u +%FT%T)
@@ -29,7 +30,15 @@ else
29
30
  endif
30
31
 
31
32
  build: prep
32
- @docker build --pull --build-arg vcs_ref=$(vcs_ref) --build-arg build_date=$(build_date) --build-arg version=$(version) --file r10k/$(dockerfile) --tag puppet/r10k:$(version) r10k
33
+ @docker build \
34
+ --pull \
35
+ --build-arg vcs_ref=$(vcs_ref) \
36
+ --build-arg build_date=$(build_date) \
37
+ --build-arg version=$(version) \
38
+ --build-arg pupperware_analytics_stream=$(PUPPERWARE_ANALYTICS_STREAM) \
39
+ --file r10k/$(dockerfile) \
40
+ --tag puppet/r10k:$(version) \
41
+ r10k
33
42
  ifeq ($(IS_LATEST),true)
34
43
  @docker tag puppet/r10k:$(version) puppet/r10k:latest
35
44
  endif
data/docker/ci/build.ps1 CHANGED
@@ -19,33 +19,88 @@ function Get-ContainerVersion
19
19
  (git describe) -replace '-.*', ''
20
20
  }
21
21
 
22
- # installs gems for build and test and grabs base images
23
- function Invoke-ContainerBuildSetup
22
+ function Lint-Dockerfile($Path)
24
23
  {
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
24
+ hadolint --ignore DL3008 --ignore DL3018 --ignore DL4000 --ignore DL4001 $Path
29
25
  }
30
26
 
31
- function Build-Container($Name, $Repository = '127.0.0.1', $Version = (Get-ContainerVersion))
27
+ function Build-Container(
28
+ $Namespace = 'puppet',
29
+ $Version = (Get-ContainerVersion),
30
+ $Vcs_ref = $(git rev-parse HEAD))
32
31
  {
33
32
  Push-Location (Join-Path (Get-CurrentDirectory) '..')
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
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
+
36
46
  Pop-Location
37
47
  }
38
48
 
39
- function Invoke-ContainerTest($Name, $Repository = '127.0.0.1', $Version = (Get-ContainerVersion))
49
+ function Invoke-ContainerTest(
50
+ $Namespace = 'puppet',
51
+ $Version = (Get-ContainerVersion))
40
52
  {
41
53
  Push-Location (Join-Path (Get-CurrentDirectory) '..')
42
- bundle exec puppet-docker spec $Name --image "$Repository/${Name}:$Version"
54
+
55
+ bundle install --path .bundle/gems
56
+ $ENV:PUPPET_TEST_DOCKER_IMAGE = "$Namespace/r10k:$Version"
57
+ bundle exec rspec r10k/spec
58
+
43
59
  Pop-Location
44
60
  }
45
61
 
46
- # removes any temporary containers / images used during builds
47
- function Clear-ContainerBuilds
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
+ )
48
69
  {
70
+ Write-Output 'Pruning Containers'
49
71
  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"
50
105
  docker image prune --filter "dangling=true" --force
51
106
  }
@@ -2,7 +2,7 @@ pe-and-platform/r10k:
2
2
  PreBuild:
3
3
  - make lint
4
4
  Build:
5
- - make build
5
+ - make build PUPPERWARE_ANALYTICS_STREAM=production
6
6
  - make test
7
7
  AfterBuildSuccess:
8
8
  - docker login -u "$DISTELLI_DOCKER_USERNAME" -p "$DISTELLI_DOCKER_PW" "$DISTELLI_DOCKER_ENDPOINT"
@@ -2,7 +2,12 @@ FROM ubuntu:16.04
2
2
 
3
3
  ARG vcs_ref
4
4
  ARG build_date
5
- ARG version="2.6.4"
5
+ ARG version="3.1.0"
6
+ # Used by entrypoint to submit metrics to Google Analytics.
7
+ # Published images should use "production" for this build_arg.
8
+ ARG pupperware_analytics_stream="dev"
9
+ ENV PUPPERWARE_ANALYTICS_STREAM="$pupperware_analytics_stream"
10
+
6
11
  ENV R10K_VERSION="$version"
7
12
  ENV UBUNTU_CODENAME="xenial"
8
13
 
@@ -33,9 +38,13 @@ RUN apt-get update && \
33
38
 
34
39
  RUN /opt/puppetlabs/puppet/bin/gem install r10k:"$R10K_VERSION"
35
40
 
41
+ COPY docker-entrypoint.sh /
42
+ RUN chmod +x /docker-entrypoint.sh
43
+ COPY docker-entrypoint.d /docker-entrypoint.d
44
+
36
45
  ENV PATH=/opt/puppetlabs/server/bin:/opt/puppetlabs/puppet/bin:/opt/puppetlabs/bin:$PATH
37
46
 
38
- ENTRYPOINT ["/opt/puppetlabs/puppet/bin/r10k"]
47
+ ENTRYPOINT ["/docker-entrypoint.sh"]
39
48
  CMD ["help"]
40
49
 
41
50
  COPY Dockerfile /
@@ -0,0 +1,28 @@
1
+ #!/bin/sh
2
+
3
+ if [ "${PUPPERWARE_DISABLE_ANALYTICS}" = "true" ]; then
4
+ echo "($0) Pupperware analytics disabled; skipping metric submission"
5
+ exit 0
6
+ fi
7
+
8
+ # See: https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
9
+ # Tracking ID
10
+ tid=UA-132486246-5
11
+ # Application Name
12
+ an=r10k
13
+ # Application Version
14
+ av=$R10K_VERSION
15
+ # Anonymous Client ID
16
+ _file=/var/tmp/pwclientid
17
+ cid=$(cat $_file 2>/dev/null || (cat /proc/sys/kernel/random/uuid | tee $_file))
18
+ # Event Category
19
+ ec=${PUPPERWARE_ANALYTICS_STREAM:-dev}
20
+ # Event Action
21
+ ea=start
22
+
23
+ _params="v=1&t=event&tid=${tid}&an=${an}&av=${av}&cid=${cid}&ec=${ec}&ea=${ea}"
24
+ _url="http://www.google-analytics.com/collect?${_params}"
25
+
26
+ echo "($0) Sending metrics ${_url}"
27
+ curl --fail --silent --show-error --output /dev/null \
28
+ -X POST -H "Content-Length: 0" $_url
@@ -0,0 +1,11 @@
1
+ #! /bin/sh
2
+
3
+ set -e
4
+
5
+ for f in /docker-entrypoint.d/*.sh; do
6
+ echo "Running $f"
7
+ chmod +x "$f"
8
+ "$f"
9
+ done
10
+
11
+ exec /opt/puppetlabs/puppet/bin/r10k "$@"
@@ -15,7 +15,13 @@ describe 'r10k container' do
15
15
  MSG
16
16
  fail error_message
17
17
  end
18
- @container = %x(docker run --rm --detach --entrypoint /bin/bash --interactive --volume #{File.join(SPEC_DIRECTORY, 'fixtures')}:/test #{@image}).chomp
18
+ @container = %x(docker run --rm --detach \
19
+ --env PUPPERWARE_DISABLE_ANALYTICS=true \
20
+ --entrypoint /bin/bash \
21
+ --interactive \
22
+ --volume #{File.join(SPEC_DIRECTORY, 'fixtures')}:/test \
23
+ #{@image}).chomp
24
+
19
25
  %x(docker exec #{@container} cp test/Puppetfile /)
20
26
  end
21
27
 
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'] || '~> 3.33')
14
- gem 'beaker-pe', '~> 1.22'
13
+ gem 'beaker', *location_for(ENV['BEAKER_VERSION'] || '~> 4.5')
14
+ gem 'beaker-pe', '~> 2.0'
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')
@@ -1,4 +1,5 @@
1
1
  require 'beaker-pe'
2
+
2
3
  test_name 'CODEMGMT-20 - C48 - Install Puppet Enterprise'
3
4
 
4
5
  step 'Install PE'
@@ -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 int-resources'
62
- curl_on(master, 'http://int-resources.ops.puppetlabs.net/QA_resources/r10k/license.key -o /etc/puppetlabs/license.key')
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')
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 int-resources'
90
- curl_on(master, 'http://int-resources.ops.puppetlabs.net/QA_resources/r10k/license.key -o /etc/puppetlabs/license.key')
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')
91
91
 
92
92
  step 'Checkout "production" Branch'
93
93
  git_on(master, 'checkout production', git_environments_path)
@@ -65,7 +65,7 @@ module R10K
65
65
  ensure
66
66
  if (postcmd = @settings[:postrun])
67
67
  if postcmd.grep('$modifiedenvs').any?
68
- envs = deployment.environments.map { |e| e.name }
68
+ envs = deployment.environments.map { |e| e.dirname }
69
69
  envs.reject! { |e| !@argv.include?(e) } if @argv.any?
70
70
  postcmd = postcmd.map { |e| e.gsub('$modifiedenvs', envs.join(' ')) }
71
71
  end
data/lib/r10k/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module R10K
2
- VERSION = '3.1.0'
2
+ VERSION = '3.1.1'
3
3
  end
@@ -5,6 +5,9 @@ class R10K::Source::Mock < R10K::Source::Base
5
5
  R10K::Source.register(:mock, self)
6
6
 
7
7
  def environments
8
- @options[:environments].map { |n| R10K::Environment::Mock.new(n, @basedir, n) }
8
+ corrected_environment_names = @options[:environments].map do |env|
9
+ R10K::Environment::Name.new(env, :prefix => @prefix, :invalid => 'correct_and_warn')
10
+ end
11
+ corrected_environment_names.map { |env| R10K::Environment::Mock.new(env.name, @basedir, env.dirname) }
9
12
  end
10
13
  end
@@ -33,7 +33,8 @@ describe R10K::Action::Deploy::Environment do
33
33
  :control => {
34
34
  :type => :mock,
35
35
  :basedir => '/some/nonexistent/path/control',
36
- :environments => %w[first second third],
36
+ :environments => %w[first second third env-that/will-be-corrected],
37
+ :prefix => 'PREFIX'
37
38
  }
38
39
  }
39
40
  )
@@ -76,7 +77,7 @@ describe R10K::Action::Deploy::Environment do
76
77
 
77
78
  subject do
78
79
  described_class.new( {config: "/some/nonexistent/path" },
79
- %w[first],
80
+ %w[PREFIX_first],
80
81
  settings )
81
82
  end
82
83
 
@@ -104,7 +105,7 @@ describe R10K::Action::Deploy::Environment do
104
105
 
105
106
  subject do
106
107
  described_class.new( {config: "/some/nonexistent/path" },
107
- %w[first],
108
+ %w[PREFIX_first],
108
109
  settings )
109
110
  end
110
111
 
@@ -114,7 +115,7 @@ describe R10K::Action::Deploy::Environment do
114
115
  expect(mock_subprocess).to receive(:execute)
115
116
 
116
117
  expect(R10K::Util::Subprocess).to receive(:new).
117
- with(["/generate/types/wrapper", "first"]).
118
+ with(["/generate/types/wrapper", "PREFIX_first"]).
118
119
  and_return(mock_subprocess)
119
120
 
120
121
  subject.call
@@ -140,7 +141,7 @@ describe R10K::Action::Deploy::Environment do
140
141
  expect(mock_subprocess).to receive(:execute)
141
142
 
142
143
  expect(R10K::Util::Subprocess).to receive(:new).
143
- with(["/generate/types/wrapper", "first second third"]).
144
+ with(["/generate/types/wrapper", "PREFIX_first PREFIX_second PREFIX_third PREFIX_env_that_will_be_corrected"]).
144
145
  and_return(mock_subprocess)
145
146
 
146
147
  subject.call
@@ -160,7 +161,7 @@ describe R10K::Action::Deploy::Environment do
160
161
  expect(R10K::Deployment).to receive(:new).and_return(deployment)
161
162
  end
162
163
 
163
- subject { described_class.new({ config: "/some/nonexistent/path", puppetfile: true }, %w[first], settings) }
164
+ subject { described_class.new({ config: "/some/nonexistent/path", puppetfile: true }, %w[PREFIX_first], settings) }
164
165
 
165
166
  describe "deployment purge level" do
166
167
  let(:purge_levels) { [:deployment] }
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.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Thebo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-07 00:00:00.000000000 Z
11
+ date: 2019-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored
@@ -187,12 +187,15 @@ files:
187
187
  - doc/git/providers.mkd
188
188
  - doc/puppetfile.mkd
189
189
  - doc/updating-your-puppetfile.mkd
190
+ - docker/.gitignore
190
191
  - docker/.rspec
191
192
  - docker/Gemfile
192
193
  - docker/Makefile
193
194
  - docker/ci/build.ps1
194
195
  - docker/distelli-manifest.yml
195
196
  - docker/r10k/Dockerfile
197
+ - docker/r10k/docker-entrypoint.d/10-analytics.sh
198
+ - docker/r10k/docker-entrypoint.sh
196
199
  - docker/r10k/spec/dockerfile_spec.rb
197
200
  - docker/r10k/spec/fixtures/Puppetfile
198
201
  - integration/Gemfile