r10k 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZWM0YTE3ZTkwYmEyZDkxZTE0ZDdlMzUyOGEzODI0Zjk1ZGU4OWI4MQ==
4
+ MTVkMmIxYThmNTlhNWYzZDA2OGM2ZTk4NWY1NGUwODcxNzViNDU2MA==
5
5
  data.tar.gz: !binary |-
6
- ZjM0ZGE5NDk2ZjE1YjM0ZDA0NjU4MzE5ZmRmYmI5NzFkYjkxMjViMw==
6
+ MjIwNDQ0NjhkNTgyNWUxMDgzN2U0OWQ4MDYzYjMxZTk4Y2ZmMmM1ZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTc2MTFjZjBiNTljNGY0NzQyZDhiNDllOTFmYjEyOTY5OTA1MzViMDlhM2I4
10
- MTczZjQwMWE1NjI3MTEwNjllYTlkOTcyZDgyZjFkZWI2MTYxODc5ZDhkOGZl
11
- YjQxZDE2YmY4ZTc1YjY3MGJjMjE4ZWMyYzk1YmQ3NGJmZDgyZjk=
9
+ NTQ5YjcxZWI0OWI4MGRiMWUyNjkxODgyYTNhMmM1YjFhNTdkYjFhOTg2MTU5
10
+ OTM0ZWJmNDBkYzA1NjhlMzVmODdjYWYxODAwY2UxYTA0YzIyYjQ1N2ZjNmY4
11
+ N2JlMWViZGM0ZTRhOTU4M2IxMTUzZDQ4NzEzY2NmODE0MmQzY2U=
12
12
  data.tar.gz: !binary |-
13
- MGJlYWJlZmU0MzczZmNjZmY4MTA1M2RhMGM2YjY3ODM5NjkwNGRhMzE5Y2Zj
14
- YjMzZTU5ODk0NGIwYmFiMTVjMWJjMGY0OTIyMTFiMzcwZjUzN2JhNWE3MzY3
15
- N2JlNTZlMWQ1ZGE1YTE1YjgxZDQwMWM1NDZkMGMwZDM5NjQzYjI=
13
+ ZGFiMTA0NTE1NTBkODA2ZGVjOTcwZWMwMTlkMmI1NTdkMDRmY2FkMjYyMWRm
14
+ YWQ3NDViNjU3Y2UyOTkzM2RkOGM3M2YxNjRjY2FjODU1ZmFjMmQ1YTNjNGNm
15
+ MTYxZmVmMGFmMzMyYTI3OTg2ZTJjMzQ4Nzk3OWE0OTU3ODg1OGI=
@@ -1,6 +1,31 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
+ 2.1.1
5
+ -----
6
+
7
+ 2015/11/12
8
+
9
+ ### Notes
10
+
11
+ (CODEMGMT-440) Defer git alternates setup
12
+
13
+ The fix for RK-175 that updated the Git alternates file for repositories was happening too early, and
14
+ could cause issues when multiple r10k processes were running concurrently. This has been fixed so that
15
+ the alternates file update is deferred till the first time the git repository is actually accessed.
16
+
17
+ (RK-187) Consider thin repos with a .git file (not directory) to be mismatched
18
+
19
+ If a given Git thin repository had a .git file where r10k expected there to be a directory it would
20
+ behave badly; this has been fixed so that if r10k encounters this case it treats the repository as
21
+ mismatched.
22
+
23
+ (RK-181) Correctly set baseurl/proxy with shared PuppetForge URL
24
+
25
+ A combination of some odd connection handling behavior in the puppet_forge gem combined with some
26
+ bad assumptions in r10k prevented users from being able to actually set a custom forge baseurl;
27
+ this has been fixed.
28
+
4
29
  2.1.0
5
30
  -----
6
31
 
@@ -37,7 +37,10 @@ module R10K
37
37
  @full_name = PuppetForge::V3.normalize_name(full_name)
38
38
  @version = version
39
39
 
