r10k 3.14.0 → 3.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/docker.yml +5 -0
  3. data/.github/workflows/rspec_tests.yml +4 -3
  4. data/.github/workflows/stale.yml +2 -0
  5. data/.gitignore +1 -0
  6. data/CHANGELOG.mkd +22 -0
  7. data/README.mkd +2 -2
  8. data/doc/dynamic-environments/configuration.mkd +44 -16
  9. data/doc/dynamic-environments/usage.mkd +4 -0
  10. data/doc/dynamic-environments/workflow-guide.mkd +3 -3
  11. data/doc/faq.mkd +1 -1
  12. data/doc/git/providers.mkd +22 -0
  13. data/docker/Makefile +18 -11
  14. data/docker/r10k/Dockerfile +1 -1
  15. data/docker/r10k/release.Dockerfile +1 -1
  16. data/integration/tests/git_source/HTTP_proxy_and_git_source.rb +1 -1
  17. data/integration/tests/git_source/git_source_repeated_remote.rb +2 -2
  18. data/integration/tests/purging/content_not_purged_at_root.rb +2 -2
  19. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module.rb +1 -1
  20. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb +1 -1
  21. data/integration/tests/user_scenario/basic_workflow/multi_source_custom_forge_git_module.rb +1 -1
  22. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module.rb +1 -1
  23. data/integration/tests/user_scenario/basic_workflow/negative/neg_bad_git_module_ref.rb +1 -1
  24. data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_git_module.rb +1 -1
  25. data/integration/tests/user_scenario/basic_workflow/single_env_switch_forge_git_module.rb +1 -1
  26. data/lib/r10k/environment/with_modules.rb +25 -2
  27. data/lib/r10k/git/rugged/bare_repository.rb +1 -1
  28. data/lib/r10k/git/rugged/credentials.rb +1 -1
  29. data/lib/r10k/git/rugged/thin_repository.rb +7 -0
  30. data/lib/r10k/git/rugged/working_repository.rb +8 -4
  31. data/lib/r10k/git/shellgit/thin_repository.rb +4 -0
  32. data/lib/r10k/git/shellgit/working_repository.rb +3 -2
  33. data/lib/r10k/git/stateful_repository.rb +4 -4
  34. data/lib/r10k/module/base.rb +6 -2
  35. data/lib/r10k/module/forge.rb +10 -10
  36. data/lib/r10k/module/git.rb +2 -4
  37. data/lib/r10k/module/local.rb +1 -1
  38. data/lib/r10k/module_loader/puppetfile/dsl.rb +1 -1
  39. data/lib/r10k/module_loader/puppetfile.rb +11 -6
  40. data/lib/r10k/settings/container.rb +1 -0
  41. data/lib/r10k/version.rb +1 -1
  42. data/locales/r10k.pot +23 -15
  43. data/r10k.gemspec +5 -7
  44. data/spec/fixtures/unit/puppetfile/various-modules/modules/apt/.gitkeep +1 -0
  45. data/spec/fixtures/unit/puppetfile/various-modules/modules/baz/.gitkeep +1 -0
  46. data/spec/fixtures/unit/puppetfile/various-modules/modules/buzz/.gitkeep +1 -0
  47. data/spec/fixtures/unit/puppetfile/various-modules/modules/canary/.gitkeep +1 -0
  48. data/spec/fixtures/unit/puppetfile/various-modules/modules/fizz/.gitkeep +1 -0
  49. data/spec/fixtures/unit/puppetfile/various-modules/modules/rpm/.gitkeep +1 -0
  50. data/spec/integration/git/stateful_repository_spec.rb +16 -0
  51. data/spec/unit/action/deploy/module_spec.rb +7 -7
  52. data/spec/unit/environment/git_spec.rb +2 -2
  53. data/spec/unit/environment/with_modules_spec.rb +47 -0
  54. data/spec/unit/git/alternates_spec.rb +28 -28
  55. data/spec/unit/git/cache_spec.rb +1 -1
  56. data/spec/unit/git/rugged/cache_spec.rb +2 -2
  57. data/spec/unit/git/shellgit/cache_spec.rb +1 -1
  58. data/spec/unit/git/stateful_repository_spec.rb +1 -1
  59. data/spec/unit/module/forge_spec.rb +9 -7
  60. data/spec/unit/module/git_spec.rb +5 -5
  61. data/spec/unit/module_loader/puppetfile_spec.rb +18 -5
  62. data/spec/unit/module_spec.rb +14 -7
  63. data/spec/unit/util/cacheable_spec.rb +2 -2
  64. metadata +24 -13
  65. data/.travis.yml +0 -42
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da22a28bcd5de19a996ff2c869ba074c402e393d7a3caa2528bb342c75192234
4
- data.tar.gz: 9bf7067d8412b9d158f2d47ad96499f90183c5dcade26b97fede2a344b06dca0
3
+ metadata.gz: c2085c3475000f081d4ff3ff19fd5f009080c9238c5e532449a24f306b2aa107
4
+ data.tar.gz: fb38a94d17d20cdd75aba6c5817cad33c77ed408307f32aa54bc4f65dabba022
5
5
  SHA512:
