puppet-blacksmith 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +13 -0
- data/lib/puppet_blacksmith/rake_tasks.rb +79 -0
- data/spec/data/Modulefile +9 -0
- data/spec/puppet_blacksmith/rake_tasks_spec.rb +52 -0
- metadata +166 -0
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2013 MaestroDev
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rest-client'
|
3
|
+
require 'puppet'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
namespace :module do
|
7
|
+
desc "Bump module version to the next minor"
|
8
|
+
task :bump do
|
9
|
+
m = modulefile()
|
10
|
+
text = File.read("Modulefile")
|
11
|
+
v = increase_version(m.version)
|
12
|
+
puts "Bumping version from #{m.version} to #{v}"
|
13
|
+
text = replace_version(text, v)
|
14
|
+
File.open("Modulefile", "w") {|file| file.puts text}
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Git tag with the current module version"
|
18
|
+
task :tag do
|
19
|
+
m = modulefile()
|
20
|
+
sh "git tag v#{m.version}"
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Bump version and git commit"
|
24
|
+
task :bump_commit => :bump do
|
25
|
+
sh "git add Modulefile"
|
26
|
+
sh "git commit -m 'Bump version'"
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Push module to the Puppet Forge"
|
30
|
+
task :push => :build do
|
31
|
+
credentials_file = File.expand_path("~/.puppetforge.yml")
|
32
|
+
unless File.exists?(credentials_file)
|
33
|
+
fail("Could not find Puppet Forge credentials file '#{credentials_file}'
|
34
|
+
Please create it
|
35
|
+
---
|
36
|
+
forge: https://forge.puppetlabs.com
|
37
|
+
username: myuser
|
38
|
+
password: mypassword")
|
39
|
+
end
|
40
|
+
credentials = YAML.load_file(credentials_file)
|
41
|
+
m = modulefile("Modulefile")
|
42
|
+
forge = credentials['forge'] || "https://forge.puppetlabs.com"
|
43
|
+
|
44
|
+
# login to the puppet forge
|
45
|
+
response = RestClient.post(
|
46
|
+
"#{forge}/login",
|
47
|
+
{'username' => credentials['username'], 'password' => credentials['password']}){
|
48
|
+
|response, request, result, &block|
|
49
|
+
if [301, 302, 307].include? response.code
|
50
|
+
response
|
51
|
+
else
|
52
|
+
response.return!(request, result, &block)
|
53
|
+
end
|
54
|
+
}
|
55
|
+
# TODO check response body for errors
|
56
|
+
|
57
|
+
# upload the file
|
58
|
+
RestClient.post("#{forge}/#{m.username}/#{m.name}/upload",
|
59
|
+
{:notes => "Auto uploaded", :tarball => File.new("pkg/#{m.username}-#{m.name}-#{m.version}.tar.gz", 'rb') },
|
60
|
+
{:cookies => response.cookies})
|
61
|
+
# TODO check response body for errors
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def replace_version(text, version)
|
66
|
+
text.gsub(/\nversion[ ]+['"].*['"]/, "\nversion '#{version}'")
|
67
|
+
end
|
68
|
+
|
69
|
+
def increase_version(version)
|
70
|
+
v = Gem::Version.new("#{version}.0")
|
71
|
+
raise "Unable to increase prerelease version #{version}" if v.prerelease?
|
72
|
+
v.bump.to_s
|
73
|
+
end
|
74
|
+
|
75
|
+
def modulefile(path = "Modulefile")
|
76
|
+
metadata = Puppet::ModuleTool::Metadata.new
|
77
|
+
Puppet::ModuleTool::ModulefileReader.evaluate(metadata, path)
|
78
|
+
metadata
|
79
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
name 'maestrodev-test'
|
2
|
+
version '1.0.0'
|
3
|
+
|
4
|
+
author 'maestrodev'
|
5
|
+
license 'Apache License, Version 2.0'
|
6
|
+
project_page 'http://github.com/maestrodev/puppet-blacksmith'
|
7
|
+
source 'http://github.com/maestrodev/puppet-blacksmith'
|
8
|
+
summary 'Testing Puppet module operations'
|
9
|
+
description 'Testing Puppet module operations'
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'puppet_blacksmith/rake_tasks'
|
2
|
+
|
3
|
+
describe 'rake tasks' do
|
4
|
+
|
5
|
+
describe 'replace_version' do
|
6
|
+
it "should replace the version" do
|
7
|
+
original = <<-eos
|
8
|
+
name 'maestrodev-test'
|
9
|
+
version '1.0.0'
|
10
|
+
|
11
|
+
author 'maestrodev'
|
12
|
+
license 'Apache License, Version 2.0'
|
13
|
+
project_page 'http://github.com/maestrodev/puppet-blacksmith'
|
14
|
+
source 'http://github.com/maestrodev/puppet-blacksmith'
|
15
|
+
summary 'version "1"'
|
16
|
+
description "version '1'"
|
17
|
+
eos
|
18
|
+
|
19
|
+
expected = <<-eos
|
20
|
+
name 'maestrodev-test'
|
21
|
+
version '1.0.1'
|
22
|
+
|
23
|
+
author 'maestrodev'
|
24
|
+
license 'Apache License, Version 2.0'
|
25
|
+
project_page 'http://github.com/maestrodev/puppet-blacksmith'
|
26
|
+
source 'http://github.com/maestrodev/puppet-blacksmith'
|
27
|
+
summary 'version "1"'
|
28
|
+
description "version '1'"
|
29
|
+
eos
|
30
|
+
|
31
|
+
replace_version(original, "1.0.1").should eql(expected)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'increase_version' do
|
36
|
+
it "should increase the version" do
|
37
|
+
increase_version("1.0").should eql("1.1")
|
38
|
+
increase_version("1.0.0").should eql("1.0.1")
|
39
|
+
increase_version("1.0.1").should eql("1.0.2")
|
40
|
+
expect { increase_version("1.0.12qwe") }.to raise_error
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
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
|
+
end
|
metadata
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: puppet-blacksmith
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- MaestroDev
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !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: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rest-client
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: puppet
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 2.7.16
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.7.16
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: puppetlabs_spec_helper
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.3.0
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.3.0
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: cucumber
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: aruba
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rspec
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 2.7.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 2.7.0
|
126
|
+
description: Puppet module tools for development and Puppet Forge management
|
127
|
+
email:
|
128
|
+
- info@maestrodev.com
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- lib/puppet_blacksmith/rake_tasks.rb
|
134
|
+
- LICENSE
|
135
|
+
- spec/data/Modulefile
|
136
|
+
- spec/puppet_blacksmith/rake_tasks_spec.rb
|
137
|
+
homepage: http://github.com/maestrodev/puppet-blacksmith
|
138
|
+
licenses: []
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
145
|
+
requirements:
|
146
|
+
- - ! '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
segments:
|
150
|
+
- 0
|
151
|
+
hash: 2134866812481276079
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
requirements: []
|
159
|
+
rubyforge_project:
|
160
|
+
rubygems_version: 1.8.24
|
161
|
+
signing_key:
|
162
|
+
specification_version: 3
|
163
|
+
summary: Tasks to manage Puppet module builds
|
164
|
+
test_files:
|
165
|
+
- spec/data/Modulefile
|
166
|
+
- spec/puppet_blacksmith/rake_tasks_spec.rb
|