40
- PuppetForge::V3::Release.conn = conn
40
+ # Copy the PuppetForge base connection to the release class; the connection
41
+ # objects are created in the class instances and thus are not shared with
42
+ # subclasses.
43
+ PuppetForge::V3::Release.conn = PuppetForge::V3::Base.conn
41
44
  @forge_release = PuppetForge::V3::Release.new({ :name => @full_name, :version => @version, :slug => "#{@full_name}-#{@version}" })
42
45
 
43
46
  @download_path = Pathname.new(Dir.mktmpdir) + (@forge_release.slug + '.tar.gz')
@@ -120,30 +123,6 @@ module R10K
120
123
  download_path.delete
121
124
  end
122
125
  end
123
-
124
- private
125
-
126
- def conn
127
- if settings[:baseurl]
128
- PuppetForge.host = settings[:baseurl]
129
- conn = PuppetForge::Connection.make_connection(settings[:baseurl])
130
- else
131
- PuppetForge.host = "https://forgeapi.puppetlabs.com"
132
- conn = PuppetForge::Connection.default_connection
133
- end
134
- conn.proxy(proxy)
135
- conn
136
- end
137
-
138
- def proxy
139
- [
140
- settings[:proxy],
141
- ENV['HTTPS_PROXY'],
142
- ENV['https_proxy'],
143
- ENV['HTTP_PROXY'],
144
- ENV['http_proxy']
145
- ].find { |value| value }
146
- end
147
126
  end
148
127
  end
149
128
  end
@@ -66,11 +66,9 @@ class R10K::Git::Rugged::ThinRepository < R10K::Git::Rugged::WorkingRepository
66
66
  # Override the parent class repo setup so that we can make sure the alternates file is up to date
67
67
  # before we create the Rugged::Repository object, which reads from the alternates file.
68
68
  def setup_rugged_repo
69
- if git_dir.exist?
70
- entry_added = alternates.add?(@cache_repo.objects_dir.to_s)
71
- if entry_added
72
- logger.debug2 { "Updated repo #{@path} to include alternate object db path #{@cache_repo.objects_dir}" }
73
- end
69
+ entry_added = alternates.add?(@cache_repo.objects_dir.to_s)
70
+ if entry_added
71
+ logger.debug2 { "Updated repo #{@path} to include alternate object db path #{@cache_repo.objects_dir}" }
74
72
  end
75
73
  super
76
74
  end
@@ -13,7 +13,6 @@ class R10K::Git::Rugged::WorkingRepository < R10K::Git::Rugged::BaseRepository
13
13
  # @param dirname [String] The directory name of the Git repository
14
14
  def initialize(basedir, dirname)
15
15
  @path = Pathname.new(File.join(basedir, dirname))
16
- setup_rugged_repo
17
16
  end
18
17
 
19
18
  # Clone this git repository
@@ -99,9 +98,14 @@ class R10K::Git::Rugged::WorkingRepository < R10K::Git::Rugged::BaseRepository
99
98
 
100
99
  private
101
100
 
102
- def setup_rugged_repo
103
- if exist? && git_dir.exist?
104
- @_rugged_repo = ::Rugged::Repository.new(@path.to_s, :alternates => alternates.to_a)
101
+ def with_repo
102
+ if @_rugged_repo.nil? && git_dir.exist?
103
+ setup_rugged_repo
105
104
  end
105
+ super
106
+ end
107
+
108
+ def setup_rugged_repo
109
+ @_rugged_repo = ::Rugged::Repository.new(@path.to_s, :alternates => alternates.to_a)
106
110
  end
107
111
  end
@@ -11,12 +11,6 @@ class R10K::Git::ShellGit::ThinRepository < R10K::Git::ShellGit::WorkingReposito
11
11
  def initialize(basedir, dirname, cache_repo)
12
12
  @cache_repo = cache_repo
13
13
  super(basedir, dirname)
14
- if git_dir.exist?
15
- entry_added = alternates.add?(@cache_repo.objects_dir.to_s)
16
- if entry_added
17
- logger.debug2 { "Updated repo #{@path} to include alternate object db path #{@cache_repo.objects_dir}" }
18
- end
19
- end
20
14
  end
21
15
 
22
16
  # Clone this git repository