6
- metadata.gz: a2a529ce1b781f858253f1d929e4cf521806a8f11ce9733a4f2dc92dcfd4792d4afcbad9290a814d10a14be645eb0ada9551c542def43f6acc48d28931783bc2
7
- data.tar.gz: 31d2a9e5d85f29da1c6f62d77d7bbd83c7ed8c4687bb5035f7185c8b37042e2707e59b623d6603af5d533ee79c44380d4a3a4a1a2a28ddd06af9c723c6f1c1bb
6
+ metadata.gz: 6de1e925f24ec5edf168c5a4d177030be2d351493ab65274998bbd02b67fa84910d3a28d800bdd03d255e4fb0cceeac1b8d09a615cb181986ee22bd4e155e0fb
7
+ data.tar.gz: f4294cd171f9665c70d9573ad082003e5cd272aa42b2f949c41bc6874399c92010e1065140544770807444e8cf60b52d0733add89cfbd0b4839381c918932004
@@ -27,6 +27,11 @@ jobs:
27
27
  with:
28
28
  ruby-version: 2.6.x
29
29
  - run: gem install bundler
30
+ - uses: actions/checkout@v2
31
+ - name: Set up QEMU
32
+ uses: docker/setup-qemu-action@v1
33
+ - name: Set up Docker Buildx
34
+ uses: docker/setup-buildx-action@v1
30
35
  - name: Build container
31
36
  working-directory: docker
32
37
  run: |
@@ -15,10 +15,11 @@ jobs:
15
15
  - {os: ubuntu-18.04, ruby: 2.5}
16
16
  - {os: ubuntu-18.04, ruby: 2.6}
17
17
  - {os: ubuntu-18.04, ruby: 2.7}
18
+ - {os: ubuntu-18.04, ruby: 3.1}
18
19
  - {os: ubuntu-18.04, ruby: jruby-9.2.10.0}
19
- - {os: windows-2016, ruby: 2.5}
20
- - {os: windows-2016, ruby: 2.6}
21
- - {os: windows-2016, ruby: 2.7}
20
+ - {os: windows-2019, ruby: 2.5}
21
+ - {os: windows-2019, ruby: 2.6}
22
+ - {os: windows-2019, ruby: 2.7}
22
23
 
23
24
  runs-on: ${{ matrix.cfg.os }}
24
25
  steps:
@@ -15,5 +15,7 @@ jobs:
15
15
  days-before-close: 7
16
16
  stale-issue-message: 'This issue has been marked stale because it has had no activity for 60 days. The Puppet Team is actively prioritizing existing bugs and new features, if this issue is still important to you please comment and we will add this to our backlog to complete. Otherwise, it will be closed in 7 days.'
17
17
  stale-issue-label: 'stale'
18
+ exempt-issue-labels: 'community interest'
18
19
  stale-pr-message: "This PR has been marked stale because it has had no activity for 60 days. If you are still interested in getting this merged, please comment and we'll try to move it forward. Otherwise, it will be closed in 7 days."
19
20
  stale-pr-label: 'stale'
21
+ exempt-pr-labels: 'community interest'
data/.gitignore CHANGED
@@ -7,3 +7,4 @@ coverage
7
7
  integration/log
8
8
  integration/junit
9
9
  integration/configs
10
+ r10k.log
data/CHANGELOG.mkd CHANGED
@@ -4,6 +4,28 @@ CHANGELOG
4
4
  Unreleased
5
5
  ----------
6
6
 
