vanagon 0.15.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vanagon/component/source.rb +45 -8
- data/lib/vanagon/component/source/git.rb +11 -2
- data/lib/vanagon/driver.rb +13 -14
- data/lib/vanagon/platform/dsl.rb +1 -1
- data/lib/vanagon/project.rb +13 -4
- data/spec/lib/vanagon/component/source_spec.rb +11 -2
- data/spec/lib/vanagon/driver_spec.rb +1 -1
- data/spec/lib/vanagon/platform/dsl_spec.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6191c02ed1d220d7d947a37b906e82e60b5bba38
|
4
|
+
data.tar.gz: a64bae317e40b8ac61dc189d062c86b52a26c2a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd1df71b5c97763d2316fc244ab0972ba5187a412cbe6c44cc77af95d82ebb102fa74327f1f1bbdc7ee0c3e66a5f63b581fe2a797d3acf9fc27e31195e101958
|
7
|
+
data.tar.gz: c03ff705b67c8688fe4dbfdc0d303600614030c2710d576aa4d9142f005002ba1e3ce33afc95b42d6ec55c43cc535af00c605380b42db4b933f0264a9fc0a356
|
@@ -15,17 +15,30 @@ class Vanagon
|
|
15
15
|
# @param options [Hash] hash of the options needed for the subtype
|
16
16
|
# @param workdir [String] working directory to fetch the source into
|
17
17
|
# @return [Vanagon::Component::Source] the correct subtype for the given source
|
18
|
-
def source(uri, **options)
|
19
|
-
#
|
20
|
-
|
18
|
+
def source(uri, **options) # rubocop:disable Metrics/AbcSize
|
19
|
+
# Sometimes the uri comes in as a string, but sometimes it's already been
|
20
|
+
# coerced into a URI object. The individual source providers will turn
|
21
|
+
# the passed uri into a URI object if needed, but for this method we
|
22
|
+
# want to work with the uri as a string.
|
23
|
+
uri = uri.to_s
|
24
|
+
if uri.start_with?('git')
|
25
|
+
source_type = :git
|
26
|
+
# when using an http(s) source for a git repo, you should prefix the
|
27
|
+
# url with `git:`, so something like `git:https://github.com/puppetlabs/vanagon`
|
28
|
+
# strip the leading `git:` so we have a valid uri
|
29
|
+
uri.sub!(/^git:http/, 'http')
|
30
|
+
else
|
31
|
+
source_type = determine_source_type(uri)
|
32
|
+
end
|
33
|
+
|
34
|
+
if source_type == :git
|
21
35
|
return Vanagon::Component::Source::Git.new uri,
|
22
36
|
sum: options[:sum],
|
23
37
|
ref: options[:ref],
|
24
38
|
workdir: options[:workdir]
|
25
39
|
end
|
26
40
|
|
27
|
-
|
28
|
-
if Vanagon::Component::Source::Http.valid_url?(uri)
|
41
|
+
if source_type == :http
|
29
42
|
return Vanagon::Component::Source::Http.new uri,
|
30
43
|
sum: options[:sum],
|
31
44
|
workdir: options[:workdir],
|
@@ -33,16 +46,40 @@ class Vanagon
|
|
33
46
|
sum_type: options[:sum_type] || "md5"
|
34
47
|
end
|
35
48
|
|
36
|
-
|
37
|
-
if Vanagon::Component::Source::Local.valid_file?(uri)
|
49
|
+
if source_type == :local
|
38
50
|
return Vanagon::Component::Source::Local.new uri,
|
39
51
|
workdir: options[:workdir]
|
40
52
|
end
|
41
53
|
|
42
|
-
#
|
54
|
+
# Unknown source type!
|
43
55
|
raise Vanagon::Error,
|
44
56
|
"Unknown file type: '#{uri}'; cannot continue"
|
45
57
|
end
|
58
|
+
|
59
|
+
def determine_source_type(uri)
|
60
|
+
# if source_type isn't specified, let's try to figure out what we have
|
61
|
+
# order of precedence for this is git, then http, then local
|
62
|
+
|
63
|
+
# Add a 5 second timeout for the `git remote-ls` execution to deal with
|
64
|
+
# URLs that incorrectly respond to git queries
|
65
|
+
timeout = 5
|
66
|
+
if Vanagon::Component::Source::Git.valid_remote?(uri, timeout)
|
67
|
+
if uri =~ /^http/
|
68
|
+
warn "Passing git URLs as http(s) addresses is deprecated! Please prefix your source URL with `git:`"
|
69
|
+
end
|
70
|
+
return :git
|
71
|
+
end
|
72
|
+
|
73
|
+
if Vanagon::Component::Source::Http.valid_url?(uri)
|
74
|
+
return :http
|
75
|
+
end
|
76
|
+
|
77
|
+
if Vanagon::Component::Source::Local.valid_file?(uri)
|
78
|
+
return :local
|
79
|
+
end
|
80
|
+
|
81
|
+
return :unknown
|
82
|
+
end
|
46
83
|
end
|
47
84
|
end
|
48
85
|
end
|
@@ -6,6 +6,7 @@ require 'English'
|
|
6
6
|
require 'fustigit'
|
7
7
|
require 'git/basic_submodules'
|
8
8
|
require 'logger'
|
9
|
+
require 'timeout'
|
9
10
|
|
10
11
|
class Vanagon
|
11
12
|
class Component
|
@@ -19,11 +20,19 @@ class Vanagon
|
|
19
20
|
# return True or False depending on whether or not
|
20
21
|
# `git` thinks it's a valid Git repo.
|
21
22
|
#
|
23
|
+
# @param url
|
24
|
+
# @param timeout Time (in seconds) to wait before assuming the
|
25
|
+
# git command has failed. Useful in instances where a URL
|
26
|
+
# prompts for credentials despite not being a git remote
|
22
27
|
# @return [Boolean] whether #url is a valid Git repo or not
|
23
|
-
def valid_remote?(url)
|
24
|
-
|
28
|
+
def valid_remote?(url, timeout = 0)
|
29
|
+
Timeout.timeout(timeout) do
|
30
|
+
!!::Git.ls_remote(url)
|
31
|
+
end
|
25
32
|
rescue ::Git::GitExecuteError
|
26
33
|
false
|
34
|
+
rescue Timeout::Error
|
35
|
+
false
|
27
36
|
end
|
28
37
|
end
|
29
38
|
|
data/lib/vanagon/driver.rb
CHANGED
@@ -11,7 +11,14 @@ class Vanagon
|
|
11
11
|
class Driver
|
12
12
|
include Vanagon::Utilities
|
13
13
|
attr_accessor :platform, :project, :target, :workdir, :remote_workdir, :verbose, :preserve
|
14
|
-
|
14
|
+
|
15
|
+
def timeout
|
16
|
+
@timeout ||= @project.timeout || ENV["VANAGON_TIMEOUT"] || 7200
|
17
|
+
end
|
18
|
+
|
19
|
+
def retry_count
|
20
|
+
@retry_count ||= @project.retry_count || ENV["VANAGON_RETRY_COUNT"] || 1
|
21
|
+
end
|
15
22
|
|
16
23
|
def initialize(platform, project, options = { workdir: nil, configdir: nil, target: nil, engine: nil, components: nil, skipcheck: false, verbose: false, preserve: false, only_build: nil, remote_workdir: nil }) # rubocop:disable Metrics/AbcSize
|
17
24
|
@verbose = options[:verbose]
|
@@ -118,8 +125,10 @@ class Vanagon
|
|
118
125
|
@engine.startup(workdir)
|
119
126
|
|
120
127
|
warn "Target is #{@engine.target}"
|
121
|
-
|
122
|
-
|
128
|
+
Vanagon::Utilities.retry_with_timeout(retry_count, timeout) do
|
129
|
+
install_build_dependencies
|
130
|
+
end
|
131
|
+
@project.fetch_sources(workdir, retry_count, timeout)
|
123
132
|
|
124
133
|
@project.make_makefile(workdir)
|
125
134
|
@project.make_bill_of_materials(workdir)
|
@@ -154,22 +163,12 @@ class Vanagon
|
|
154
163
|
end
|
155
164
|
|
156
165
|
warn "rendering Makefile"
|
157
|
-
|
166
|
+
@project.fetch_sources(workdir, retry_count, timeout)
|
158
167
|
@project.make_bill_of_materials(workdir)
|
159
168
|
@project.generate_packaging_artifacts(workdir)
|
160
169
|
@project.make_makefile(workdir)
|
161
170
|
end
|
162
171
|
|
163
|
-
# Retry the provided block, use the retry count and timeout
|
164
|
-
# values from the project, if available, otherwise use some
|
165
|
-
# sane defaults.
|
166
|
-
def retry_task(&block)
|
167
|
-
@timeout = @project.timeout || ENV["VANAGON_TIMEOUT"] || 7200
|
168
|
-
@retry_count = @project.retry_count || ENV["VANAGON_RETRY_COUNT"] || 1
|
169
|
-
Vanagon::Utilities.retry_with_timeout(@retry_count, @timeout) { yield }
|
170
|
-
end
|
171
|
-
private :retry_task
|
172
|
-
|
173
172
|
# Initialize the logging instance
|
174
173
|
def loginit(logfile)
|
175
174
|
@@logger = Logger.new(logfile)
|
data/lib/vanagon/platform/dsl.rb
CHANGED
@@ -30,7 +30,7 @@ class Vanagon
|
|
30
30
|
@platform = case platform_name
|
31
31
|
when /^aix-/
|
32
32
|
Vanagon::Platform::RPM::AIX.new(@name)
|
33
|
-
when /^(cisco-wrlinux|el|fedora)-/
|
33
|
+
when /^(cisco-wrlinux|el|fedora|redhat)-/
|
34
34
|
Vanagon::Platform::RPM.new(@name)
|
35
35
|
when /^sles-/
|
36
36
|
Vanagon::Platform::RPM::SLES.new(@name)
|
data/lib/vanagon/project.rb
CHANGED
@@ -162,12 +162,21 @@ class Vanagon
|
|
162
162
|
# Collects all sources and patches into the provided workdir
|
163
163
|
#
|
164
164
|
# @param workdir [String] directory to stage sources into
|
165
|
-
|
165
|
+
# @param retry_count [Integer] number of times to retry each fetch
|
166
|
+
# @param timeout [Integer] How long to wait (in seconds) for each
|
167
|
+
# fetch before aborting
|
168
|
+
def fetch_sources(workdir, retry_count = 1, timeout = 7200)
|
166
169
|
@components.each do |component|
|
167
|
-
|
170
|
+
Vanagon::Utilities.retry_with_timeout(retry_count, timeout) do
|
171
|
+
component.get_source(workdir)
|
172
|
+
end
|
168
173
|
# Fetch secondary sources
|
169
|
-
|
170
|
-
|
174
|
+
Vanagon::Utilities.retry_with_timeout(retry_count, timeout) do
|
175
|
+
component.get_sources(workdir)
|
176
|
+
end
|
177
|
+
Vanagon::Utilities.retry_with_timeout(retry_count, timeout) do
|
178
|
+
component.get_patches(workdir)
|
179
|
+
end
|
171
180
|
end
|
172
181
|
end
|
173
182
|
|
@@ -12,6 +12,7 @@ describe "Vanagon::Component::Source" do
|
|
12
12
|
let(:private_git) { "git@github.com:abcd/things" }
|
13
13
|
let(:http_git) { "http://github.com/abcd/things" }
|
14
14
|
let(:https_git) { "https://github.com/abcd/things" }
|
15
|
+
let(:git_prefixed_http) { "git:http://github.com/abcd/things" }
|
15
16
|
|
16
17
|
let(:http_url) { "http://abcd/things" }
|
17
18
|
let(:https_url) { "https://abcd/things" }
|
@@ -53,8 +54,9 @@ describe "Vanagon::Component::Source" do
|
|
53
54
|
end
|
54
55
|
|
55
56
|
it "returns a Git object for git:// repositories" do
|
56
|
-
|
57
|
-
|
57
|
+
component_source = klass.source(public_git, ref: ref, workdir: workdir)
|
58
|
+
expect(component_source.url.to_s).to eq public_git
|
59
|
+
expect(component_source.class).to eq Vanagon::Component::Source::Git
|
58
60
|
end
|
59
61
|
|
60
62
|
it "returns a Git object for http:// repositories" do
|
@@ -66,6 +68,13 @@ describe "Vanagon::Component::Source" do
|
|
66
68
|
expect(klass.source(https_git, ref: ref, workdir: workdir).class)
|
67
69
|
.to eq Vanagon::Component::Source::Git
|
68
70
|
end
|
71
|
+
|
72
|
+
it "returns a Git object for git:http:// repositories" do
|
73
|
+
component_source = klass.source(git_prefixed_http, ref: ref, workdir: workdir)
|
74
|
+
expect(component_source.url.to_s).to eq 'http://github.com/abcd/things'
|
75
|
+
expect(component_source.class).to eq Vanagon::Component::Source::Git
|
76
|
+
end
|
77
|
+
|
69
78
|
end
|
70
79
|
|
71
80
|
context "takes a HTTP/HTTPS file" do
|
@@ -3,7 +3,7 @@ require 'vanagon/project'
|
|
3
3
|
require 'vanagon/platform'
|
4
4
|
|
5
5
|
describe 'Vanagon::Driver' do
|
6
|
-
let (:project) { double(:project, :settings => {} ) }
|
6
|
+
let (:project) { double(:project, :settings => {}, :timeout => 9001, :retry_count => 42 ) }
|
7
7
|
|
8
8
|
let (:redhat) do
|
9
9
|
eval_platform('el-7-x86_64', <<-END)
|
@@ -4,6 +4,7 @@ describe 'Vanagon::Platform::DSL' do
|
|
4
4
|
let (:deb_platform_block) { "platform 'debian-test-fixture' do |plat| end" }
|
5
5
|
let (:el_5_platform_block) { "platform 'el-5-fixture' do |plat| end" }
|
6
6
|
let (:el_6_platform_block) { "platform 'el-6-fixture' do |plat| end" }
|
7
|
+
let (:redhat_7_platform_block) { "platform 'redhat-7-fixture' do |plat| end" }
|
7
8
|
let (:sles_platform_block) { "platform 'sles-test-fixture' do |plat| end" }
|
8
9
|
let (:cicso_wrlinux_platform_block) { "platform 'cisco-wrlinux-fixture' do |plat| end" }
|
9
10
|
let (:solaris_10_platform_block) { "platform 'solaris-10-fixture' do |plat| end" }
|
@@ -60,6 +61,14 @@ describe 'Vanagon::Platform::DSL' do
|
|
60
61
|
expect(plat._platform.provisioning).to include("curl -o '/etc/yum.repos.d/#{hex_value}-pl-puppet-agent-0.2.1-el-7-x86_64.repo' '#{el_definition}'")
|
61
62
|
end
|
62
63
|
|
64
|
+
it "works for specifically redhat platforms" do
|
65
|
+
plat = Vanagon::Platform::DSL.new('redhat-7-fixture')
|
66
|
+
expect(SecureRandom).to receive(:hex).and_return(hex_value)
|
67
|
+
plat.instance_eval(redhat_7_platform_block)
|
68
|
+
plat.yum_repo(el_definition)
|
69
|
+
expect(plat._platform.provisioning).to include("curl -o '/etc/yum.repos.d/#{hex_value}-pl-puppet-agent-0.2.1-el-7-x86_64.repo' '#{el_definition}'")
|
70
|
+
end
|
71
|
+
|
63
72
|
# This test currently covers wrlinux 5 and 7
|
64
73
|
it "downloads the repo file to the correct yum location for wrlinux" do
|
65
74
|
plat = Vanagon::Platform::DSL.new('cisco-wrlinux-fixture')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vanagon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet Labs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|