vanagon 0.38.0 → 0.39.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fe169a867215743c1234c1dc7611f6747040505867c94f05379e2e789e1ef22
|
4
|
+
data.tar.gz: d663402a3ff359291b83a970e59ea8e9ce3b3101ba1a5d443e38b2372018ffa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c58c68372fb374b8ea3d3d016473e32bc41d76632f42dd76bcdef99a375b8758198fd1b193231932746d8c219cce8131817a43bc4c2597f8be2477c52f02d3f
|
7
|
+
data.tar.gz: 18e74e97521b6db5596d746ff6628f932bdfd0b69670987588063a8f6b688a4ce3e0bfcd9d2f6159af68f5f9c3a47a2336267a928e10e0adf35d3e7b4cdd9f29
|
@@ -60,6 +60,7 @@ class Vanagon
|
|
60
60
|
# VANAGON-227 We need to be careful when guessing whether a https://github.com/...
|
61
61
|
# URL is actually a true git repo. Make some rules around it based on the github API.
|
62
62
|
# Decide that anything with a documented media_type is just an http url.
|
63
|
+
# We do this instead of talking to GitHub directly to avoid rate limiting.
|
63
64
|
# See:
|
64
65
|
# https://docs.github.com/en/repositories/working-with-files/using-files/downloading-source-code-archives
|
65
66
|
# https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#download-a-repository-archive-tar
|
@@ -68,17 +69,13 @@ class Vanagon
|
|
68
69
|
url_directory = url.to_s.delete_prefix(github_url_prefix)
|
69
70
|
url_components = url_directory.split('/')
|
70
71
|
|
71
|
-
return :github_remote if url_directory.end_with?('.git')
|
72
|
-
|
73
72
|
# Find cases of supported github media types.
|
74
73
|
# [ owner, repo, media_type, ref ]
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
:
|
80
|
-
when 'zipball'
|
81
|
-
:github_zipball
|
74
|
+
path_types = ['archive', 'releases', 'tarball', 'zipball']
|
75
|
+
if path_types.include?(url_components[2]) ||
|
76
|
+
url_components[-1].end_with?('.tar.gz') ||
|
77
|
+
url_components[-1].end_with?('.zip')
|
78
|
+
:github_media
|
82
79
|
else
|
83
80
|
:github_remote
|
84
81
|
end
|
@@ -22,20 +22,19 @@ class Vanagon
|
|
22
22
|
return false unless ['http', 'https'].include? uri.scheme
|
23
23
|
|
24
24
|
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
25
|
-
http.request(Net::HTTP::Head.new(uri))
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
25
|
+
response = http.request(Net::HTTP::Head.new(uri))
|
26
|
+
case response
|
27
|
+
when Net::HTTPRedirection
|
28
|
+
# By parsing the location header, we get either an absolute
|
29
|
+
# URI or a URI with a relative `path`. Adding it to `uri`
|
30
|
+
# should correctly update the relative `path` or overwrite
|
31
|
+
# the entire URI if it's absolute.
|
32
|
+
location = URI.parse(response.header['location'])
|
33
|
+
valid_url?(uri + location)
|
34
|
+
when Net::HTTPSuccess
|
35
|
+
true
|
36
|
+
else
|
37
|
+
false
|
39
38
|
end
|
40
39
|
end
|
41
40
|
end
|
data/lib/vanagon/platform/dsl.rb
CHANGED
@@ -18,7 +18,7 @@ class Vanagon
|
|
18
18
|
class DSL
|
19
19
|
# Constructor for the DSL object
|
20
20
|
#
|
21
|
-
# @param
|
21
|
+
# @param platform_name [String] name of the platform
|
22
22
|
# @return [Vanagon::Platform::DSL] A DSL object to describe the {Vanagon::Platform}
|
23
23
|
def initialize(platform_name)
|
24
24
|
@name = platform_name
|
@@ -26,9 +26,15 @@ class Vanagon
|
|
26
26
|
|
27
27
|
# Primary way of interacting with the DSL. Also a simple factory to get the right platform object.
|
28
28
|
#
|
29
|
-
# @param
|
29
|
+
# @param platform_name [String] name of the platform
|
30
|
+
# @param override_name [Boolean] whether the specified `platform_name` should override the basename
|
30
31
|
# @param block [Proc] DSL definition of the platform to call
|
31
|
-
def platform(platform_name, &block)
|
32
|
+
def platform(platform_name, override_name: false, &block)
|
33
|
+
# By default, the Vanagon::Platform's name/version/arch will be based on
|
34
|
+
# the filename of the platform definition. But if override_name is true,
|
35
|
+
# then use the `platform_name` passed into this method instead.
|
36
|
+
@name = platform_name if override_name
|
37
|
+
|
32
38
|
@platform = case platform_name
|
33
39
|
when /^aix-/
|
34
40
|
Vanagon::Platform::RPM::AIX.new(@name)
|
@@ -15,12 +15,27 @@ describe "Vanagon::Component::Source::Git" do
|
|
15
15
|
let(:github_archive_uri) do
|
16
16
|
'https://github.com/2ndQuadrant/pglogical/archive/a_file_name.tar.gz'
|
17
17
|
end
|
18
|
+
let(:github_releases_uri) do
|
19
|
+
'https://github.com/libffi/libffi/releases/download/v3.4.3/libffi-3.4.3.tar.gz'
|
20
|
+
end
|
18
21
|
let(:github_tarball_uri) do
|
19
22
|
'https://github.com/Baeldung/kotlin-tutorials/tarball/main'
|
20
23
|
end
|
21
24
|
let(:github_zipball_uri) do
|
22
25
|
'https://github.com/Baeldung/kotlin-tutorials/zipball/master'
|
23
26
|
end
|
27
|
+
let(:github_actual_tarball_uri) do
|
28
|
+
'https://github.com/puppetlabs/puppet/archive/refs/tags/8.2.0.tar.gz'
|
29
|
+
end
|
30
|
+
let(:github_actual_tarball_with_unexpected_path_uri) do
|
31
|
+
'https://github.com/puppetlabs/puppet/something/refs/tags/8.2.0.tar.gz'
|
32
|
+
end
|
33
|
+
let(:github_actual_zipball_uri) do
|
34
|
+
'https://github.com/puppetlabs/puppet/archive/refs/tags/8.2.0.zip'
|
35
|
+
end
|
36
|
+
let(:github_actual_zipball_with_unexpected_path_uri) do
|
37
|
+
'https://github.com/puppetlabs/puppet/something/refs/tags/8.2.0.zip'
|
38
|
+
end
|
24
39
|
let(:github_repo_uri) do
|
25
40
|
'https://github.com/cameronmcnz/rock-paper-scissors'
|
26
41
|
end
|
@@ -32,14 +47,34 @@ describe "Vanagon::Component::Source::Git" do
|
|
32
47
|
expect(Vanagon::Component::Source::Git.valid_remote?(github_archive_uri)).to be false
|
33
48
|
end
|
34
49
|
|
50
|
+
it "flags github releases uris as not valid repos" do
|
51
|
+
expect(Vanagon::Component::Source::Git.valid_remote?(github_releases_uri)).to be false
|
52
|
+
end
|
53
|
+
|
35
54
|
it "flags github tarball uris as not valid repos" do
|
36
55
|
expect(Vanagon::Component::Source::Git.valid_remote?(github_tarball_uri)).to be false
|
37
56
|
end
|
38
57
|
|
58
|
+
it "flags github actual tarball uris as not valid repos" do
|
59
|
+
expect(Vanagon::Component::Source::Git.valid_remote?(github_actual_tarball_uri)).to be false
|
60
|
+
end
|
61
|
+
|
62
|
+
it "flags github actual tarball uris with an unexpected path as not valid repos" do
|
63
|
+
expect(Vanagon::Component::Source::Git.valid_remote?(github_actual_tarball_with_unexpected_path_uri)).to be false
|
64
|
+
end
|
65
|
+
|
39
66
|
it "flags git zipball uris as not valid repos" do
|
40
67
|
expect(Vanagon::Component::Source::Git.valid_remote?(github_zipball_uri)).to be false
|
41
68
|
end
|
42
69
|
|
70
|
+
it "flags github actual tarball uris as not valid repos" do
|
71
|
+
expect(Vanagon::Component::Source::Git.valid_remote?(github_actual_zipball_uri)).to be false
|
72
|
+
end
|
73
|
+
|
74
|
+
it "flags github actual tarball uris with an unexpected path as not valid repos" do
|
75
|
+
expect(Vanagon::Component::Source::Git.valid_remote?(github_actual_zipball_with_unexpected_path_uri)).to be false
|
76
|
+
end
|
77
|
+
|
43
78
|
it "identifies git generic uris as valid repos" do
|
44
79
|
expect(Vanagon::Component::Source::Git.valid_remote?(github_repo_uri)).to be true
|
45
80
|
end
|
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.
|
4
|
+
version: 0.39.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet By Perforce
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docopt
|