7
+ 3.15.0
8
+ ------
9
+
10
+ - Support and test Ruby 3
11
+ - Allow puppet_forge 3.x & newer versions of fast_gettext/gettext [#1302](https://github.com/puppetlabs/r10k/pull/1302)
12
+ - Allow newer cri versions [#1302](https://github.com/puppetlabs/r10k/pull/1302)
13
+ - Fix error when using install_path from environment module [#1288](https://github.com/puppetlabs/r10k/issues/1288)
14
+ - (RK-399) Do not warn about local modifications in the spec directory when `exclude_spec` is set [#1291](https://github.com/puppetlabs/r10k/pull/1291)
15
+
16
+ 3.14.2
17
+ ------
18
+
19
+ - (RK-397) Ensure `--incremental` does not skip undeployed modules [#1278](https://github.com/puppetlabs/r10k/pull/1278)
20
+
21
+ 3.14.1
22
+ ------
23
+
24
+ - (RK-395) Make `exclude_spec` from a Puppetfile the priority override [#1271](https://github.com/puppetlabs/r10k/issues/1271)
25
+ - (RK-394) Fix `force` always resolving to true for `puppetfile install` [#1269](https://github.com/puppetlabs/r10k/issues/1265)
26
+ - (RK-393) Bug fix: not all spec directories are deleted when :exclude_spec is true [#1267](https://github.com/puppetlabs/r10k/pull/1267)
27
+ - Refactor internal module creation to always expect a hash, even for Forge modules, which can be specified in the Puppetfile with just a version string. [#1170](https://github.com/puppetlabs/r10k/pull/1170)
28
+
7
29
  3.14.0
8
30
  ------
9
31
 
data/README.mkd CHANGED
@@ -18,7 +18,7 @@ Requirements
18
18
  ------------
19
19
 
20
20
  R10k supports the Ruby versions `>= 2.4.0`. It's tested on Ruby 2.4.0 up to
21
- Ruby 2.7.0 + Jruby.
21
+ Ruby 3.1.0 + Jruby.
22
22
 
23
23
  R10k requires additional components, depending on how you plan on managing
24
24
  environments and modules.
@@ -61,7 +61,7 @@ for installation.
61
61
  If you have more specific needs or plan on modifying r10k you can run it out of
62
62
  a git repository using Bundler for dependencies:
63
63
 
64
- git clone git://github.com/puppetlabs/r10k
64
+ git clone https://github.com/puppetlabs/r10k
65
65
  cd r10k
66
66
  bundle install
67
67
  bundle exec r10k help
@@ -128,6 +128,18 @@ git:
128
128
  private_key: "/etc/puppetlabs/r10k/ssh/id_rsa"
129
129
  ```
130
130
 
131
+ #### oauth_token
132
+
133
+ The oauth_token setting is only used by the Rugged git provider.
134
+
135
+ The oauth_token option specifies the path to the default access token for Git HTTPS remotes.
136
+ Public git repositories can be accessed via HTTPS without authentication, but the oauth_token setting may be set if any non-public HTTPS remotes are used.
137
+
138
+ ```yaml
139
+ git:
140
+ oauth_token: "/etc/puppetlabs/r10k/token"
141
+ ```
142
+
131
143
  #### repositories
132
144
 
133
145
  The repositories option allows configuration to be set on a per-remote basis. Each entry is a map of
@@ -145,6 +157,18 @@ git:
145
157
  private_key: "/etc/puppetlabs/r10k/ssh/id_rsa-protected-repo-deploy-key"
146
158
  ```
147
159
 
160
+ ##### oauth_token
161
+
162
+ A repository specific access token to use for HTTPS connections for the given repository URL. This
163
+ overrides the global oauth_token setting.
164
+
165
+ ```yaml
166
+ git:
167
+ repositories:
168
+ - remote: "https://tessier-ashpool.freeside/protected-repo.git"
169
+ oauth_token: "/etc/puppetlabs/r10k/protected-repo-deploy-token"
170
+ ```
171
+
148
172
  ##### proxy
149
173
 
150
174
  The 'proxy' setting allows you to set or override the global proxy setting for a single, specific
@@ -349,12 +373,13 @@ deploy:
349
373
 
350
374
  #### exclude_spec
351
375
 
352
- During module deployment, r10k's default behavior is to deploy the spec directory.
353
- This behavior can be configured for all modules using the `exclude_spec` setting in the r10k config.
354
- This config setting can be overridden in each module definition in the Puppetfile
355
- or more globally via the CLI for deploys. The following example sets all modules to
356
- not deploy the spec dir.
357
-
376
+ During module deployment, r10k's default behavior is to deploy the spec directory. Setting
377
+ `exclude_spec` to true will deploy modules without their spec directory. This behavior
378
+ can be configured for all modules using the `exclude_spec` setting in the r10k config.
379
+ It can also be passed as a CLI argument for `deploy environment/module`, overriding the
380
+ r10k config. Setting this per module in a `Puppetfile` will override the default, r10k config,
381
+ and cli flag for that module. The following example sets all modules to not deploy the spec
382
+ dir via the r10k config.
358
383
 
359
384
  ```yaml
360
385
  deploy:
@@ -373,13 +398,16 @@ specific documentation for more information.
373
398
  The 'remote' setting specifies where the source repository should be fetched
374
399
  from. It may be any valid URL that the source may check out or clone. The remote
375
400
  must be able to be fetched without any interactive input, eg usernames or
376
- passwords cannot be prompted for in order to fetch the remote.
401
+ passwords cannot be prompted for in order to fetch the remote. We support the
402
+ `git`, `ssh`, and `https` transport protocols. An SSH private key or access
403
+ token must be provided for authentication. Only `https` may be used without
404
+ authentication. See [GitHub's blog on protocol security](https://github.blog/2021-09-01-improving-git-protocol-security-github/) for more info.
377
405
 
378
406
  ```yaml
379
407
  ---
380
408
  sources:
381
409
  mysource:
382
- remote: 'git://git-server.site/my-org/main-modules'
410
+ remote: 'https://git-server.site/my-org/main-modules'
383
411
  ```
384
412
 
385
413
  ### basedir
@@ -497,7 +525,7 @@ hiera data files are kept. In this case you will specify a single source:
497
525
  ---
498
526
  sources:
499
527
  operations:
500
- remote: 'git://git-server.site/my-org/org-modules'
528
+ remote: 'https://git-server.site/my-org/org-modules'
501
529
  basedir: '/etc/puppet/environments'
502
530
  ```
503
531
 
@@ -510,10 +538,10 @@ repository and your modules in another repository, you can specify two sources:
510
538
  ---
511
539
  sources:
512
540
  operations:
513
- remote: 'git://git-server.site/my-org/org-modules'
541
+ remote: 'https://git-server.site/my-org/org-modules'
514
542
  basedir: '/etc/puppet/environments'
515
543
  hiera:
516
- remote: 'git://git-server.site/my-org/org-hiera-data'
544
+ remote: 'https://git-server.site/my-org/org-hiera-data'
517
545
  basedir: '/etc/puppet/hiera-data'
518
546
  ```
519
547
 
@@ -528,15 +556,15 @@ not the modules of other groups.
528
556
  ---
529
557
  sources:
530
558
  main:
531
- remote: 'git://git-server.site/my-org/main-modules'
559
+ remote: 'https://git-server.site/my-org/main-modules'
532
560
  basedir: '/etc/puppet/environments'
533
561
  prefix: false # Prefix defaults to false so this is only here for clarity
534
562
  qa:
535
- remote: 'git://git-server.site/my-org/qa-puppet-modules'
563
+ remote: 'https://git-server.site/my-org/qa-puppet-modules'
536
564
  basedir: '/etc/puppet/environments'
537
565
  prefix: true
538
566
  dev:
539
- remote: 'git://git-server.site/my-org/dev-puppet-modules'
567
+ remote: 'https://git-server.site/my-org/dev-puppet-modules'
540
568
  basedir: '/etc/puppet/environments'
541
569
  prefix: true
542
570
  ```
@@ -562,11 +590,11 @@ must override the `prefix` so environment folders line up in both directories:
562
590
  ---
563
591
  sources:
564
592
  app1_data:
565
- remote: 'git://git-server.site/my-org/app1-hieradata'
593
+ remote: 'https://git-server.site/my-org/app1-hieradata'
566
594
  basedir: '/etc/puppet/hieradata'
567
595
  prefix: "app1"
568
596
  app1_modules:
569
- remote: 'git://git-server.site/my-org/app1-puppet-modules'
597
+ remote: 'https://git-server.site/my-org/app1-puppet-modules'
570
598
  basedir: '/etc/puppet/environments'
571
599
  prefix: "app1"
572
600
  ```
@@ -84,6 +84,10 @@ explicit, static version. These are released Forge versions, or Git modules usin
84
84
  the `:tag`, or `:commit` keys. Git `:ref`s containing only the full 40 character
85
85
  commit SHA will also be treated as static versions. Then invoke a deploy with:
86
86
 
87
+ There may be issues with deployments apparently successful after an initial errored
88
+ deployment. If this is happening, try running without the `--incremental` flag
89
+ to run a full deployment.
90
+
87
91
  r10k deploy environment production --modules --incremental
88
92
 
89
93
  - - -
@@ -38,7 +38,7 @@ mod "puppetlabs/ntp"
38
38
 
39
39
  # Your modules:
40
40
  mod "custom_facts",
41
- :git => "git://github.com/user/custom_facts"
41
+ :git => "https://github.com/user/custom_facts"
42
42
  ```
43
43
 
44
44
  For any existing modules that you branched, add a reference to the new branch
@@ -46,7 +46,7 @@ name. Don't forget the comma at the end of the *:git* value.
46
46
 
47
47
  ```
48
48
  mod "other_module",
49
- :git => "git://github.com/user/other_module",
49
+ :git => "https://github.com/user/other_module",
50
50
  :ref => "feature"
51
51
  ```
52
52
 
@@ -159,7 +159,7 @@ the *:git* value.
159
159
 
160
160
  ```
161
161
  mod "other_module",
162
- :git => "git://github.com/user/other_module",
162
+ :git => "https://github.com/user/other_module",
163
163
  :ref => "feature"
164
164
  ```
165
165
 
data/doc/faq.mkd CHANGED
@@ -17,7 +17,7 @@ modify. For example creating the script:
17
17
 
18
18
  ```
19
19
  $ cat /usr/local/bin/generate-puppet-types.sh
20
- !#/bin/bash
20
+ #!/bin/bash
21
21
 
22
22
  for environment in $1; do
23
23
  /opt/puppetlabs/bin/puppet generate types --environment $environment
@@ -56,6 +56,28 @@ git:
56
56
  private_key: '/root/.ssh/private_repo_id'
57
57
  ```
58
58
 
59
+ ### HTTPS Configuration
60
+
61
+ Public HTTPS based Git repositories can be accessed with no additional settings.
62
+ For repos that do require authentication, the 'oauth_token' option may be provided.
63
+
64
+ ```yaml
65
+ git:
66
+ oauth_token: '/etc/puppetlabs/r10k/token'
67
+ ```
68
+
69
+ If you have per repository access tokens you can add them with the repositories list.
70
+
71
+ ```yaml
72
+ git:
73
+ # default access token
74
+ oauth_token: '/etc/puppetlabs/r10k/token'
75
+ repositories:
76
+ - remote: "https://github.com/my_org/private_repo.git"
77
+ # access token for this repo only
78
+ oauth_token: '/etc/puppetlabs/r10k/private_repo_token'
79
+ ```
80
+
59
81
  #### Supported transports with Rugged
60
82
 
61
83
  Rugged compiles libgit2 and and the Ruby bindings when the gem is installed. You
data/docker/Makefile CHANGED
@@ -6,7 +6,11 @@ build_date := $(shell date -u +%FT%T)
6
6
  hadolint_available := $(shell hadolint --help > /dev/null 2>&1; echo $$?)
7
7
  hadolint_command := hadolint
8
8
  hadolint_container := ghcr.io/hadolint/hadolint:latest
9
- alpine_version := 3.9
9
+ alpine_version := 3.14
10
+ # --load (--output=type=docker) can only be used with a single arch / platform
11
+ # https://github.com/docker/buildx/issues/59
12
+ output_type := docker
13
+ platform := linux/amd64
10
14
  export BUNDLE_PATH = $(PWD)/.bundle/gems
11
15
  export BUNDLE_BIN = $(PWD)/.bundle/bin
12
16
  export GEMFILE = $(PWD)/Gemfile
@@ -32,6 +36,10 @@ else
32
36
  dockerfile_context := $(PWD)/..
33
37
  endif
34
38
 
39
+ ifeq ($(IS_LATEST),true)
40
+ latest_tag := --tag $(NAMESPACE)/r10k:$(LATEST_VERSION)
41
+ endif
42
+
35
43
  prep:
36
44
  @git fetch --unshallow 2> /dev/null ||:
37
45
  @git fetch origin 'refs/tags/*:refs/tags/*'
@@ -52,17 +60,15 @@ build: prep
52
60
  docker pull alpine:$(alpine_version)
53
61
  docker buildx build \
54
62
  ${DOCKER_BUILD_FLAGS} \
55
- --load \
63
+ --output=type=$(output_type) \
64
+ --platform $(platform) \
56
65
  --build-arg alpine_version=$(alpine_version) \
57
66
  --build-arg vcs_ref=$(vcs_ref) \
58
67
  --build-arg build_date=$(build_date) \
59
68
  --build-arg version=$(VERSION) \
60
69
  --build-arg pupperware_analytics_stream=$(PUPPERWARE_ANALYTICS_STREAM) \
61
70
  --file r10k/$(dockerfile) \
62
- --tag $(NAMESPACE)/r10k:$(VERSION) $(dockerfile_context)
63
- ifeq ($(IS_LATEST),true)
64
- @docker tag $(NAMESPACE)/r10k:$(VERSION) puppet/r10k:$(LATEST_VERSION)
65
- endif
71
+ --tag $(NAMESPACE)/r10k:$(VERSION) $(latest_tag) $(dockerfile_context)
66
72
 
67
73
  test: prep
68
74
  @bundle install --path $$BUNDLE_PATH --gemfile $$GEMFILE --with test
@@ -71,11 +77,12 @@ test: prep
71
77
  bundle exec --gemfile $$GEMFILE \
72
78
  rspec spec
73
79
 
74
- push-image: prep
75
- @docker push $(NAMESPACE)/r10k:$(VERSION)
76
- ifeq ($(IS_LATEST),true)
77
- @docker push $(NAMESPACE)/r10k:$(LATEST_VERSION)
78
- endif
80
+ # call build to produce multiple architectures
81
+ # uses cached output from amd64 build target if it exists
82
+ # registry output is equivalent to --push
83
+ push-image: platform=linux/amd64,linux/arm64
84
+ push-image: output_type=registry
85
+ push-image: prep build
79
86
 
80
87
  push-readme:
81
88
  @docker pull sheogorath/readme-to-dockerhub
@@ -1,4 +1,4 @@
1
- ARG alpine_version=3.9
1
+ ARG alpine_version=3.14
2
2
  FROM alpine:${alpine_version} as build
3
3
 
4
4
  # hadolint ignore=DL3018
@@ -1,4 +1,4 @@
1
- ARG alpine_version=3.9
1
+ ARG alpine_version=3.14
2
2
  FROM alpine:${alpine_version}
3
3
 
4
4
  ARG vcs_ref
@@ -16,7 +16,7 @@ r10k_config_bak_path = "#{r10k_config_path}.bak"
16
16
 
17
17
  puppetfile =<<-EOS
18
18
  mod 'motd',
19
- :git => 'git://github.com/puppetlabs/puppetlabs-motd'
19
+ :git => 'https://github.com/puppetlabs/puppetlabs-motd'
20
20
  EOS
21
21
 
22
22
  proxy_env_value = 'http://cattastic.net:3219'
@@ -29,11 +29,11 @@ CONF
29
29
  # Install the same module in two different places
30
30
  puppetfile = <<-EOS
31
31
  mod 'prod_apache',
32
- :git => 'git://github.com/puppetlabs/puppetlabs-apache.git',
32
+ :git => 'https://github.com/puppetlabs/puppetlabs-apache.git',
33
33
  :tag => 'v6.0.0'
34
34
 
35
35
  mod 'test_apache',
36
- :git => 'git://github.com/puppetlabs/puppetlabs-apache.git',
36
+ :git => 'https://github.com/puppetlabs/puppetlabs-apache.git',
37
37
  :tag => 'v6.0.0'
38
38
  EOS
39
39
 
@@ -30,12 +30,12 @@ CONF
30
30
  puppetfile = <<-EOS
31
31
  mod 'non_module_object_1',
32
32
  :install_path => './',
33
- :git => 'git://github.com/puppetlabs/control-repo.git',
33
+ :git => 'https://github.com/puppetlabs/control-repo.git',
34
34
  :branch => 'production'
35
35
 
36
36
  mod 'non_module_object_2',
37
37
  :install_path => '',
38
- :git => 'git://github.com/puppetlabs/control-repo.git',
38
+ :git => 'https://github.com/puppetlabs/control-repo.git',
39
39
  :branch => 'production'
40
40
  EOS
41
41
 
@@ -27,7 +27,7 @@ stdlib_notify_message_regex = /The test message is:.*one.*=>.*1.*two.*=>.*bats.*
27
27
  puppet_file = <<-PUPPETFILE
28
28
  mod "puppetlabs/motd"
29
29
  mod 'puppetlabs/stdlib',
30
- :git => 'git://github.com/puppetlabs/puppetlabs-stdlib.git',
30
+ :git => 'https://github.com/puppetlabs/puppetlabs-stdlib.git',
31
31
  :tag => 'v7.0.1'
32
32
  PUPPETFILE
33
33
 
@@ -31,7 +31,7 @@ puppet_file = <<-PUPPETFILE
31
31
  moduledir '#{@module_path}'
32
32
  mod "puppetlabs/motd"
33
33
  mod 'puppetlabs/stdlib',
34
- :git => 'git://github.com/puppetlabs/puppetlabs-stdlib.git',
34
+ :git => 'https://github.com/puppetlabs/puppetlabs-stdlib.git',
35
35
  :tag => 'v7.0.1'
36
36
  PUPPETFILE
37
37
 
@@ -65,7 +65,7 @@ env_structs = {:production => GitEnv.new('/git_repos',
65
65
  '/git_repos_alt/environments_alt.git',
66
66
  '/root/environments_alt',
67
67
  '/root/environments_alt/Puppetfile',
68
- 'mod "puppetlabs/stdlib", :git => "git://github.com/puppetlabs/puppetlabs-stdlib.git", :tag => "v7.0.1"',
68
+ 'mod "puppetlabs/stdlib", :git => "https://github.com/puppetlabs/puppetlabs-stdlib.git", :tag => "v7.0.1"',
69
69
  '/root/environments_alt/manifests/site.pp',
70
70
  create_site_pp(master_certname, stage_env_manifest)
71
71
  ),
@@ -15,7 +15,7 @@ r10k_fqp = get_r10k_fqp(master)
15
15
 
16
16
  #File
17
17
  puppet_file = <<-PUPPETFILE
18
- mod 'broken', :git => 'git://github.com/puppetlabs/puppetlabs-broken'
18
+ mod 'broken', :git => 'https://github.com/puppetlabs/puppetlabs-broken'
19
19
  PUPPETFILE
20
20
 
21
21
  puppet_file_path = File.join(git_environments_path, 'Puppetfile')
@@ -12,7 +12,7 @@ r10k_fqp = get_r10k_fqp(master)
12
12
  #File
13
13
  puppet_file = <<-PUPPETFILE
14
14
  mod 'broken',
15
- :git => 'git://github.com/puppetlabs/puppetlabs-motd',
15
+ :git => 'https://github.com/puppetlabs/puppetlabs-motd',
16
16
  :ref => 'does_not_exist'
17
17
  PUPPETFILE
18
18
 
@@ -28,7 +28,7 @@ notify_message_regex = /I am in the production environment/
28
28
  puppet_file = <<-PUPPETFILE
29
29
  mod "puppetlabs/motd"
30
30
  mod 'puppetlabs/inifile',
31
- :git => 'git://github.com/puppetlabs/puppetlabs-inifile',
31
+ :git => 'https://github.com/puppetlabs/puppetlabs-inifile',
32
32
  :tag => 'v5.0.1'
33
33
  PUPPETFILE
34
34
 
@@ -27,7 +27,7 @@ PUPPETFILE
27
27
 
28
28
  puppet_file_git = <<-PUPPETFILE
29
29
  mod "puppetlabs/motd",
30
- :git => 'git://github.com/puppetlabs/puppetlabs-motd',
30
+ :git => 'https://github.com/puppetlabs/puppetlabs-motd',
31
31
  :tag => '1.2.0'
32
32
  PUPPETFILE
33
33
 
@@ -96,13 +96,36 @@ class R10K::Environment::WithModules < R10K::Environment::Base
96
96
  def load_modules(module_hash)
97
97
  module_hash.each do |name, args|
98
98
  if !args.is_a?(Hash)
99
- args = { version: args }
99
+ args = { type: 'forge', version: args }
100
100
  end
101
101
 
102
102
  add_module(name, args)
103
103
  end
104
104
  end
105
105
 
106
+ def resolve_path(base, dirname, path)
107
+ if Pathname.new(path).absolute?
108
+ cleanpath(path)
109
+ else
110
+ cleanpath(File.join(base, dirname, path))
111
+ end
112
+ end
113
+
114
+ # .cleanpath is as good as we can do without touching the filesystem.
115
+ # The .realpath methods will choke if some of the intermediate paths
116
+ # are missing, even though in some cases we will create them later as
117
+ # needed.
118
+ def cleanpath(path)
119
+ Pathname.new(path).cleanpath.to_s
120
+ end
121
+
122
+ def validate_install_path(path, modname)
123
+ unless /^#{Regexp.escape(@basedir)}.*/ =~ path
124
+ raise R10K::Error.new("Environment cannot manage content '#{modname}' outside of containing environment: #{path} is not within #{@basedir}")
125
+ end
126
+ true
127
+ end
128
+
106
129
  # @param [String] name
107
130
  # @param [Hash] args
108
131
  def add_module(name, args)
@@ -111,7 +134,7 @@ class R10K::Environment::WithModules < R10K::Environment::Base
111
134
  args[:overrides] = @overrides
112
135
 
113
136
  if install_path = args.delete(:install_path)
114
- install_path = resolve_install_path(install_path)
137
+ install_path = resolve_path(@basedir, @dirname, install_path)
115
138
  validate_install_path(install_path, name)
116
139
  else
117
140
  install_path = @moduledir
@@ -64,7 +64,7 @@ class R10K::Git::Rugged::BareRepository < R10K::Git::Rugged::BaseRepository
64
64
  results = nil
65
65
 
66
66
  R10K::Git.with_proxy(proxy) do
67
- results = with_repo { |repo| repo.fetch(remote_name, refspecs, options) }
67
+ results = with_repo { |repo| repo.fetch(remote_name, refspecs, **options) }
68
68
  end
69
69
 
70
70
  report_transfer(results, remote_name)
@@ -130,7 +130,7 @@ class R10K::Git::Rugged::Credentials
130
130
 
131
131
  user = nil
132
132
 
133
- if !username_from_url.nil?
133
+ if !username_from_url.nil? && !username_from_url.empty?
134
134
  user = username_from_url
135
135
  logger.debug2 _("URL %{url} includes the username %{username}, using that user for authentication.") % {url: url.inspect, username: username_from_url}
136
136
  elsif git_user
@@ -75,6 +75,13 @@ class R10K::Git::Rugged::ThinRepository < R10K::Git::Rugged::WorkingRepository
75
75
  end
76
76
  end
77
77
 
78
+ def stage_files(files=['.'])
79
+ with_repo do |repo|
80
+ index = repo.index
81
+ files.each { |p| index.add( :path => p ) }
82
+ end
83
+ end
84
+
78
85
  private
79
86
 
80
87
  # Override the parent class repo setup so that we can make sure the alternates file is up to date
@@ -93,7 +93,7 @@ class R10K::Git::Rugged::WorkingRepository < R10K::Git::Rugged::BaseRepository
93
93
  results = nil
94
94
 
95
95
  R10K::Git.with_proxy(proxy) do
96
- results = with_repo { |repo| repo.fetch(remote_name, refspecs, options) }
96
+ results = with_repo { |repo| repo.fetch(remote_name, refspecs, **options) }
97
97
  end
98
98
 
99
99
  report_transfer(results, remote)
@@ -117,11 +117,15 @@ class R10K::Git::Rugged::WorkingRepository < R10K::Git::Rugged::BaseRepository
117
117
  with_repo { |repo| repo.config['remote.origin.url'] }
118
118
  end
119
119
 
120
- def dirty?
120
+ def dirty?(exclude_spec=false)
121
121
  with_repo do |repo|
122
- diff = repo.diff_workdir('HEAD')
122
+ if exclude_spec
123
+ diff = repo.diff_workdir('HEAD').select { |d| ! d.delta.old_file[:path].start_with?('spec/') }
124
+ else
125
+ diff = repo.diff_workdir('HEAD').to_a
126
+ end
123
127
 
124
- diff.each_patch do |p|
128
+ diff.each do |p|
125
129
  logger.debug(_("Found local modifications in %{file_path}" % {file_path: File.join(@path, p.delta.old_file[:path])}))
126
130
  logger.debug1(p.to_s)
127
131
  end
@@ -43,6 +43,10 @@ class R10K::Git::ShellGit::ThinRepository < R10K::Git::ShellGit::WorkingReposito
43
43
  git(['ls-tree', '-t', '-r', '--name-only', ref], :path => @path.to_s).stdout.split("\n")
44
44
  end
45
45
 
46
+ def stage_files(files=['.'])
47
+ git(['add', files].flatten, :path => @path.to_s)
48
+ end
49
+
46
50
  private
47
51
 
48
52
  def setup_cache_remote
@@ -90,11 +90,12 @@ class R10K::Git::ShellGit::WorkingRepository < R10K::Git::ShellGit::BaseReposito
90
90
  end
91
91
 
92
92
  # does the working tree have local modifications to tracked files?
93
- def dirty?
93
+ def dirty?(exclude_spec=false)
94
94
  result = git(['diff-index', '--exit-code', '--name-only', 'HEAD'], :path => @path.to_s, :raise_on_fail => false)
95
95
 
96
96
  if result.exit_code != 0
97
97
  dirty_files = result.stdout.split('\n')
98
+ dirty_files.delete_if { |f| f.start_with?('spec/') } if exclude_spec
98
99
 
99
100
  dirty_files.each do |file|
100
101
  logger.debug(_("Found local modifications in %{file_path}" % {file_path: File.join(@path, file)}))
@@ -103,7 +104,7 @@ class R10K::Git::ShellGit::WorkingRepository < R10K::Git::ShellGit::BaseReposito
103
104
  logger.debug1 { git(['diff-index', '-p', 'HEAD', file], :path => @path.to_s, :raise_on_fail => false).stdout }
104
105
  end
105
106
 
106
- return true
107
+ return dirty_files.size > 0
107
108
  else
108
109
  return false
109
110
  end