@@ -51,4 +45,21 @@ class R10K::Git::ShellGit::ThinRepository < R10K::Git::ShellGit::WorkingReposito
51
45
  git ["remote", "add", "cache", @cache_repo.git_dir.to_s], :path => @path.to_s
52
46
  fetch
53
47
  end
48
+
49
+ def git(cmd, opts = {})
50
+ if !@_synced_alternates
51
+ sync_alternates
52
+ @_synced_alternates = true
53
+ end
54
+ super
55
+ end
56
+
57
+ def sync_alternates
58
+ if git_dir.exist?
59
+ entry_added = alternates.add?(@cache_repo.objects_dir.to_s)
60
+ if entry_added
61
+ logger.debug2 { "Updated repo #{@path} to include alternate object db path #{@cache_repo.objects_dir}" }
62
+ end
63
+ end
64
+ end
54
65
  end
@@ -59,6 +59,8 @@ class R10K::Git::StatefulRepository
59
59
  :absent
60
60
  elsif !@repo.git_dir.exist?
61
61
  :mismatched
62
+ elsif !@repo.git_dir.directory?
63
+ :mismatched
62
64
  elsif !(@repo.origin == @remote)
63
65
  :mismatched
64
66
  elsif !(@repo.head == @cache.resolve(@ref))
@@ -47,8 +47,8 @@ module R10K
47
47
 
48
48
  class ForgeInitializer < BaseInitializer
49
49
  def call
50
- with_setting(:proxy) { |value| R10K::Forge::ModuleRelease.settings[:proxy] = value }
51
- with_setting(:baseurl) { |value| R10K::Forge::ModuleRelease.settings[:baseurl] = value }
50
+ with_setting(:baseurl) { |value| PuppetForge.host = value }
51
+ with_setting(:proxy) { |value| PuppetForge::V3::Base.conn.proxy(value) }
52
52
  end
53
53
  end
54
54
  end
@@ -60,7 +60,7 @@ class R10K::Module::Forge < R10K::Module::Base
60
60
  def expected_version
61
61
  if @expected_version == :latest
62
62
  begin
63
- @expected_version = @v3_module.current_release.version
63
+ @expected_version = @v3_module.current_release.version
64
64
  rescue Faraday::ResourceNotFound => e
65
65
  raise PuppetForge::ReleaseNotFound, "The module #{@title} does not exist on #{PuppetForge::V3::Release.conn.url_prefix}.", e.backtrace
66
66
  end
