knife-spork 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +10 -0
- data/README.md +5 -1
- data/knife-spork.gemspec +1 -1
- data/lib/chef/knife/spork-upload.rb +10 -9
- data/lib/knife-spork/plugins/git.rb +62 -30
- data/lib/knife-spork/plugins/plugin.rb +8 -0
- data/lib/knife-spork/runner.rb +2 -0
- metadata +8 -8
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## 1.0.4 (14th September, 2012)
|
2
|
+
Features:
|
3
|
+
|
4
|
+
- Spork can now run command from any directory, not just the root of your chef repository.
|
5
|
+
|
6
|
+
Bugfixes:
|
7
|
+
|
8
|
+
- Fixed spork uploader to work more cleanly with 10.14.0 and greater
|
9
|
+
- Spork bump will no longer throw errors when no cookbook name is specified
|
10
|
+
|
1
11
|
## 1.0.3 (10th September, 2012)
|
2
12
|
Bugfixes:
|
3
13
|
|
data/README.md
CHANGED
@@ -38,7 +38,8 @@ Below is a sample config file with all supported options and all shipped plugins
|
|
38
38
|
default_environments:
|
39
39
|
- development
|
40
40
|
- production
|
41
|
-
version_change_threshold:
|
41
|
+
version_change_threshold: 2
|
42
|
+
environment_path: "/home/me/environments"
|
42
43
|
plugins:
|
43
44
|
campfire:
|
44
45
|
account: myaccount
|
@@ -70,6 +71,9 @@ The `default_environments` directive allows you to specify a default list of env
|
|
70
71
|
#### Version Change Threshold
|
71
72
|
The `version_change_threshold` directive allows you to customise the threshold used by a safety check in spork promote which will prompt for confirmation if you're promoting a cookbook by more than version_change_threshold versions. This defaults to 2 if not set, ie promoting a cookbook from v1.0.1 to v 1.0.2 will not trip this check, wheras promoting from v1.0.1 to v1.0.3 will.
|
72
73
|
|
74
|
+
#### Environment Path
|
75
|
+
The `envirinment_path` allows you to specify the path to where you store your chef environment json files. If this parameter is not specified, spork will default to using the first element of your cookbook_path, replacing the word "cookbooks" with "environments"
|
76
|
+
|
73
77
|
#### Plugins
|
74
78
|
Knife spork supports plugins to allow users to hook it into existing systems such as source control, monitoring and chat systems. Plugins are enabled / disabled by adding / removing their config block from the plugin section of the config file. Any of the default plugins shown above can be disabled by removing their section.
|
75
79
|
|
data/knife-spork.gemspec
CHANGED
@@ -2,7 +2,7 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = 'knife-spork'
|
5
|
-
gem.version = '1.0.
|
5
|
+
gem.version = '1.0.4'
|
6
6
|
gem.authors = ["Jon Cowie"]
|
7
7
|
gem.email = 'jonlives@gmail.com'
|
8
8
|
gem.homepage = 'https://github.com/jonlives/knife-spork'
|
@@ -62,19 +62,20 @@ module KnifeSpork
|
|
62
62
|
@cookbooks.reverse.each do |cookbook|
|
63
63
|
begin
|
64
64
|
check_dependencies(cookbook)
|
65
|
-
if
|
66
|
-
uploader = Chef::CookbookUploader.new(
|
67
|
-
if
|
65
|
+
if name_args.include?(cookbook.name.to_s)
|
66
|
+
uploader = Chef::CookbookUploader.new(cookbook, ::Chef::Config.cookbook_path)
|
67
|
+
if uploader.respond_to?(:upload_cookbooks)
|
68
|
+
# Chef >= 10.14.0
|
69
|
+
uploader.upload_cookbooks
|
68
70
|
ui.info "Freezing #{cookbook.name} at #{cookbook.version}..."
|
69
71
|
cookbook.freeze_version
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
uploader = Chef::CookbookUploader.new(cookbook, ::Chef::Config.cookbook_path).upload_cookbook
|
74
|
-
if name_args.include?(cookbook.name.to_s)
|
72
|
+
uploader.upload_cookbooks
|
73
|
+
else
|
74
|
+
uploader.upload_cookbook
|
75
75
|
ui.info "Freezing #{cookbook.name} at #{cookbook.version}..."
|
76
76
|
cookbook.freeze_version
|
77
|
-
|
77
|
+
uploader.upload_cookbook
|
78
|
+
|
78
79
|
end
|
79
80
|
end
|
80
81
|
rescue Net::HTTPServerException => e
|
@@ -8,29 +8,41 @@ module KnifeSpork
|
|
8
8
|
def perform; end
|
9
9
|
|
10
10
|
def before_bump
|
11
|
-
git_pull
|
12
|
-
git_pull_submodules
|
11
|
+
git_pull(environment_path) unless cookbook_path.include?(environment_path.gsub"/environments","")
|
12
|
+
git_pull_submodules(environment_path) unless cookbook_path.include?(environment_path.gsub"/environments","")
|
13
|
+
cookbooks.each do |cookbook|
|
14
|
+
git_pull(cookbook.root_dir)
|
15
|
+
git_pull_submodules(cookbook.root_dir)
|
16
|
+
end
|
13
17
|
end
|
14
18
|
|
15
19
|
def before_upload
|
16
|
-
git_pull
|
17
|
-
git_pull_submodules
|
20
|
+
git_pull(environment_path) unless cookbook_path.include?(environment_path.gsub"/environments","")
|
21
|
+
git_pull_submodules(environment_path) unless cookbook_path.include?(environment_path.gsub"/environments","")
|
22
|
+
cookbooks.each do |cookbook|
|
23
|
+
git_pull(cookbook.root_dir)
|
24
|
+
git_pull_submodules(cookbook.root_dir)
|
25
|
+
end
|
18
26
|
end
|
19
27
|
|
20
28
|
def before_promote
|
21
|
-
|
22
|
-
|
29
|
+
cookbooks.each do |cookbook|
|
30
|
+
git_pull(environment_path) unless cookbook.root_dir.include?(environment_path.gsub"/environments","")
|
31
|
+
git_pull_submodules(environment_path) unless cookbook.root_dir.include?(environment_path.gsub"/environments","")
|
32
|
+
git_pull(cookbook.root_dir)
|
33
|
+
git_pull_submodules(cookbook.root_dir)
|
34
|
+
end
|
23
35
|
end
|
24
36
|
|
25
37
|
def after_bump
|
26
38
|
cookbooks.each do |cookbook|
|
27
|
-
git_add(
|
39
|
+
git_add(cookbook.root_dir,"metadata.rb")
|
28
40
|
end
|
29
41
|
end
|
30
42
|
|
31
43
|
def after_promote_local
|
32
44
|
environments.each do |environment|
|
33
|
-
git_add("
|
45
|
+
git_add(environment_path,"#{environment}.json")
|
34
46
|
end
|
35
47
|
end
|
36
48
|
|
@@ -42,7 +54,7 @@ module KnifeSpork
|
|
42
54
|
@git ||= begin
|
43
55
|
::Git.open('.', :log => log)
|
44
56
|
rescue
|
45
|
-
ui.error 'You are not currently in a git repository.
|
57
|
+
ui.error 'You are not currently in a git repository. Please ensure you are in a git repo, a repo subdirectory, or remove the git plugin from your KnifeSpork configuration!'
|
46
58
|
exit(0)
|
47
59
|
end
|
48
60
|
end
|
@@ -51,33 +63,42 @@ module KnifeSpork
|
|
51
63
|
# - Stash local changes
|
52
64
|
# - Pull from the remote
|
53
65
|
# - Pop the stash
|
54
|
-
def git_pull
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
66
|
+
def git_pull(path)
|
67
|
+
if is_repo?(path)
|
68
|
+
ui.msg "Git: Pulling latest changes from #{path}"
|
69
|
+
output = IO.popen ("git pull 2>&1")
|
70
|
+
Process.wait
|
71
|
+
exit_code = $?
|
72
|
+
if !exit_code.exitstatus == 0
|
73
|
+
ui.error "#{output.read()}\n"
|
74
|
+
exit 1
|
75
|
+
end
|
61
76
|
end
|
62
77
|
end
|
63
78
|
|
64
|
-
def git_pull_submodules
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
79
|
+
def git_pull_submodules(path)
|
80
|
+
if is_repo?(path)
|
81
|
+
ui.msg "Pulling latest changes from git submodules (if any)"
|
82
|
+
output = IO.popen ("git submodule foreach git pull 2>&1")
|
83
|
+
Process.wait
|
84
|
+
exit_code = $?
|
85
|
+
if !exit_code.exitstatus == 0
|
86
|
+
ui.error "#{output.read()}\n"
|
87
|
+
exit 1
|
88
|
+
end
|
72
89
|
end
|
73
90
|
end
|
74
91
|
|
75
|
-
def git_add(filepath)
|
76
|
-
|
77
|
-
ui.msg "Git add'ing #{filepath}"
|
78
|
-
|
79
|
-
|
80
|
-
|
92
|
+
def git_add(filepath,filename)
|
93
|
+
if is_repo?(filepath)
|
94
|
+
ui.msg "Git add'ing #{filepath}/#{filename}"
|
95
|
+
output = IO.popen ("cd #{filepath} && git add #{filename}")
|
96
|
+
Process.wait
|
97
|
+
exit_code = $?
|
98
|
+
if !exit_code.exitstatus == 0
|
99
|
+
ui.error "#{output.read()}\n"
|
100
|
+
exit 1
|
101
|
+
end
|
81
102
|
end
|
82
103
|
end
|
83
104
|
|
@@ -107,6 +128,17 @@ module KnifeSpork
|
|
107
128
|
end
|
108
129
|
end
|
109
130
|
|
131
|
+
def is_repo?(path)
|
132
|
+
output = IO.popen ("cd #{path} && git rev-parse --git-dir 2>&1")
|
133
|
+
Process.wait
|
134
|
+
if $? != 0
|
135
|
+
ui.warn "#{path} is not a git repo, skipping..."
|
136
|
+
return false
|
137
|
+
else
|
138
|
+
return true
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
110
142
|
def remote
|
111
143
|
config.remote || 'origin'
|
112
144
|
end
|
data/lib/knife-spork/runner.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-spork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
12
|
+
date: 2012-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: chef
|
16
|
-
requirement: &
|
16
|
+
requirement: &70208983407820 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.10.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70208983407820
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: git
|
27
|
-
requirement: &
|
27
|
+
requirement: &70208983407340 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.2.5
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70208983407340
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: app_conf
|
38
|
-
requirement: &
|
38
|
+
requirement: &70208983406820 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 0.4.0
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70208983406820
|
47
47
|
description: A workflow plugin to help many devs work with the same chef repo/server
|
48
48
|
email: jonlives@gmail.com
|
49
49
|
executables: []
|