librarian-puppet 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -11
- data/lib/librarian/puppet/cli.rb +2 -0
- data/lib/librarian/puppet/environment.rb +3 -0
- data/lib/librarian/puppet/extension.rb +16 -2
- data/lib/librarian/puppet/lockfile/parser.rb +5 -3
- data/lib/librarian/puppet/source/forge.rb +3 -2
- data/lib/librarian/puppet/source/forge/repo.rb +1 -1
- data/lib/librarian/puppet/source/forge/repo_v1.rb +12 -1
- data/lib/librarian/puppet/source/forge/repo_v3.rb +2 -2
- data/lib/librarian/puppet/source/githubtarball.rb +1 -1
- data/lib/librarian/puppet/source/githubtarball/repo.rb +12 -6
- data/lib/librarian/puppet/source/local.rb +3 -3
- data/lib/librarian/puppet/source/repo.rb +1 -1
- data/lib/librarian/puppet/templates/Puppetfile +4 -4
- data/lib/librarian/puppet/util.rb +5 -0
- data/lib/librarian/puppet/version.rb +1 -1
- 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: 00ea6603b1c515215bb1f55bccc63bb1cc9a43fa
|
4
|
+
data.tar.gz: 369d915e3047152dac00490e1a80234bd80e1f61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34438184c66b52a657452b3980715830e66afa94f26329785ac4d6de0e0de6f293b8e42c054264569872f56874aeb02a865d3652196049e4e716d96c10cb8d36
|
7
|
+
data.tar.gz: c06ea15a7cd05b84193ea63703c2c7ee56cb52da1b5fa8816ccda61dfc45a1842ced0806a1f864cf805bc8a93a8b06e8157e3f588eb8cffb6785330e285e3473
|
data/README.md
CHANGED
@@ -28,6 +28,13 @@ It is based on [Librarian](https://github.com/applicationsonline/librarian), a
|
|
28
28
|
framework for writing bundlers, which are tools that resolve, fetch, install,
|
29
29
|
and isolate a project's dependencies.
|
30
30
|
|
31
|
+
## Versions
|
32
|
+
|
33
|
+
Librarian-puppet >= 1.1.0 requires Ruby 1.9 and uses the Puppet Forge API v3.
|
34
|
+
Versions < 1.1.0 works on Ruby 1.8.
|
35
|
+
|
36
|
+
See the [Changelog](Changelog.md) for more details.
|
37
|
+
|
31
38
|
## The Puppetfile
|
32
39
|
|
33
40
|
Every Puppet repository that uses Librarian-puppet will have a file named
|
@@ -47,16 +54,16 @@ This Puppetfile will download all the dependencies listed in your Modulefile fro
|
|
47
54
|
|
48
55
|
forge "https://forge.puppetlabs.com"
|
49
56
|
|
50
|
-
mod
|
51
|
-
mod
|
57
|
+
mod 'puppetlabs-razor'
|
58
|
+
mod 'puppetlabs-ntp', "0.0.3"
|
52
59
|
|
53
|
-
mod
|
60
|
+
mod 'puppetlabs-apt',
|
54
61
|
:git => "git://github.com/puppetlabs/puppetlabs-apt.git"
|
55
62
|
|
56
|
-
mod
|
63
|
+
mod 'puppetlabs-stdlib',
|
57
64
|
:git => "git://github.com/puppetlabs/puppetlabs-stdlib.git"
|
58
65
|
|
59
|
-
mod 'puppetlabs
|
66
|
+
mod 'puppetlabs-apache', '0.6.0',
|
60
67
|
:github_tarball => 'puppetlabs/puppetlabs-apache'
|
61
68
|
|
62
69
|
|
@@ -73,29 +80,29 @@ This declares that we want to use the official Puppet Labs Forge as our default
|
|
73
80
|
source when pulling down modules. If you run your own local forge, you may
|
74
81
|
want to change this.
|
75
82
|
|
76
|
-
mod
|
83
|
+
mod 'puppetlabs-razor'
|
77
84
|
|
78
85
|
Pull in the latest version of the Puppet Labs Razor module from the default
|
79
86
|
source.
|
80
87
|
|
81
|
-
mod
|
88
|
+
mod 'puppetlabs-ntp', "0.0.3"
|
82
89
|
|
83
90
|
Pull in version 0.0.3 of the Puppet Labs NTP module from the default source.
|
84
91
|
|
85
|
-
mod
|
92
|
+
mod 'puppetlabs-apt',
|
86
93
|
:git => "git://github.com/puppetlabs/puppetlabs-apt.git"
|
87
94
|
|
88
95
|
Our puppet infrastructure repository depends on the `apt` module from the
|
89
96
|
Puppet Labs GitHub repos and checks out the `master` branch.
|
90
97
|
|
91
|
-
mod
|
98
|
+
mod 'puppetlabs-apt',
|
92
99
|
:git => "git://github.com/puppetlabs/puppetlabs-apt.git",
|
93
100
|
:ref => '0.0.3'
|
94
101
|
|
95
102
|
Our puppet infrastructure repository depends on the `apt` module from the
|
96
103
|
Puppet Labs GitHub repos and checks out a tag of `0.0.3`.
|
97
104
|
|
98
|
-
mod
|
105
|
+
mod 'puppetlabs-apt',
|
99
106
|
:git => "git://github.com/puppetlabs/puppetlabs-apt.git",
|
100
107
|
:ref => 'feature/master/dans_refactor'
|
101
108
|
|
@@ -117,7 +124,7 @@ with many modules in it. If we need a module from such a repository, we can
|
|
117
124
|
use the `:path =>` option here to help Librarian-puppet drill down and find the
|
118
125
|
module subdirectory.
|
119
126
|
|
120
|
-
mod
|
127
|
+
mod 'puppetlabs-apt',
|
121
128
|
:git => "git://github.com/fake/puppet-modules.git",
|
122
129
|
:path => "modules/apt"
|
123
130
|
|
@@ -154,6 +161,14 @@ source specified. This command writes the complete resolution into
|
|
154
161
|
`Puppetfile.lock` and then copies all of the fetched modules into your
|
155
162
|
`modules/` directory, overwriting whatever was there before.
|
156
163
|
|
164
|
+
Librarian-puppet support both v1 and v3 of the Puppet Forge API.
|
165
|
+
Specify a specific API version when installing modules:
|
166
|
+
|
167
|
+
$ librarian-puppet install --use-v1-api # this is default
|
168
|
+
$ librarian-puppet install --no-use-v1-api # use the v3 API
|
169
|
+
|
170
|
+
Please note that this does not apply for the official Puppet Forge where v3 is used by default.
|
171
|
+
|
157
172
|
Get an overview of your `Puppetfile.lock` with:
|
158
173
|
|
159
174
|
$ librarian-puppet show
|
data/lib/librarian/puppet/cli.rb
CHANGED
@@ -44,6 +44,7 @@ module Librarian
|
|
44
44
|
option "path", :type => :string
|
45
45
|
option "destructive", :type => :boolean, :default => false
|
46
46
|
option "local", :type => :boolean, :default => false
|
47
|
+
option "use-v1-api", :type => :boolean, :default => true
|
47
48
|
def install
|
48
49
|
|
49
50
|
unless File.exist?('Puppetfile')
|
@@ -64,6 +65,7 @@ module Librarian
|
|
64
65
|
environment.config_db.local["path"] = options["path"]
|
65
66
|
end
|
66
67
|
|
68
|
+
environment.config_db.local['use-v1-api'] = options['use-v1-api'] ? '1' : nil
|
67
69
|
environment.config_db.local['mode'] = options['local'] ? 'local' : nil
|
68
70
|
|
69
71
|
resolve!
|
@@ -8,6 +8,19 @@ module Librarian
|
|
8
8
|
end
|
9
9
|
|
10
10
|
class Dependency
|
11
|
+
include Librarian::Puppet::Util
|
12
|
+
|
13
|
+
def initialize(name, requirement, source)
|
14
|
+
assert_name_valid! name
|
15
|
+
|
16
|
+
# let's settle on provider-module syntax instead of provider/module
|
17
|
+
self.name = normalize_name(name)
|
18
|
+
self.requirement = Requirement.new(requirement)
|
19
|
+
self.source = source
|
20
|
+
|
21
|
+
@manifests = nil
|
22
|
+
end
|
23
|
+
|
11
24
|
class Requirement
|
12
25
|
def initialize(*args)
|
13
26
|
args = initialize_normalize_args(args)
|
@@ -84,6 +97,8 @@ module Librarian
|
|
84
97
|
end
|
85
98
|
|
86
99
|
class ManifestSet
|
100
|
+
include Librarian::Puppet::Util
|
101
|
+
|
87
102
|
private
|
88
103
|
|
89
104
|
# Check if module doesn't exist and fail fast
|
@@ -93,7 +108,7 @@ module Librarian
|
|
93
108
|
|
94
109
|
deps = Set.new
|
95
110
|
until names.empty?
|
96
|
-
name = names.shift
|
111
|
+
name = normalize_name(names.shift)
|
97
112
|
next if deps.include?(name)
|
98
113
|
|
99
114
|
deps << name
|
@@ -105,7 +120,6 @@ module Librarian
|
|
105
120
|
end
|
106
121
|
|
107
122
|
class Manifest
|
108
|
-
|
109
123
|
class PreReleaseVersion
|
110
124
|
|
111
125
|
# Compares pre-release component ids using Semver 2.0.0 spec
|
@@ -5,6 +5,7 @@ require 'librarian/manifest_set'
|
|
5
5
|
module Librarian
|
6
6
|
class Lockfile
|
7
7
|
class Parser
|
8
|
+
include Librarian::Puppet::Util
|
8
9
|
|
9
10
|
def parse(string)
|
10
11
|
string = string.dup
|
@@ -26,8 +27,8 @@ module Librarian
|
|
26
27
|
manifests = {}
|
27
28
|
while lines.first =~ /^ {4}([\w\-\/]+) \((.*)\)$/ # This change allows forward slash
|
28
29
|
lines.shift
|
29
|
-
name = $1
|
30
|
-
manifests[name] = {:version =>
|
30
|
+
name, version = normalize_name($1), $2
|
31
|
+
manifests[name] = {:version => version, :dependencies => {}}
|
31
32
|
while lines.first =~ /^ {6}([\w\-\/]+) \((.*)\)$/
|
32
33
|
lines.shift
|
33
34
|
manifests[name][:dependencies][$1] = $2.split(/,\s*/)
|
@@ -42,9 +43,10 @@ module Librarian
|
|
42
43
|
dependencies = []
|
43
44
|
while lines.first =~ /^ {2}([\w\-\/]+)(?: \((.*)\))?$/ # This change allows forward slash
|
44
45
|
lines.shift
|
45
|
-
name, requirement = $1, $2.split(/,\s*/)
|
46
|
+
name, requirement = normalize_name($1), $2.split(/,\s*/)
|
46
47
|
dependencies << Dependency.new(name, requirement, manifests_index[name].source)
|
47
48
|
end
|
49
|
+
|
48
50
|
Resolution.new(dependencies, manifests)
|
49
51
|
end
|
50
52
|
|
@@ -121,7 +121,7 @@ module Librarian
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def install_path(name)
|
124
|
-
environment.install_path.join(name.split('
|
124
|
+
environment.install_path.join(name.split('-').last)
|
125
125
|
end
|
126
126
|
|
127
127
|
def fetch_version(name, version_uri)
|
@@ -148,9 +148,10 @@ module Librarian
|
|
148
148
|
|
149
149
|
def repo(name)
|
150
150
|
@repo ||= {}
|
151
|
+
|
151
152
|
unless @repo[name]
|
152
153
|
# if we are using the official Forge then use API v3, otherwise stick to v1 for now
|
153
|
-
# if uri.hostname =~ /\.puppetlabs\.com$/
|
154
|
+
# if uri.hostname =~ /\.puppetlabs\.com$/ || !environment.use_v1_api
|
154
155
|
# @repo[name] = RepoV3.new(self, name)
|
155
156
|
# else
|
156
157
|
@repo[name] = RepoV1.new(self, name)
|
@@ -59,7 +59,7 @@ module Librarian
|
|
59
59
|
install_path.rmtree
|
60
60
|
end
|
61
61
|
|
62
|
-
unpacked_path = version_unpacked_cache_path(version).join(name.split('
|
62
|
+
unpacked_path = version_unpacked_cache_path(version).join(name.split('-').last)
|
63
63
|
|
64
64
|
unless unpacked_path.exist?
|
65
65
|
raise Error, "#{unpacked_path} does not exist, something went wrong. Try removing it manually"
|
@@ -34,11 +34,15 @@ module Librarian
|
|
34
34
|
private
|
35
35
|
|
36
36
|
# Issue #223 dependencies may be duplicated
|
37
|
+
# and convert organization/modulename to organization-modulename
|
37
38
|
def clear_duplicated_dependencies(data)
|
38
39
|
return nil if data.nil?
|
39
40
|
data.each do |m,versions|
|
40
41
|
versions.each do |v|
|
41
42
|
if v["dependencies"] and !v["dependencies"].empty?
|
43
|
+
# convert organization/modulename to organization-modulename
|
44
|
+
v["dependencies"].each {|d| d[0] = normalize_name(d[0])}
|
45
|
+
|
42
46
|
dependency_names = v["dependencies"].map {|d| d[0]}
|
43
47
|
duplicated = dependency_names.select{ |e| dependency_names.count(e) > 1 }
|
44
48
|
unless duplicated.empty?
|
@@ -53,6 +57,13 @@ module Librarian
|
|
53
57
|
end
|
54
58
|
end
|
55
59
|
end
|
60
|
+
# convert organization/modulename to organization-modulename
|
61
|
+
data.keys.each do |m|
|
62
|
+
if m =~ %r{.*/.*}
|
63
|
+
data[normalize_name(m)] = data[m]
|
64
|
+
data.delete(m)
|
65
|
+
end
|
66
|
+
end
|
56
67
|
data
|
57
68
|
end
|
58
69
|
|
@@ -79,7 +90,7 @@ module Librarian
|
|
79
90
|
def api_call(module_name, version=nil)
|
80
91
|
url = source.uri.clone
|
81
92
|
url.path += "#{'/' if url.path.empty? or url.path[-1] != '/'}api/v1/releases.json"
|
82
|
-
url.query = "module=#{module_name}"
|
93
|
+
url.query = "module=#{module_name.sub('-','/')}" # v1 API expects "organization/module"
|
83
94
|
url.query += "&version=#{version}" unless version.nil?
|
84
95
|
debug { "Querying Forge API for module #{name}#{" and version #{version}" unless version.nil?}: #{url}" }
|
85
96
|
|
@@ -25,7 +25,7 @@ module Librarian
|
|
25
25
|
else
|
26
26
|
# should never get here as we use one repo object for each module (to be changed in the future)
|
27
27
|
debug { "Looking up url for #{name}@#{version}" }
|
28
|
-
release = PuppetForge::Release.find("#{name
|
28
|
+
release = PuppetForge::Release.find("#{name}-#{version}")
|
29
29
|
end
|
30
30
|
"#{source}#{release.file_uri}"
|
31
31
|
end
|
@@ -33,7 +33,7 @@ module Librarian
|
|
33
33
|
private
|
34
34
|
|
35
35
|
def get_module
|
36
|
-
@module ||= PuppetForge::Module.find(name
|
36
|
+
@module ||= PuppetForge::Module.find(name)
|
37
37
|
raise(Error, "Unable to find module '#{name}' on #{source}") unless @module
|
38
38
|
@module
|
39
39
|
end
|
@@ -40,11 +40,11 @@ module Librarian
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def install_version!(version, install_path)
|
43
|
-
if environment.local? && !vendored?(
|
43
|
+
if environment.local? && !vendored?(vendored_name, version)
|
44
44
|
raise Error, "Could not find a local copy of #{source.uri} at #{version}."
|
45
45
|
end
|
46
46
|
|
47
|
-
vendor_cache(source.uri.to_s, version) unless vendored?(
|
47
|
+
vendor_cache(source.uri.to_s, version) unless vendored?(vendored_name, version)
|
48
48
|
|
49
49
|
cache_version_unpacked! version
|
50
50
|
|
@@ -62,19 +62,19 @@ module Librarian
|
|
62
62
|
|
63
63
|
path.mkpath
|
64
64
|
|
65
|
-
target = vendored?(
|
65
|
+
target = vendored?(vendored_name, version) ? vendored_path(vendored_name, version) : name
|
66
66
|
|
67
67
|
Librarian::Posix.run!(%W{tar xzf #{target} -C #{path}})
|
68
68
|
end
|
69
69
|
|
70
70
|
def vendor_cache(name, version)
|
71
|
-
clean_up_old_cached_versions(name)
|
71
|
+
clean_up_old_cached_versions(vendored_name(name))
|
72
72
|
|
73
73
|
url = "https://api.github.com/repos/#{name}/tarball/#{version}"
|
74
74
|
add_api_token_to_url(url)
|
75
75
|
|
76
76
|
environment.vendor!
|
77
|
-
File.open(vendored_path(name, version).to_s, 'wb') do |f|
|
77
|
+
File.open(vendored_path(vendored_name(name), version).to_s, 'wb') do |f|
|
78
78
|
begin
|
79
79
|
debug { "Downloading <#{url}> to <#{f.path}>" }
|
80
80
|
open(url,
|
@@ -90,7 +90,7 @@ module Librarian
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def clean_up_old_cached_versions(name)
|
93
|
-
Dir["#{environment.vendor_cache}/#{name
|
93
|
+
Dir["#{environment.vendor_cache}/#{name}*.tar.gz"].each do |old_version|
|
94
94
|
FileUtils.rm old_version
|
95
95
|
end
|
96
96
|
end
|
@@ -106,6 +106,8 @@ module Librarian
|
|
106
106
|
def add_api_token_to_url url
|
107
107
|
if token_key_nil?
|
108
108
|
debug { "#{TOKEN_KEY} environment value is empty or missing" }
|
109
|
+
elsif url.include? "?"
|
110
|
+
url << "&access_token=#{ENV[TOKEN_KEY]}"
|
109
111
|
else
|
110
112
|
url << "?access_token=#{ENV[TOKEN_KEY]}"
|
111
113
|
end
|
@@ -159,6 +161,10 @@ module Librarian
|
|
159
161
|
options[:headers].each { |k, v| request.add_field k, v }
|
160
162
|
http.request(request)
|
161
163
|
end
|
164
|
+
|
165
|
+
def vendored_name(name = source.uri.to_s)
|
166
|
+
name.sub('/','-')
|
167
|
+
end
|
162
168
|
end
|
163
169
|
end
|
164
170
|
end
|
@@ -26,11 +26,11 @@ module Librarian
|
|
26
26
|
found_path = found_path(name)
|
27
27
|
raise Error, "Path for #{name} doesn't contain a puppet module" if found_path.nil?
|
28
28
|
|
29
|
-
unless name.include? '/'
|
30
|
-
warn { "Invalid module name '#{name}', you should qualify it with 'ORGANIZATION
|
29
|
+
unless name.include? '/' or name.include? '-'
|
30
|
+
warn { "Invalid module name '#{name}', you should qualify it with 'ORGANIZATION-#{name}' for resolution to work correctly" }
|
31
31
|
end
|
32
32
|
|
33
|
-
install_path = environment.install_path.join(name.split('
|
33
|
+
install_path = environment.install_path.join(name.split('-').last)
|
34
34
|
if install_path.exist?
|
35
35
|
debug { "Deleting #{relative_path_to(install_path)}" }
|
36
36
|
install_path.rmtree
|
@@ -7,16 +7,16 @@ forge "https://forgeapi.puppetlabs.com"
|
|
7
7
|
modulefile
|
8
8
|
|
9
9
|
# A module from the Puppet Forge
|
10
|
-
# mod 'puppetlabs
|
10
|
+
# mod 'puppetlabs-stdlib'
|
11
11
|
|
12
12
|
# A module from git
|
13
|
-
# mod 'puppetlabs
|
13
|
+
# mod 'puppetlabs-ntp',
|
14
14
|
# :git => 'git://github.com/puppetlabs/puppetlabs-ntp.git'
|
15
15
|
|
16
16
|
# A module from a git branch/tag
|
17
|
-
# mod 'puppetlabs
|
17
|
+
# mod 'puppetlabs-apt',
|
18
18
|
# :git => 'https://github.com/puppetlabs/puppetlabs-apt.git',
|
19
19
|
# :ref => '1.4.x'
|
20
20
|
|
21
21
|
# A module from Github pre-packaged tarball
|
22
|
-
# mod 'puppetlabs
|
22
|
+
# mod 'puppetlabs-apache', '0.6.0', :github_tarball => 'puppetlabs/puppetlabs-apache'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: librarian-puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Sharpe
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-07-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: librarian
|