@@ -35,6 +35,14 @@ module R10K
35
35
  R10K::Settings::Collection.new(:forge, [
36
36
  URIDefinition.new(:proxy, {
37
37
  :desc => "An optional proxy server to use when downloading modules from the forge.",
38
+ :default => lambda do
39
+ [
40
+ ENV['HTTPS_PROXY'],
41
+ ENV['https_proxy'],
42
+ ENV['HTTP_PROXY'],
43
+ ENV['http_proxy']
44
+ ].find { |value| value }
45
+ end
38
46
  }),
39
47
 
40
48
  URIDefinition.new(:baseurl, {
@@ -1,3 +1,3 @@
1
1
  module R10K
2
- VERSION = '2.1.0'
2
+ VERSION = '2.1.1'
3
3
  end
@@ -26,6 +26,14 @@ describe R10K::Git::StatefulRepository do
26
26
  end
27
27
  end
28
28
 
29
+ describe "when the directory has a .git file" do
30
+ it "is mismatched" do
31
+ thinrepo.path.mkdir
32
+ File.open("#{thinrepo.path}/.git", "w") {}
33
+ expect(subject.status).to eq :mismatched
34
+ end
35
+ end
36
+
29
37
  describe "when the repository doesn't match the desired remote" do
30
38
  it "is mismatched" do
31
39
  thinrepo.clone(remote, {:ref => '1.0.0'})
@@ -18,38 +18,6 @@ describe R10K::Forge::ModuleRelease do
18
18
  subject.unpack_path = unpack_path
19
19
  end
20
20
 
21
- describe 'setting the proxy' do
22
- %w[HTTPS_PROXY https_proxy HTTP_PROXY http_proxy].each do |env_var|
23
- it "respects the #{env_var} environment variable" do
24
- R10K::Util::ExecEnv.withenv(env_var => "http://proxy.value") do
25
- subject = described_class.new('branan-eight_hundred', '8.0.0')
26
- proxy_uri = forge_release_class.conn.proxy.uri
27
- expect(proxy_uri.to_s).to eq "http://proxy.value"
28
- end
29
- end
30
- end
31
-
32
- describe 'using application settings' do
33
- before { described_class.settings[:proxy] = 'http://proxy.setting' }
34
- after { described_class.settings.reset! }
35
-
36
- it 'has a setting for the forge proxy' do
37
- subject = described_class.new('branan-eight_hundred', '8.0.0')
38
- proxy_uri = forge_release_class.conn.proxy.uri
39
- expect(proxy_uri.to_s).to eq "http://proxy.setting"
40
- end
41
-
42
- it 'prefers the proxy setting over an environment variable' do
43
- R10K::Util::ExecEnv.withenv('HTTPS_PROXY' => "http://proxy.from.env") do
44
- subject = described_class.new('branan-eight_hundred', '8.0.0')
45
- proxy_uri = forge_release_class.conn.proxy.uri
46
- expect(proxy_uri.to_s).to eq "http://proxy.setting"
47
- end
48
- end
49
- end
50
-
51
- end
52
-
53
21
  describe '#download' do
54
22
  it "downloads the module from the forge into `download_path`" do
55
23
  expect(subject.forge_release).to receive(:download).with(download_path)
@@ -22,15 +22,15 @@ describe R10K::Initializers::GitInitializer do
22
22
  end
23
23
 
24
24
  describe R10K::Initializers::ForgeInitializer do
25
- it "configures the Forge proxy" do
26
- subject = described_class.new({:proxy => 'http://my.site.proxy:3128'})
27
- expect(R10K::Forge::ModuleRelease.settings).to receive(:[]=).with(:proxy, 'http://my.site.proxy:3128')
25
+ it "sets the PuppetForge host" do
26
+ subject = described_class.new({:baseurl => 'https://my.site.forge'})
27
+ expect(PuppetForge).to receive(:host=).with('https://my.site.forge')
28
28
  subject.call
29
29
  end
30
30
 
31
- it "configures the Forge baseurl" do
32
- subject = described_class.new({:baseurl => 'https://my.site.forge'})
33
- expect(R10K::Forge::ModuleRelease.settings).to receive(:[]=).with(:baseurl, 'https://my.site.forge')
31
+ it "configures PuppetForge connection proxy" do
32
+ subject = described_class.new({:proxy => 'http://my.site.proxy:3128'})
33
+ expect(PuppetForge::V3::Base.conn).to receive(:proxy).with('http://my.site.proxy:3128')
34
34
  subject.call
35
35
  end
36
36
  end
@@ -1,5 +1,6 @@
1
1
  require 'spec_helper'
2
2
  require 'r10k/settings'
3
+ require 'r10k/util/exec_env'
3
4
 
4
5
  describe R10K::Settings do
5
6
  describe "git settings" do
@@ -52,6 +53,17 @@ describe R10K::Settings do
52
53
  expect(err.errors[:proxy].message).to match(/could not be parsed as a URL/)
53
54
  end
54
55
  end
56
+
57
+ describe "setting a default value" do
58
+ %w[HTTPS_PROXY https_proxy HTTP_PROXY http_proxy].each do |env_var|
59
+ it "respects the #{env_var} environment variable" do
60
+ R10K::Util::ExecEnv.withenv(env_var => "http://proxy.value/#{env_var}") do
61
+ output = subject.evaluate({})
62
+ expect(output[:proxy]).to eq("http://proxy.value/#{env_var}")
63
+ end
64
+ end
65
+ end
66
+ end
55
67
  end
56
68
 
57
69
  describe "baseurl" 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: 2.1.0
4
+ version: 2.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: 2015-10-28 00:00:00.000000000 Z
11
+ date: 2015-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored