puppet-blacksmith 1.0.5 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/puppet_blacksmith/error.rb +4 -0
- data/lib/puppet_blacksmith/forge.rb +92 -0
- data/lib/puppet_blacksmith/git.rb +43 -0
- data/lib/puppet_blacksmith/modulefile.rb +46 -0
- data/lib/puppet_blacksmith/rake_tasks.rb +13 -106
- data/lib/puppet_blacksmith/version.rb +3 -0
- data/lib/puppet_blacksmith.rb +4 -0
- data/spec/data/forge_error.html +230 -0
- data/spec/data/maestrodev-ant-1.0.4.tar.gz +0 -0
- data/spec/puppet_blacksmith/forge_spec.rb +52 -0
- data/spec/puppet_blacksmith/git_spec.rb +24 -0
- data/spec/puppet_blacksmith/{rake_tasks_spec.rb → modulefile_spec.rb} +16 -17
- data/spec/spec_helper.rb +2 -0
- metadata +50 -34
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'rest-client'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
module Blacksmith
|
5
|
+
class Forge
|
6
|
+
|
7
|
+
PUPPETLABS_FORGE = "https://forge.puppetlabs.com"
|
8
|
+
|
9
|
+
attr_accessor :username, :password
|
10
|
+
attr_writer :url
|
11
|
+
|
12
|
+
def initialize(username = nil, password = nil, url = nil)
|
13
|
+
self.username = username
|
14
|
+
self.password = password
|
15
|
+
self.url = url
|
16
|
+
RestClient.proxy = ENV['http_proxy']
|
17
|
+
load_credentials_from_file if username.nil?
|
18
|
+
end
|
19
|
+
|
20
|
+
def url
|
21
|
+
@url || PUPPETLABS_FORGE
|
22
|
+
end
|
23
|
+
|
24
|
+
def push!(name, package = nil)
|
25
|
+
unless package
|
26
|
+
regex = /^#{username}-#{name}-.*\.tar\.gz$/
|
27
|
+
pkg = File.expand_path("pkg")
|
28
|
+
f = Dir.new(pkg).select{|f| f.match(regex)}.last
|
29
|
+
raise Errno::ENOENT, "File not found in #{pkg} with regex #{regex}" if f.nil?
|
30
|
+
package = File.join(pkg, f)
|
31
|
+
end
|
32
|
+
raise Errno::ENOENT, "File does not exist: #{package}" unless File.exists?(package)
|
33
|
+
|
34
|
+
# login to the puppet forge
|
35
|
+
response = RestClient.post(
|
36
|
+
"#{url}/login",
|
37
|
+
{'username' => username, 'password' => password}){
|
38
|
+
|response, request, result, &block|
|
39
|
+
if [301, 302, 307].include? response.code
|
40
|
+
response # no need to follow redirects
|
41
|
+
else
|
42
|
+
response.return!(request, result, &block)
|
43
|
+
end
|
44
|
+
}
|
45
|
+
raise Blacksmith::Error, "Failed to login to Puppet Forge: cookies not set correctly" unless response.cookies['auth']
|
46
|
+
|
47
|
+
page = Nokogiri::HTML(response.body)
|
48
|
+
errors = page.css('.failure')
|
49
|
+
raise Blacksmith::Error, "Error uploading module #{package} to Puppet Forge #{username}/#{name}:#{errors.text}" unless errors.empty?
|
50
|
+
|
51
|
+
# upload the file
|
52
|
+
response = RestClient.post("#{url}/#{username}/#{name}/upload",
|
53
|
+
{:tarball => File.new(package, 'rb')},
|
54
|
+
{:cookies => response.cookies}){
|
55
|
+
|response, request, result, &block|
|
56
|
+
if [301, 302, 307].include? response.code
|
57
|
+
response # no need to follow redirects
|
58
|
+
else
|
59
|
+
response.return!(request, result, &block)
|
60
|
+
end
|
61
|
+
}
|
62
|
+
page = Nokogiri::HTML(response.body)
|
63
|
+
errors = page.css('.errors')
|
64
|
+
raise Blacksmith::Error, "Error uploading module #{package} to Puppet Forge #{username}/#{name}:#{errors.text}" unless errors.empty?
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def load_credentials_from_file
|
70
|
+
credentials_file = File.expand_path("~/.puppetforge.yml")
|
71
|
+
unless File.exists?(credentials_file)
|
72
|
+
raise Blacksmith::Error, <<-eos
|
73
|
+
Could not find Puppet Forge credentials file '#{credentials_file}'
|
74
|
+
Please create it
|
75
|
+
---
|
76
|
+
forge: https://forge.puppetlabs.com
|
77
|
+
username: myuser
|
78
|
+
password: mypassword
|
79
|
+
eos
|
80
|
+
end
|
81
|
+
credentials = YAML.load_file(credentials_file)
|
82
|
+
self.username = credentials['username']
|
83
|
+
self.password = credentials['password']
|
84
|
+
if credentials['forge']
|
85
|
+
# deprecated
|
86
|
+
puts "'forge' entry is deprecated in .puppetforge.yml, use 'url'"
|
87
|
+
self.url = credentials['forge']
|
88
|
+
end
|
89
|
+
self.url = credentials['url'] if credentials['url']
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module Blacksmith
|
4
|
+
class Git
|
5
|
+
|
6
|
+
attr_accessor :path
|
7
|
+
|
8
|
+
def initialize(path = ".")
|
9
|
+
@path = File.expand_path(path)
|
10
|
+
end
|
11
|
+
|
12
|
+
def tag!(version)
|
13
|
+
exec_git "tag v#{version}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def commit_modulefile!
|
17
|
+
s = exec_git "add Modulefile"
|
18
|
+
s += exec_git "commit -m '[blacksmith] Bump version'"
|
19
|
+
s
|
20
|
+
end
|
21
|
+
|
22
|
+
def push!
|
23
|
+
s = exec_git "push"
|
24
|
+
s += exec_git "push --tags"
|
25
|
+
s
|
26
|
+
end
|
27
|
+
|
28
|
+
def exec_git(cmd)
|
29
|
+
out = ""
|
30
|
+
err = ""
|
31
|
+
# wait_thr is nil in JRuby < 1.7.5 see http://jira.codehaus.org/browse/JRUBY-6409
|
32
|
+
new_cmd = "git --git-dir=#{File.join(path, '.git')} --work-tree=#{path} #{cmd}"
|
33
|
+
Open3.popen3(new_cmd) do |stdin, stdout, stderr, wait_thr|
|
34
|
+
out = stdout.read
|
35
|
+
err = stderr.read
|
36
|
+
# exit_status = wait_thr.value
|
37
|
+
end
|
38
|
+
exit_status = $?
|
39
|
+
raise Blacksmith::Error, err unless exit_status.success?
|
40
|
+
return out
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'puppet'
|
2
|
+
|
3
|
+
module Blacksmith
|
4
|
+
class Modulefile
|
5
|
+
|
6
|
+
attr_reader :path
|
7
|
+
|
8
|
+
def initialize(path = "Modulefile")
|
9
|
+
@path = path
|
10
|
+
end
|
11
|
+
|
12
|
+
def metadata
|
13
|
+
unless @metadata
|
14
|
+
metadata = Puppet::ModuleTool::Metadata.new
|
15
|
+
Puppet::ModuleTool::ModulefileReader.evaluate(metadata, path)
|
16
|
+
@metadata = metadata
|
17
|
+
end
|
18
|
+
@metadata
|
19
|
+
end
|
20
|
+
|
21
|
+
def name
|
22
|
+
metadata.name
|
23
|
+
end
|
24
|
+
def version
|
25
|
+
metadata.version
|
26
|
+
end
|
27
|
+
|
28
|
+
def bump!
|
29
|
+
new_version = increase_version(version)
|
30
|
+
text = File.read(path)
|
31
|
+
text = replace_version(text, new_version)
|
32
|
+
File.open(path, "w") {|file| file.puts text}
|
33
|
+
new_version
|
34
|
+
end
|
35
|
+
|
36
|
+
def replace_version(text, version)
|
37
|
+
text.gsub(/\nversion[ ]+['"].*['"]/, "\nversion '#{version}'")
|
38
|
+
end
|
39
|
+
|
40
|
+
def increase_version(version)
|
41
|
+
v = Gem::Version.new("#{version}.0")
|
42
|
+
raise Blacksmith::Error, "Unable to increase prerelease version #{version}" if v.prerelease?
|
43
|
+
v.bump.to_s
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -1,28 +1,31 @@
|
|
1
1
|
require 'rake'
|
2
|
-
|
3
|
-
require 'puppet'
|
4
|
-
require 'yaml'
|
5
|
-
require 'nokogiri'
|
2
|
+
require_relative '../puppet_blacksmith'
|
6
3
|
|
7
4
|
namespace :module do
|
8
5
|
desc "Bump module version to the next minor"
|
9
6
|
task :bump do
|
10
|
-
|
7
|
+
m = Blacksmith::Modulefile.new
|
8
|
+
v = m.bump!
|
9
|
+
puts "Bumping version from #{m.version} to #{v}"
|
11
10
|
end
|
12
11
|
|
13
12
|
desc "Git tag with the current module version"
|
14
13
|
task :tag do
|
15
|
-
|
14
|
+
m = Blacksmith::Modulefile.new
|
15
|
+
Blacksmith::Git.new.tag!(m.version)
|
16
16
|
end
|
17
17
|
|
18
18
|
desc "Bump version and git commit"
|
19
19
|
task :bump_commit => :bump do
|
20
|
-
|
20
|
+
Blacksmith::Git.new.commit_modulefile!
|
21
21
|
end
|
22
22
|
|
23
23
|
desc "Push module to the Puppet Forge"
|
24
24
|
task :push => :build do
|
25
|
-
|
25
|
+
m = Blacksmith::Modulefile.new
|
26
|
+
forge = Blacksmith::Forge.new
|
27
|
+
puts "Uploading to Puppet Forge #{forge.username}/#{m.name}"
|
28
|
+
forge.push!(m.name)
|
26
29
|
end
|
27
30
|
|
28
31
|
desc "Runs clean again"
|
@@ -33,104 +36,8 @@ namespace :module do
|
|
33
36
|
|
34
37
|
desc "Release the Puppet module, doing a clean, build, tag, push, bump_commit and git push."
|
35
38
|
task :release => [:clean, :build, :tag, :push, :bump_commit] do
|
36
|
-
puts "Pushing
|
37
|
-
|
38
|
-
puts "Pushing tags to remote git repo"
|
39
|
-
sh "git push --tags"
|
39
|
+
puts "Pushing to remote git repo"
|
40
|
+
Blacksmith::Git.new.push!
|
40
41
|
end
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
# task methods for reuse
|
45
|
-
|
46
|
-
def bump
|
47
|
-
m = modulefile()
|
48
|
-
text = File.read("Modulefile")
|
49
|
-
v = increase_version(m.version)
|
50
|
-
puts "Bumping version from #{m.version} to #{v}"
|
51
|
-
text = replace_version(text, v)
|
52
|
-
File.open("Modulefile", "w") {|file| file.puts text}
|
53
|
-
end
|
54
|
-
|
55
|
-
def tag
|
56
|
-
m = modulefile()
|
57
|
-
sh "git tag v#{m.version}"
|
58
|
-
end
|
59
|
-
|
60
|
-
def bump_commit
|
61
|
-
sh "git add Modulefile"
|
62
|
-
sh "git commit -m 'Bump version'"
|
63
|
-
end
|
64
|
-
|
65
|
-
def bump_commit_push
|
66
|
-
sh "git add Modulefile"
|
67
|
-
sh "git commit -m 'Bump version'"
|
68
|
-
end
|
69
|
-
|
70
|
-
def push
|
71
|
-
RestClient.proxy = ENV['http_proxy']
|
72
|
-
credentials_file = File.expand_path("~/.puppetforge.yml")
|
73
|
-
unless File.exists?(credentials_file)
|
74
|
-
fail(<<-eos)
|
75
|
-
Could not find Puppet Forge credentials file '#{credentials_file}'
|
76
|
-
Please create it
|
77
|
-
---
|
78
|
-
forge: https://forge.puppetlabs.com
|
79
|
-
username: myuser
|
80
|
-
password: mypassword
|
81
|
-
eos
|
82
|
-
end
|
83
|
-
credentials = YAML.load_file(credentials_file)
|
84
|
-
m = modulefile("Modulefile")
|
85
|
-
forge = credentials['forge'] || "https://forge.puppetlabs.com"
|
86
|
-
|
87
|
-
# login to the puppet forge
|
88
|
-
puts "Logging into Puppet Forge as user #{credentials['username']}"
|
89
|
-
response = RestClient.post(
|
90
|
-
"#{forge}/login",
|
91
|
-
{'username' => credentials['username'], 'password' => credentials['password']}){
|
92
|
-
|response, request, result, &block|
|
93
|
-
if [301, 302, 307].include? response.code
|
94
|
-
response
|
95
|
-
else
|
96
|
-
response.return!(request, result, &block)
|
97
|
-
end
|
98
|
-
}
|
99
|
-
fail("Failed to login to Puppet Forge: cookies not set correctly") unless response.cookies['auth']
|
100
|
-
|
101
|
-
# upload the file
|
102
|
-
package = "pkg/#{m.username}-#{m.name}-#{m.version}.tar.gz"
|
103
|
-
puts "Uploading #{package} to Puppet Forge #{m.username}/#{m.name}"
|
104
|
-
response = RestClient.post("#{forge}/#{m.username}/#{m.name}/upload",
|
105
|
-
{:tarball => File.new(package, 'rb')},
|
106
|
-
{:cookies => response.cookies}){
|
107
|
-
|response, request, result, &block|
|
108
|
-
if [301, 302, 307].include? response.code
|
109
|
-
response
|
110
|
-
else
|
111
|
-
response.return!(request, result, &block)
|
112
|
-
end
|
113
|
-
}
|
114
|
-
page = Nokogiri::HTML(response.body)
|
115
|
-
errors = page.css('.errors')
|
116
|
-
fail("Error uploading module #{package} to Puppet Forge #{m.username}/#{m.name}:#{errors.text}") unless errors.empty?
|
117
|
-
end
|
118
|
-
|
119
|
-
|
120
|
-
# util
|
121
|
-
|
122
|
-
def replace_version(text, version)
|
123
|
-
text.gsub(/\nversion[ ]+['"].*['"]/, "\nversion '#{version}'")
|
124
|
-
end
|
125
|
-
|
126
|
-
def increase_version(version)
|
127
|
-
v = Gem::Version.new("#{version}.0")
|
128
|
-
raise "Unable to increase prerelease version #{version}" if v.prerelease?
|
129
|
-
v.bump.to_s
|
130
|
-
end
|
131
42
|
|
132
|
-
def modulefile(path = "Modulefile")
|
133
|
-
metadata = Puppet::ModuleTool::Metadata.new
|
134
|
-
Puppet::ModuleTool::ModulefileReader.evaluate(metadata, path)
|
135
|
-
metadata
|
136
43
|
end
|
@@ -0,0 +1,230 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html dir="ltr" lang="en-US">
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
5
|
+
<title>Puppet Forge</title>
|
6
|
+
<link rel="stylesheet" href="/styles/application.css" />
|
7
|
+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
|
8
|
+
<script src="/scripts/modernizr.js"></script>
|
9
|
+
|
10
|
+
<script src="//munchkin.marketo.net/munchkin.js" type="text/javascript"></script>
|
11
|
+
|
12
|
+
<script src="/scripts/leadcapture.js"></script>
|
13
|
+
|
14
|
+
<script type="text/javascript">
|
15
|
+
mktoMunchkin("307-QLA-991");
|
16
|
+
|
17
|
+
var _gaq = _gaq || [];
|
18
|
+
_gaq.push(['_setAccount', 'UA-1537572-5']);
|
19
|
+
_gaq.push(['_trackPageview']);
|
20
|
+
(function() {
|
21
|
+
var ga = document.createElement('script');
|
22
|
+
ga.type = 'text/javascript';
|
23
|
+
ga.async = true;
|
24
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
25
|
+
var s = document.getElementsByTagName('script')[0];
|
26
|
+
s.parentNode.insertBefore(ga, s);
|
27
|
+
})();
|
28
|
+
|
29
|
+
var _gauges = _gauges || [];
|
30
|
+
(function() {
|
31
|
+
var t = document.createElement('script');
|
32
|
+
t.type = 'text/javascript';
|
33
|
+
t.async = true;
|
34
|
+
t.id = 'gauges-tracker';
|
35
|
+
t.setAttribute('data-site-id', '50a02411613f5d682f0000c1');
|
36
|
+
t.src = '//secure.gaug.es/track.js';
|
37
|
+
var s = document.getElementsByTagName('script')[0];
|
38
|
+
s.parentNode.insertBefore(t, s);
|
39
|
+
})();
|
40
|
+
</script>
|
41
|
+
</head>
|
42
|
+
<body>
|
43
|
+
<section id="masthead">
|
44
|
+
<div class="site-width">
|
45
|
+
<ul>
|
46
|
+
<li class="colon-after"><a href="http://www.puppetlabs.com">Puppet Labs</a></li>
|
47
|
+
<li><a href="http://puppetlabs.com/puppet/puppet-open-source/">Open Source Projects</a></li>
|
48
|
+
<li><a href="http://puppetlabs.com/services/customer-support/">Support</a></li>
|
49
|
+
<li><a href="http://docs.puppetlabs.com/">Docs</a></li>
|
50
|
+
<li><a href="http://projects.puppetlabs.com/">Bugs</a></li>
|
51
|
+
</ul>
|
52
|
+
</div>
|
53
|
+
</section>
|
54
|
+
<section id="header">
|
55
|
+
<div class="site-width clearfix">
|
56
|
+
<a href="/">
|
57
|
+
<img src="/images/forge-logo.png" class="logo" width="214px" height="50px" alt="Puppet Forge Home">
|
58
|
+
</a>
|
59
|
+
|
60
|
+
<div class="stats">
|
61
|
+
<span class="first">
|
62
|
+
<span class="big">1,369</span> modules
|
63
|
+
</span>
|
64
|
+
<span>
|
65
|
+
<span class="big">1,193,444</span> downloads
|
66
|
+
</span>
|
67
|
+
</div>
|
68
|
+
</div>
|
69
|
+
</section>
|
70
|
+
<section id="content">
|
71
|
+
<div class="site-width clearfix">
|
72
|
+
<section id="body">
|
73
|
+
<h2>Upload a Release of maestrodev/test</h2>
|
74
|
+
<div class="errors">
|
75
|
+
<ul>
|
76
|
+
<li>Internal server error</li>
|
77
|
+
</ul>
|
78
|
+
</div>
|
79
|
+
|
80
|
+
<form action="/maestrodev/test/upload" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
|
81
|
+
<input type="hidden" name="utf-8" value="✓" />
|
82
|
+
<ul class="form">
|
83
|
+
<li class="requiredFieldText">Required fields <span>*</span></li>
|
84
|
+
|
85
|
+
<li>
|
86
|
+
<label for="tarball" class="required">Tarball</label>
|
87
|
+
<p>
|
88
|
+
The version number for this release will be determined from the metadata.json file in the uploaded tarball.
|
89
|
+
|
90
|
+
</p>
|
91
|
+
<input name="tarball" type="file" required />
|
92
|
+
</li>
|
93
|
+
|
94
|
+
<li>
|
95
|
+
<input type="submit" value="Upload Release" />
|
96
|
+
<a href="/maestrodev/test">Cancel</a>
|
97
|
+
</li>
|
98
|
+
</ul>
|
99
|
+
</form>
|
100
|
+
|
101
|
+
</section>
|
102
|
+
<section id="sidebar">
|
103
|
+
<section class="session">
|
104
|
+
<table>
|
105
|
+
<tr>
|
106
|
+
<td>
|
107
|
+
<img class="avatar" alt="avatar" src="//gravatar.com/avatar/192d33f0c408b08b3df9d4927bfbcdc0.png?r=PG&s=45" /></td>
|
108
|
+
<td>
|
109
|
+
<a class="profile-edit" href="/users/maestrodev/edit">MaestroDev</a>
|
110
|
+
<a href="/logout">Sign Out</a>
|
111
|
+
</td>
|
112
|
+
</tr>
|
113
|
+
</table>
|
114
|
+
|
115
|
+
<ul>
|
116
|
+
<li><a href="/maestrodev">Your Modules</a></li>
|
117
|
+
<li><a href="/modules/new">Publish a Module</a></li>
|
118
|
+
</ul>
|
119
|
+
</section>
|
120
|
+
|
121
|
+
<section class="search">
|
122
|
+
<h3>Find Modules</h3>
|
123
|
+
<form action="/modules" method="get" accept-charset="UTF-8">
|
124
|
+
<input type="hidden" name="utf-8" value="✓" />
|
125
|
+
<input type="hidden" name="sort" value="rank" />
|
126
|
+
<input type="search" name="q" required placeholder="eg. apache, mysql" />
|
127
|
+
<input type="submit" value="Find" />
|
128
|
+
</form>
|
129
|
+
</section>
|
130
|
+
|
131
|
+
<section class="tags">
|
132
|
+
<h3>Popular Tags</h3>
|
133
|
+
<ul>
|
134
|
+
<li>
|
135
|
+
<a href="/tags/ubuntu">
|
136
|
+
<b>ubuntu</b> (248 modules)
|
137
|
+
</a>
|
138
|
+
</li>
|
139
|
+
<li>
|
140
|
+
<a href="/tags/debian">
|
141
|
+
<b>debian</b> (197 modules)
|
142
|
+
</a>
|
143
|
+
</li>
|
144
|
+
<li>
|
145
|
+
<a href="/tags/rhel">
|
146
|
+
<b>rhel</b> (145 modules)
|
147
|
+
</a>
|
148
|
+
</li>
|
149
|
+
<li>
|
150
|
+
<a href="/tags/CentOS">
|
151
|
+
<b>CentOS</b> (114 modules)
|
152
|
+
</a>
|
153
|
+
</li>
|
154
|
+
<li>
|
155
|
+
<a href="/tags/centos">
|
156
|
+
<b>centos</b> (95 modules)
|
157
|
+
</a>
|
158
|
+
</li>
|
159
|
+
<li>
|
160
|
+
<a href="/tags/monitoring">
|
161
|
+
<b>monitoring</b> (77 modules)
|
162
|
+
</a>
|
163
|
+
</li>
|
164
|
+
<li>
|
165
|
+
<a href="/tags/networking">
|
166
|
+
<b>networking</b> (73 modules)
|
167
|
+
</a>
|
168
|
+
</li>
|
169
|
+
<li>
|
170
|
+
<a href="/tags/redhat">
|
171
|
+
<b>redhat</b> (68 modules)
|
172
|
+
</a>
|
173
|
+
</li>
|
174
|
+
<li>
|
175
|
+
<a href="/tags/security">
|
176
|
+
<b>security</b> (62 modules)
|
177
|
+
</a>
|
178
|
+
</li>
|
179
|
+
<li>
|
180
|
+
<a href="/tags/applications">
|
181
|
+
<b>applications</b> (61 modules)
|
182
|
+
</a>
|
183
|
+
</li>
|
184
|
+
</ul>
|
185
|
+
</section>
|
186
|
+
|
187
|
+
<section class="banner">
|
188
|
+
<a href="http://puppetconf.com/register/"><img src="/images/puppetconf_v1-01.png"></a>
|
189
|
+
</section> </section>
|
190
|
+
</div>
|
191
|
+
</section>
|
192
|
+
<section id="footer">
|
193
|
+
<div class="site-width">
|
194
|
+
<div id="footer-links">
|
195
|
+
<ul>
|
196
|
+
<li><strong>Community</strong></li>
|
197
|
+
<li><a href="http://webchat.freenode.net/?channels=puppet">IRC</a></li>
|
198
|
+
<li><a href="http://groups.google.com/group/puppet-dev">Puppet Developer List</a></li>
|
199
|
+
<li><a href="http://groups.google.com/group/puppet-users?pli=1">Puppet User List</a></li>
|
200
|
+
<li><a href="http://www.linkedin.com/groups?about=&gid=696467&trk=anet_ug_grppro">Puppet Users' LinkedIn Group</a></li>
|
201
|
+
<li><a href="http://puppetlabs.com/resources/newsletter/">Subscribe to Newsletter</a></li>
|
202
|
+
</ul>
|
203
|
+
</div>
|
204
|
+
<div id="footer-bottom" class="clearfix">
|
205
|
+
<div class="vcard">
|
206
|
+
© 2009-2012
|
207
|
+
<span class="org">
|
208
|
+
<a href="http://puppetlabs.com/" title="Puppet Labs">
|
209
|
+
Puppet Labs
|
210
|
+
</a>
|
211
|
+
</span>
|
212
|
+
<a class="email" href="mailto:info@puppetlabs.com">info@puppetlabs.com</a>
|
213
|
+
<span class="adr">
|
214
|
+
<span class="street-address">926 NW 13th Ave., Suite 210</span>
|
215
|
+
/
|
216
|
+
<span class="locality">Portland</span>
|
217
|
+
,
|
218
|
+
<span class="region">OR</span>
|
219
|
+
<span class="postal-code">97209</span>
|
220
|
+
|
221
|
+
</span>
|
222
|
+
<span class="tel">+1 503-805-9065</span>
|
223
|
+
</div>
|
224
|
+
<div class="new-relic-logo">Monitored by <a href="http://newrelic.com/"><img src="/images/new-relic-oval.png"></a>
|
225
|
+
</div>
|
226
|
+
</div>
|
227
|
+
</div>
|
228
|
+
</section>
|
229
|
+
</body>
|
230
|
+
</html>
|
File without changes
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
describe 'Blacksmith::Forge' do
|
5
|
+
|
6
|
+
subject { Blacksmith::Forge.new(username, password, forge) }
|
7
|
+
let(:username) { 'johndoe' }
|
8
|
+
let(:password) { 'secret' }
|
9
|
+
let(:forge) { "https://forge.puppetlabs.com" }
|
10
|
+
let(:module_name) { "test" }
|
11
|
+
let(:version) { "1.0.0" }
|
12
|
+
let(:package) { File.dirname(__FILE__) + '/../data/maestrodev-ant-1.0.4.tar.gz' }
|
13
|
+
|
14
|
+
describe 'push' do
|
15
|
+
|
16
|
+
before do
|
17
|
+
FileUtils.mkdir_p("pkg")
|
18
|
+
FileUtils.touch("pkg/#{username}-#{module_name}-#{version}.tar.gz")
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when using username and password" do
|
22
|
+
before do
|
23
|
+
stub_request(:post, "#{forge}/login").with(
|
24
|
+
:body => {'username' => username, 'password' => password}).to_return(
|
25
|
+
:status => 200, :headers => { 'Set-Cookie' => "auth=xxx; path=/; expires=Tue, 27-Aug-2013 08:34:51 GMT" })
|
26
|
+
|
27
|
+
stub_request(:post, "#{forge}/#{username}/#{module_name}/upload").to_return(:status => 200)
|
28
|
+
subject.push!(module_name, package)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should push the module" do
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "when forge returns an error" do
|
37
|
+
before do
|
38
|
+
stub_request(:post, "#{forge}/login").with(
|
39
|
+
:body => {'username' => username, 'password' => password}).to_return(
|
40
|
+
:status => 200, :headers => { 'Set-Cookie' => "auth=xxx; path=/; expires=Tue, 27-Aug-2013 08:34:51 GMT" })
|
41
|
+
|
42
|
+
stub_request(:post, "#{forge}/#{username}/#{module_name}/upload").to_return(
|
43
|
+
:body => File.new('spec/data/forge_error.html'), :status => 200)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should handle the error" do
|
47
|
+
expect { subject.push!(module_name, package) }.to raise_error(%r{^Error uploading module .*maestrodev-ant-1.0.4.tar.gz to Puppet Forge johndoe/test})
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Blacksmith::Git' do
|
4
|
+
|
5
|
+
subject { Blacksmith::Git.new(path) }
|
6
|
+
let(:path) { File.join(File.dirname(__FILE__), '../../tmp/git_test') }
|
7
|
+
let(:version) { '1.0.0' }
|
8
|
+
|
9
|
+
before do
|
10
|
+
FileUtils.rm_rf path
|
11
|
+
FileUtils.mkdir_p(path)
|
12
|
+
`git init #{path}`
|
13
|
+
FileUtils.touch(File.join(path, "Modulefile"))
|
14
|
+
`cd #{path} && git add Modulefile && git commit -am "Init"`
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'tag!' do
|
18
|
+
before { subject.tag!(version) }
|
19
|
+
it "should have the tag" do
|
20
|
+
out = `cd #{path} && git tag`
|
21
|
+
out.chomp.should match(/^v1.0.0$/)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,6 +1,15 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
|
-
describe '
|
3
|
+
describe 'Blacksmith::Modulefile' do
|
4
|
+
|
5
|
+
subject { Blacksmith::Modulefile.new(path) }
|
6
|
+
let(:path) { "spec/data/Modulefile" }
|
7
|
+
|
8
|
+
context 'when modulefile is parsed' do
|
9
|
+
it { subject.metadata.version.should eql("1.0.0") }
|
10
|
+
it { subject.metadata.username.should eql("maestrodev") }
|
11
|
+
it { subject.metadata.name.should eql("test") }
|
12
|
+
end
|
4
13
|
|
5
14
|
describe 'replace_version' do
|
6
15
|
it "should replace the version" do
|
@@ -28,25 +37,15 @@ summary 'version "1"'
|
|
28
37
|
description "version '1'"
|
29
38
|
eos
|
30
39
|
|
31
|
-
replace_version(original, "1.0.1").should eql(expected)
|
40
|
+
subject.replace_version(original, "1.0.1").should eql(expected)
|
32
41
|
end
|
33
42
|
end
|
34
43
|
|
35
44
|
describe 'increase_version' do
|
36
|
-
it "should
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
expect { increase_version("1.0.12qwe") }.to raise_error
|
41
|
-
end
|
45
|
+
it { subject.increase_version("1.0").should eql("1.1") }
|
46
|
+
it { subject.increase_version("1.0.0").should eql("1.0.1") }
|
47
|
+
it { subject.increase_version("1.0.1").should eql("1.0.2") }
|
48
|
+
it { expect { subject.increase_version("1.0.12qwe") }.to raise_error }
|
42
49
|
end
|
43
50
|
|
44
|
-
describe 'modulefile' do
|
45
|
-
it "should parse the modulefile" do
|
46
|
-
m = modulefile("spec/data/Modulefile")
|
47
|
-
m.version.should eql("1.0.0")
|
48
|
-
m.username.should eql("maestrodev")
|
49
|
-
m.name.should eql("test")
|
50
|
-
end
|
51
|
-
end
|
52
51
|
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-blacksmith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: rake
|
16
|
-
requirement: &12387780 !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: *12387780
|
25
14
|
- !ruby/object:Gem::Dependency
|
26
15
|
name: rest-client
|
27
|
-
requirement: &
|
16
|
+
requirement: &16892060 !ruby/object:Gem::Requirement
|
28
17
|
none: false
|
29
18
|
requirements:
|
30
19
|
- - ! '>='
|
@@ -32,10 +21,10 @@ dependencies:
|
|
32
21
|
version: '0'
|
33
22
|
type: :runtime
|
34
23
|
prerelease: false
|
35
|
-
version_requirements: *
|
24
|
+
version_requirements: *16892060
|
36
25
|
- !ruby/object:Gem::Dependency
|
37
26
|
name: puppet
|
38
|
-
requirement: &
|
27
|
+
requirement: &16891460 !ruby/object:Gem::Requirement
|
39
28
|
none: false
|
40
29
|
requirements:
|
41
30
|
- - ! '>='
|
@@ -43,32 +32,32 @@ dependencies:
|
|
43
32
|
version: 2.7.16
|
44
33
|
type: :runtime
|
45
34
|
prerelease: false
|
46
|
-
version_requirements: *
|
35
|
+
version_requirements: *16891460
|
47
36
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
49
|
-
requirement: &
|
37
|
+
name: nokogiri
|
38
|
+
requirement: &16890980 !ruby/object:Gem::Requirement
|
50
39
|
none: false
|
51
40
|
requirements:
|
52
41
|
- - ! '>='
|
53
42
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
43
|
+
version: '0'
|
55
44
|
type: :runtime
|
56
45
|
prerelease: false
|
57
|
-
version_requirements: *
|
46
|
+
version_requirements: *16890980
|
58
47
|
- !ruby/object:Gem::Dependency
|
59
|
-
name:
|
60
|
-
requirement: &
|
48
|
+
name: rake
|
49
|
+
requirement: &16890460 !ruby/object:Gem::Requirement
|
61
50
|
none: false
|
62
51
|
requirements:
|
63
52
|
- - ! '>='
|
64
53
|
- !ruby/object:Gem::Version
|
65
54
|
version: '0'
|
66
|
-
type: :
|
55
|
+
type: :development
|
67
56
|
prerelease: false
|
68
|
-
version_requirements: *
|
57
|
+
version_requirements: *16890460
|
69
58
|
- !ruby/object:Gem::Dependency
|
70
59
|
name: cucumber
|
71
|
-
requirement: &
|
60
|
+
requirement: &16889980 !ruby/object:Gem::Requirement
|
72
61
|
none: false
|
73
62
|
requirements:
|
74
63
|
- - ! '>='
|
@@ -76,10 +65,10 @@ dependencies:
|
|
76
65
|
version: '0'
|
77
66
|
type: :development
|
78
67
|
prerelease: false
|
79
|
-
version_requirements: *
|
68
|
+
version_requirements: *16889980
|
80
69
|
- !ruby/object:Gem::Dependency
|
81
70
|
name: aruba
|
82
|
-
requirement: &
|
71
|
+
requirement: &16889520 !ruby/object:Gem::Requirement
|
83
72
|
none: false
|
84
73
|
requirements:
|
85
74
|
- - ! '>='
|
@@ -87,10 +76,10 @@ dependencies:
|
|
87
76
|
version: '0'
|
88
77
|
type: :development
|
89
78
|
prerelease: false
|
90
|
-
version_requirements: *
|
79
|
+
version_requirements: *16889520
|
91
80
|
- !ruby/object:Gem::Dependency
|
92
81
|
name: rspec
|
93
|
-
requirement: &
|
82
|
+
requirement: &16888960 !ruby/object:Gem::Requirement
|
94
83
|
none: false
|
95
84
|
requirements:
|
96
85
|
- - ! '>='
|
@@ -98,7 +87,18 @@ dependencies:
|
|
98
87
|
version: 2.7.0
|
99
88
|
type: :development
|
100
89
|
prerelease: false
|
101
|
-
version_requirements: *
|
90
|
+
version_requirements: *16888960
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: webmock
|
93
|
+
requirement: &16888440 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *16888440
|
102
102
|
description: Puppet module tools for development and Puppet Forge management
|
103
103
|
email:
|
104
104
|
- info@maestrodev.com
|
@@ -106,9 +106,20 @@ executables: []
|
|
106
106
|
extensions: []
|
107
107
|
extra_rdoc_files: []
|
108
108
|
files:
|
109
|
+
- lib/puppet_blacksmith.rb
|
110
|
+
- lib/puppet_blacksmith/forge.rb
|
111
|
+
- lib/puppet_blacksmith/modulefile.rb
|
109
112
|
- lib/puppet_blacksmith/rake_tasks.rb
|
113
|
+
- lib/puppet_blacksmith/version.rb
|
114
|
+
- lib/puppet_blacksmith/error.rb
|
115
|
+
- lib/puppet_blacksmith/git.rb
|
110
116
|
- LICENSE
|
111
|
-
- spec/
|
117
|
+
- spec/spec_helper.rb
|
118
|
+
- spec/puppet_blacksmith/git_spec.rb
|
119
|
+
- spec/puppet_blacksmith/forge_spec.rb
|
120
|
+
- spec/puppet_blacksmith/modulefile_spec.rb
|
121
|
+
- spec/data/maestrodev-ant-1.0.4.tar.gz
|
122
|
+
- spec/data/forge_error.html
|
112
123
|
- spec/data/Modulefile
|
113
124
|
homepage: http://github.com/maestrodev/puppet-blacksmith
|
114
125
|
licenses: []
|
@@ -124,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
135
|
version: '0'
|
125
136
|
segments:
|
126
137
|
- 0
|
127
|
-
hash:
|
138
|
+
hash: 3568524494369527716
|
128
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
140
|
none: false
|
130
141
|
requirements:
|
@@ -138,5 +149,10 @@ signing_key:
|
|
138
149
|
specification_version: 3
|
139
150
|
summary: Tasks to manage Puppet module builds
|
140
151
|
test_files:
|
141
|
-
- spec/
|
152
|
+
- spec/spec_helper.rb
|
153
|
+
- spec/puppet_blacksmith/git_spec.rb
|
154
|
+
- spec/puppet_blacksmith/forge_spec.rb
|
155
|
+
- spec/puppet_blacksmith/modulefile_spec.rb
|
156
|
+
- spec/data/maestrodev-ant-1.0.4.tar.gz
|
157
|
+
- spec/data/forge_error.html
|
142
158
|
- spec/data/Modulefile
|