puppetfiler 0.1.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 +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +16 -0
- data/TODO +16 -0
- data/bin/console +7 -0
- data/bin/setup +8 -0
- data/exe/puppetfiler +5 -0
- data/lib/puppetfiler.rb +4 -0
- data/lib/puppetfiler/cli.rb +36 -0
- data/lib/puppetfiler/mod.rb +12 -0
- data/lib/puppetfiler/puppetfile.rb +105 -0
- data/lib/puppetfiler/version.rb +3 -0
- data/puppetfiler.gemspec +33 -0
- metadata +188 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4a9dee90116b58575cd3fbd7cefd0f87b97a1f4b
|
4
|
+
data.tar.gz: c1c10e1e4625aae2faa715cb68bdf71f5f217afd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b4ffa27b7e7416062d73074cc7d29d4b0fc9444c5263a1389c40423618bebf7cbe56bc98bc8e91a5222cfa30b8a7705e81c89f2a1b830649c372a36acaf41e38
|
7
|
+
data.tar.gz: c66ec34b0544b7dadc39c9e0af2f6ba96039d92780e457b9131015da1d72d55684c625ac8d8e24a79e2d5440d200baac0dca3153fd8a2473e5a10d81d3469699
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Nelo Wallus
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Puppetfiler
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/puppetfiler`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'puppetfiler'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install puppetfiler
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/puppetfiler.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'cucumber'
|
4
|
+
require 'cucumber/rake/task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
9
|
+
t.cucumber_opts = 'features --format pretty'
|
10
|
+
end
|
11
|
+
|
12
|
+
task :default do
|
13
|
+
%i{spec features}.each do |task|
|
14
|
+
Rake::Task[task].invoke
|
15
|
+
end
|
16
|
+
end
|
data/TODO
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
* Validity check of dependencies noted in a metaparam.json against an
|
2
|
+
environments Puppetfile
|
3
|
+
metaparam.json should be a required parameter with no default
|
4
|
+
|
5
|
+
Also possible would be to find all metaparam.json's below the dirname
|
6
|
+
of the given Puppetfile, matching against those
|
7
|
+
|
8
|
+
On the other hand many keep their local clones of modules beside the
|
9
|
+
environment, which'd favor matching against found metaparams below the
|
10
|
+
current path
|
11
|
+
|
12
|
+
* Building of .fixtures.yml for modules based on the metadata
|
13
|
+
I did something similar on my modulesync config[1], however having it
|
14
|
+
this way and called via a rake task might be favorable
|
15
|
+
|
16
|
+
[1]: https://github.com/ntnn/modulesync-cfg/blob/master/moduleroot/.fixtures.yml
|
data/bin/console
ADDED
data/bin/setup
ADDED
data/exe/puppetfiler
ADDED
data/lib/puppetfiler.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'puppetfiler/puppetfile'
|
3
|
+
require 'puppetfiler/version'
|
4
|
+
|
5
|
+
module Puppetfiler
|
6
|
+
class CLI < Thor
|
7
|
+
desc 'check [puppetfile]', 'Check forge for newer versions of used forge modules'
|
8
|
+
def check(puppetfile = 'Puppetfile')
|
9
|
+
pf = Puppetfiler::Puppetfile.new(puppetfile)
|
10
|
+
format = "% -#{pf.maxlen_name}s % -#{pf.maxlen_ver}s %s"
|
11
|
+
|
12
|
+
puts sprintf(format, 'module', 'current', 'newest')
|
13
|
+
|
14
|
+
pf.updates.each do |name, hash|
|
15
|
+
puts sprintf(format, name, hash[:current], hash[:newest])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'fixture [puppetfile]', 'Create puppetlabs_spec_helper compatible .fixtures.yml from puppetfile'
|
20
|
+
method_option :stdout, :aliases => '-o'
|
21
|
+
def fixture(puppetfile = 'Puppetfile')
|
22
|
+
f = Puppetfiler::Puppetfile.new(puppetfile).fixture
|
23
|
+
|
24
|
+
if options[:stdout]
|
25
|
+
puts f
|
26
|
+
else
|
27
|
+
File.write('.fixtures.yml', f)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'version', 'Output version'
|
32
|
+
def version
|
33
|
+
puts "puppetfiler v#{Puppetfiler::VERSION}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'puppet_forge'
|
2
|
+
require 'semantic_puppet'
|
3
|
+
|
4
|
+
module Puppetfiler
|
5
|
+
class Mod
|
6
|
+
def self.newest(name)
|
7
|
+
mod = PuppetForge::Module.find(name.gsub('/', '-'))
|
8
|
+
version = mod.current_release.version
|
9
|
+
return SemanticPuppet::Version.parse(version)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'puppetfiler/mod'
|
3
|
+
|
4
|
+
module Puppetfiler
|
5
|
+
class Puppetfile
|
6
|
+
def initialize(path = 'Puppetfile')
|
7
|
+
@modules = {}
|
8
|
+
@repos = {}
|
9
|
+
@puppetfile = path
|
10
|
+
|
11
|
+
@maxlen_name = 0
|
12
|
+
@maxlen_ver = 0
|
13
|
+
|
14
|
+
# TODO heredocs are ugly, maybe ruby has a way to store them
|
15
|
+
# elsewhere as .erb
|
16
|
+
# Also omit forge_modules/repositories if the referring key is
|
17
|
+
# empty
|
18
|
+
@fixture_template = <<-EOT
|
19
|
+
---
|
20
|
+
fixtures:
|
21
|
+
forge_modules:
|
22
|
+
<% @modules.each do |name, version| -%>
|
23
|
+
<%= name.split('/')[1] %>:
|
24
|
+
repo: <%= name %>
|
25
|
+
ref: <%= version %>
|
26
|
+
<% end -%>
|
27
|
+
repositories:
|
28
|
+
<% @repos.each do |name, hash| -%>
|
29
|
+
<%= name %>:
|
30
|
+
repo: <%= hash[:uri] %>
|
31
|
+
ref: <%= hash[:ref] %>
|
32
|
+
<% end -%>
|
33
|
+
EOT
|
34
|
+
|
35
|
+
self.evaluate
|
36
|
+
end
|
37
|
+
|
38
|
+
def evaluate
|
39
|
+
# TODO add error handling if target doesn't exist
|
40
|
+
self.instance_eval(File.read(@puppetfile))
|
41
|
+
end
|
42
|
+
|
43
|
+
def maxlen_name
|
44
|
+
@maxlen_name
|
45
|
+
end
|
46
|
+
|
47
|
+
def maxlen_ver
|
48
|
+
[@maxlen_ver, 'current'.length].max
|
49
|
+
end
|
50
|
+
|
51
|
+
def updates
|
52
|
+
updates = {}
|
53
|
+
|
54
|
+
@modules.each do |name, version|
|
55
|
+
current = SemanticPuppet::Version.parse(version)
|
56
|
+
newest = Puppetfiler::Mod.newest(name)
|
57
|
+
|
58
|
+
if not newest.eql?(current)
|
59
|
+
updates[name] = {
|
60
|
+
:current => current,
|
61
|
+
:newest => newest,
|
62
|
+
}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
return updates
|
67
|
+
end
|
68
|
+
|
69
|
+
def fixture
|
70
|
+
ERB.new(@fixture_template, nil, '-').result(binding)
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def moduledir(*args)
|
76
|
+
end
|
77
|
+
|
78
|
+
def mod(name, *args)
|
79
|
+
arg = args[0]
|
80
|
+
|
81
|
+
if arg.is_a?(String)
|
82
|
+
return if arg == 'latest'
|
83
|
+
@modules[name] = arg
|
84
|
+
@maxlen_name = name.length if name.length > @maxlen_name
|
85
|
+
@maxlen_ver = arg.length if arg.length > @maxlen_ver
|
86
|
+
else args.is_a?(Hash)
|
87
|
+
|
88
|
+
@repos[name] = {}
|
89
|
+
|
90
|
+
# TODO support local(?)
|
91
|
+
%i{git svn}.each do |vcs|
|
92
|
+
@repos[name][:uri] = arg[vcs] if arg.keys.member?(vcs)
|
93
|
+
end
|
94
|
+
|
95
|
+
# TODO support fallbacks, e.g. using the rugged provider
|
96
|
+
# which is also used by puppetlabs_spec_helper
|
97
|
+
%i{fallback branch tag commit}.each do |ref|
|
98
|
+
@repos[name][:ref] = arg[ref] if arg.keys.member?(ref)
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
data/puppetfiler.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'puppetfiler/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'puppetfiler'
|
8
|
+
spec.version = Puppetfiler::VERSION
|
9
|
+
spec.authors = ['Nelo-T. Wallus']
|
10
|
+
spec.email = ['nelo@wallus.de']
|
11
|
+
|
12
|
+
spec.summary = 'Miscallenous actions on Puppetfiles'
|
13
|
+
spec.homepage = 'https://github.com/ntnn/puppetfiler'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = 'exe'
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
26
|
+
spec.add_development_dependency 'cucumber', '~> 2.4'
|
27
|
+
spec.add_development_dependency 'aruba', '~> 0.14.2'
|
28
|
+
spec.add_development_dependency 'pry', '~> 0.10.4'
|
29
|
+
|
30
|
+
spec.add_dependency 'puppet_forge', '~> 2.2'
|
31
|
+
spec.add_dependency 'semantic_puppet', '~> 0.1.4'
|
32
|
+
spec.add_dependency 'thor', '~> 0.19.4'
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,188 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: puppetfiler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nelo-T. Wallus
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: cucumber
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: aruba
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.14.2
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.14.2
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.10.4
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.10.4
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: puppet_forge
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.2'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.2'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: semantic_puppet
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.1.4
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.1.4
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: thor
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.19.4
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.19.4
|
139
|
+
description:
|
140
|
+
email:
|
141
|
+
- nelo@wallus.de
|
142
|
+
executables:
|
143
|
+
- puppetfiler
|
144
|
+
extensions: []
|
145
|
+
extra_rdoc_files: []
|
146
|
+
files:
|
147
|
+
- ".gitignore"
|
148
|
+
- ".rspec"
|
149
|
+
- ".travis.yml"
|
150
|
+
- Gemfile
|
151
|
+
- LICENSE.txt
|
152
|
+
- README.md
|
153
|
+
- Rakefile
|
154
|
+
- TODO
|
155
|
+
- bin/console
|
156
|
+
- bin/setup
|
157
|
+
- exe/puppetfiler
|
158
|
+
- lib/puppetfiler.rb
|
159
|
+
- lib/puppetfiler/cli.rb
|
160
|
+
- lib/puppetfiler/mod.rb
|
161
|
+
- lib/puppetfiler/puppetfile.rb
|
162
|
+
- lib/puppetfiler/version.rb
|
163
|
+
- puppetfiler.gemspec
|
164
|
+
homepage: https://github.com/ntnn/puppetfiler
|
165
|
+
licenses:
|
166
|
+
- MIT
|
167
|
+
metadata: {}
|
168
|
+
post_install_message:
|
169
|
+
rdoc_options: []
|
170
|
+
require_paths:
|
171
|
+
- lib
|
172
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
173
|
+
requirements:
|
174
|
+
- - ">="
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '0'
|
177
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
requirements: []
|
183
|
+
rubyforge_project:
|
184
|
+
rubygems_version: 2.6.10
|
185
|
+
signing_key:
|
186
|
+
specification_version: 4
|
187
|
+
summary: Miscallenous actions on Puppetfiles
|
188
|
+
test_files: []
|