knife-spork 1.6.2 → 1.6.3
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 +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +8 -1
- data/README.md +18 -0
- data/knife-spork.gemspec +4 -4
- data/lib/chef/knife/spork-delete.rb +132 -0
- data/lib/knife-spork/plugins/campfire.rb +8 -0
- data/lib/knife-spork/plugins/eventinator.rb +12 -0
- data/lib/knife-spork/plugins/grove.rb +6 -0
- data/lib/knife-spork/plugins/hipchat.rb +4 -0
- data/lib/knife-spork/plugins/irccat.rb +9 -0
- data/lib/knife-spork/plugins/jabber.rb +4 -0
- data/lib/knife-spork/plugins/plugin.rb +4 -0
- data/lib/knife-spork/plugins/slack.rb +4 -0
- data/lib/knife-spork/plugins/statusnet.rb +4 -0
- data/lib/knife-spork/runner.rb +1 -0
- metadata +8 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9f41664f90da0809a4d75a015883b920cbcbf9a0
|
|
4
|
+
data.tar.gz: cd5d2629b7a32ead1d32d6b11649c478f91bef21
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8b5fd7c94fe33abeef46f3a00f6d0403a450c5f5c9206b3aae4cc6042e77112ff2690ddbcf781d4148966cb917ecc00ccd7fbbb5fa694f61ed7aeda2db6c7b25
|
|
7
|
+
data.tar.gz: 73d8bedaac9e18b72fd72fb878b6566c5392b77a87894226288262ae284d7d0eab826708cea9f496fe155f6cc6cf4bea19c9e0339721492c6e1d3b01cce61e8c
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
+
## 1.6.3(12th December, 2016)
|
|
2
|
+
|
|
3
|
+
Features:
|
|
4
|
+
|
|
5
|
+
- Added commands to delete cookbooks (Thanks to kdaniels https://github.com/jonlives/knife-spork/pull/205)
|
|
6
|
+
|
|
7
|
+
|
|
1
8
|
## 1.6.2(13th June, 2016)
|
|
2
9
|
|
|
3
10
|
Features:
|
|
4
11
|
|
|
5
|
-
- Search for spork config file in .chef directory under current working dir (
|
|
12
|
+
- Search for spork config file in .chef directory under current working dir (Thanks to jgoulah https://github.com/jonlives/knife-spork/pull/203)
|
|
6
13
|
|
|
7
14
|
Bugfixes:
|
|
8
15
|
|
data/README.md
CHANGED
|
@@ -337,6 +337,24 @@ Saving changes to my_environment.json
|
|
|
337
337
|
Promotion complete. Don't forget to upload your changed my_environment to Chef Server
|
|
338
338
|
```
|
|
339
339
|
|
|
340
|
+
Spork Delete
|
|
341
|
+
------------
|
|
342
|
+
This function works mostly the same as normal `knife cookbook delete COOKBOOK` including options to delete all versions and delete without interactive confirmation.
|
|
343
|
+
|
|
344
|
+
#### Usage
|
|
345
|
+
```bash
|
|
346
|
+
knife spork delete COOKBOOK
|
|
347
|
+
```
|
|
348
|
+
#### Example
|
|
349
|
+
```text
|
|
350
|
+
$ knife spork delete apache2 -a
|
|
351
|
+
WARNING: Deleting cookbook apache2...
|
|
352
|
+
Do you really want to delete all versions of apache2? (Y/N) Y
|
|
353
|
+
Deleted cookbook[apache2][2.0.2]
|
|
354
|
+
Successfully deleted cookbook apache2 ALL versions from the Chef server
|
|
355
|
+
Cookbooks deleted from Chef server: apache2: ALL versions
|
|
356
|
+
```
|
|
357
|
+
|
|
340
358
|
Spork Omni
|
|
341
359
|
-------------
|
|
342
360
|
Omni lets you combine one of the most common combinations of spork commands (bump, upload & promote or promote --remote) - into one handy shortcut.
|
data/knife-spork.gemspec
CHANGED
|
@@ -2,9 +2,9 @@ $:.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.6.
|
|
6
|
-
gem.authors = ["Jon Cowie"]
|
|
7
|
-
gem.email = 'jonlives@gmail.com'
|
|
5
|
+
gem.version = '1.6.3'
|
|
6
|
+
gem.authors = ["Jon Cowie", "Katherine Daniels"]
|
|
7
|
+
gem.email = ['jonlives@gmail.com', 'kdaniels@etsy.com']
|
|
8
8
|
gem.homepage = 'https://github.com/jonlives/knife-spork'
|
|
9
9
|
gem.licenses = ['GPL']
|
|
10
10
|
gem.summary = "A workflow plugin to help many devs work with the same chef repo/server"
|
|
@@ -23,4 +23,4 @@ Gem::Specification.new do |gem|
|
|
|
23
23
|
gem.add_runtime_dependency 'git', '>= 1.2.5'
|
|
24
24
|
gem.add_runtime_dependency 'app_conf', '>= 0.4.0'
|
|
25
25
|
gem.add_runtime_dependency 'diffy', '>= 3.0.1'
|
|
26
|
-
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
require 'chef/knife'
|
|
2
|
+
|
|
3
|
+
module KnifeSpork
|
|
4
|
+
class SporkDelete < Chef::Knife
|
|
5
|
+
deps do
|
|
6
|
+
require 'chef/exceptions'
|
|
7
|
+
require 'knife-spork/runner'
|
|
8
|
+
require 'socket'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
ALL_NO_CONF = 'all_no_conf'.freeze
|
|
12
|
+
ALL_CONF = 'all_conf'.freeze
|
|
13
|
+
ONE_NO_CONF = 'one_no_conf'.freeze
|
|
14
|
+
ONE_CONF = 'one_conf'.freeze
|
|
15
|
+
|
|
16
|
+
banner 'knife spork delete [COOKBOOKS...] (options)'
|
|
17
|
+
|
|
18
|
+
option :cookbook_path,
|
|
19
|
+
:short => '-o PATH:PATH',
|
|
20
|
+
:long => '--cookbook-path PATH:PATH',
|
|
21
|
+
:description => 'A colon-separated path to look for cookbooks in',
|
|
22
|
+
:proc => lambda { |o| o.split(':') }
|
|
23
|
+
|
|
24
|
+
option :yes,
|
|
25
|
+
:short => '-y',
|
|
26
|
+
:long => '--yes',
|
|
27
|
+
:description => 'Say yes to all prompts for confirmation'
|
|
28
|
+
|
|
29
|
+
option :all,
|
|
30
|
+
:short => '-a',
|
|
31
|
+
:long => '--all',
|
|
32
|
+
:description => 'Delete all versions of the specified cookbooks'
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def run
|
|
36
|
+
self.class.send(:include, KnifeSpork::Runner)
|
|
37
|
+
self.config = Chef::Config.merge!(config)
|
|
38
|
+
config[:cookbook_path] ||= Chef::Config[:cookbook_path]
|
|
39
|
+
|
|
40
|
+
if @name_args.empty?
|
|
41
|
+
show_usage
|
|
42
|
+
ui.error("You must specify the --all flag or at least one cookbook name")
|
|
43
|
+
exit 1
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
delete
|
|
47
|
+
@misc_output = @deleted_cookbook_string
|
|
48
|
+
run_plugins(:after_delete)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
|
|
53
|
+
def printable_version_string(version)
|
|
54
|
+
# The version variable might be a string or an array. The array might even be empty.
|
|
55
|
+
# Based on what it is, we will return a string that says something like "versions 1, 2" or "version 1" or "ALL versions"
|
|
56
|
+
# for more human-readable output.
|
|
57
|
+
if (version.class == Array and version.size == 0) or version == "ALL"
|
|
58
|
+
return "ALL versions"
|
|
59
|
+
elsif version.class == Array
|
|
60
|
+
if version.size > 1
|
|
61
|
+
return "versions #{version.join(', ')}"
|
|
62
|
+
else
|
|
63
|
+
return "version #{version.join(', ')}"
|
|
64
|
+
end
|
|
65
|
+
else
|
|
66
|
+
return "version #{version}"
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def run_knife_command(cookbook_name, command, version = [])
|
|
71
|
+
begin
|
|
72
|
+
ui.warn("Deleting cookbook #{cookbook_name}...")
|
|
73
|
+
case command
|
|
74
|
+
when ALL_NO_CONF
|
|
75
|
+
@knife.delete_all_without_confirmation
|
|
76
|
+
when ALL_CONF
|
|
77
|
+
@knife.delete_all_versions
|
|
78
|
+
when ONE_NO_CONF
|
|
79
|
+
@knife.delete_versions_without_confirmation(version)
|
|
80
|
+
when ONE_CONF
|
|
81
|
+
@knife.version = version
|
|
82
|
+
@knife.delete_explicit_version
|
|
83
|
+
end
|
|
84
|
+
ui.msg("Successfully deleted cookbook #{cookbook_name} #{printable_version_string(version)} from the Chef server")
|
|
85
|
+
true
|
|
86
|
+
rescue SystemExit
|
|
87
|
+
# The user said no at a confirmation prompt, just continue. But return false since we
|
|
88
|
+
# didn't actually delete anything.
|
|
89
|
+
false
|
|
90
|
+
rescue Exception => e
|
|
91
|
+
ui.error("Error deleting cookbook #{cookbook_name}: #{e}")
|
|
92
|
+
false
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def delete
|
|
97
|
+
@deleted_cookbooks = []
|
|
98
|
+
name_args.each do |cookbook_name|
|
|
99
|
+
@knife = Chef::Knife::CookbookDelete.new
|
|
100
|
+
@knife.name_args = cookbook_name
|
|
101
|
+
@knife.cookbook_name = cookbook_name
|
|
102
|
+
if config[:all]
|
|
103
|
+
@knife.config[:all] = true
|
|
104
|
+
if config[:yes]
|
|
105
|
+
@deleted_cookbooks.push([cookbook_name, "ALL"]) if run_knife_command(cookbook_name, ALL_NO_CONF)
|
|
106
|
+
else
|
|
107
|
+
@deleted_cookbooks.push([cookbook_name, "ALL"]) if run_knife_command(cookbook_name, ALL_CONF)
|
|
108
|
+
end
|
|
109
|
+
else
|
|
110
|
+
begin
|
|
111
|
+
versions_to_delete = @knife.ask_which_versions_to_delete
|
|
112
|
+
rescue NoMethodError
|
|
113
|
+
# Rescuing this means the output from knife itself already gets printed, no need to duplicate that.
|
|
114
|
+
exit 1
|
|
115
|
+
end
|
|
116
|
+
if config[:yes]
|
|
117
|
+
@deleted_cookbooks.push([cookbook_name, versions_to_delete]) if run_knife_command(cookbook_name, ONE_NO_CONF, versions_to_delete)
|
|
118
|
+
else
|
|
119
|
+
versions_to_delete.each do |version|
|
|
120
|
+
@deleted_cookbooks.push([cookbook_name, version]) if run_knife_command(cookbook_name, ONE_CONF, version)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
# This is the formatted string that the plugins will use to print.
|
|
126
|
+
@deleted_cookbook_string = ""
|
|
127
|
+
@deleted_cookbooks.each {|cookbook, version| @deleted_cookbook_string << "#{cookbook}: #{printable_version_string(version)}, " }
|
|
128
|
+
@deleted_cookbook_string.chop!.chop! # Get rid of the trailing , chop chop!
|
|
129
|
+
ui.msg("Cookbooks deleted from chef server: #{@deleted_cookbook_string}")
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
@@ -16,6 +16,14 @@ EOH
|
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
def after_delete
|
|
20
|
+
campfire do |rooms|
|
|
21
|
+
rooms.paste <<-EOH
|
|
22
|
+
"#{organization}#{current_user} deleted the following cookbooks: #{misc_output}"
|
|
23
|
+
EOH
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
19
27
|
def after_promote_remote
|
|
20
28
|
campfire do |rooms|
|
|
21
29
|
rooms.paste <<-EOH
|
|
@@ -24,6 +24,18 @@ module KnifeSpork
|
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
def after_delete
|
|
28
|
+
event_data = {
|
|
29
|
+
:tag => 'knife',
|
|
30
|
+
:username => current_user,
|
|
31
|
+
:status => "#{organization}#{current_user} deleted the following cookbooks: #{misc_output}",
|
|
32
|
+
:metadata => {
|
|
33
|
+
:deleted_cookbooks => misc_output
|
|
34
|
+
}.to_json
|
|
35
|
+
}
|
|
36
|
+
eventinate(event_data)
|
|
37
|
+
end
|
|
38
|
+
|
|
27
39
|
def after_promote_remote
|
|
28
40
|
environments.each do |environment|
|
|
29
41
|
cookbooks.each do |cookbook|
|
|
@@ -13,6 +13,12 @@ module KnifeSpork
|
|
|
13
13
|
EOH
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
def after_delete
|
|
17
|
+
grove <<-EOH
|
|
18
|
+
#{organization}#{current_user} deleted the following cookbooks: #{misc_output}
|
|
19
|
+
EOH
|
|
20
|
+
end
|
|
21
|
+
|
|
16
22
|
def after_promote_remote
|
|
17
23
|
grove <<-EOH
|
|
18
24
|
#{current_user} promoted #{cookbooks.collect{|c| "#{c.name}@#{c.version}"}.join(', ')} on #{environments.collect{|e| "#{e.name}"}.join(', ')}
|
|
@@ -11,6 +11,10 @@ module KnifeSpork
|
|
|
11
11
|
hipchat "#{organization}#{current_user} uploaded the following cookbooks:\n#{cookbooks.collect{ |c| " #{c.name}@#{c.version}" }.join("\n")}"
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
def after_delete
|
|
15
|
+
hipchat "#{organization}#{current_user} deleted the following cookbooks: #{misc_output}"
|
|
16
|
+
end
|
|
17
|
+
|
|
14
18
|
def after_promote_remote
|
|
15
19
|
environments.each do |environment|
|
|
16
20
|
diff = environment_diffs[environment.name]
|
|
@@ -7,6 +7,7 @@ module KnifeSpork
|
|
|
7
7
|
|
|
8
8
|
TEMPLATES = {
|
|
9
9
|
:upload => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} uploaded #TEAL%{cookbooks}#NORMAL',
|
|
10
|
+
:delete => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} deleted the following cookbooks: #TEAL%{misc_output}#NORMAL',
|
|
10
11
|
:promote => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} promoted #TEAL%{cookbooks}#NORMAL to %{environment} %{gist}',
|
|
11
12
|
:environmentfromfile => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} uploaded environment #TEAL%{object_name}#NORMAL %{gist}',
|
|
12
13
|
:environmentedit => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} edited environment #TEAL%{object_name}#NORMAL %{gist}',
|
|
@@ -40,6 +41,14 @@ module KnifeSpork
|
|
|
40
41
|
})
|
|
41
42
|
end
|
|
42
43
|
|
|
44
|
+
def after_delete
|
|
45
|
+
irccat(template(:delete) % {
|
|
46
|
+
:organization => organization,
|
|
47
|
+
:current_user => current_user,
|
|
48
|
+
:misc_output => misc_output
|
|
49
|
+
})
|
|
50
|
+
end
|
|
51
|
+
|
|
43
52
|
def after_promote_remote
|
|
44
53
|
environments.each do |environment|
|
|
45
54
|
diff = environment_diffs[environment.name]
|
|
@@ -11,6 +11,10 @@ module KnifeSpork
|
|
|
11
11
|
jabber "#{organization}#{current_user} uploaded the following cookbooks:\n#{cookbooks.collect{ |c| " #{c.name}@#{c.version}" }.join("\n")}"
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
def after_delete
|
|
15
|
+
jabber "#{organization}#{current_user} deleted the following cookbooks: #{misc_output}"
|
|
16
|
+
end
|
|
17
|
+
|
|
14
18
|
def after_promote_remote
|
|
15
19
|
jabber "#{organization}#{current_user} promoted the following cookbooks:\n#{cookbooks.collect{ |c| " #{c.name}@#{c.version}" }.join("\n")} to #{environments.collect{ |e| "#{e.name}" }.join(", ")}"
|
|
16
20
|
end
|
|
@@ -11,6 +11,10 @@ module KnifeSpork
|
|
|
11
11
|
slack "#{organization}#{current_user} uploaded the following cookbooks:\n#{cookbooks.collect{ |c| " #{c.name}@#{c.version}" }.join("\n")}"
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
def after_delete
|
|
15
|
+
slack "#{organization}#{current_user} deleted the following cookbooks: #{misc_output}"
|
|
16
|
+
end
|
|
17
|
+
|
|
14
18
|
def after_promote_remote
|
|
15
19
|
slack "#{organization}#{current_user} promoted the following cookbooks:\n#{cookbooks.collect{ |c| " #{c.name}@#{c.version}" }.join("\n")} to #{environments.collect{ |e| "#{e.name}" }.join(", ")}"
|
|
16
20
|
end
|
|
@@ -11,6 +11,10 @@ module KnifeSpork
|
|
|
11
11
|
statusnet "#{organization}#{current_user} uploaded the following cookbooks:\n#{cookbooks.collect{ |c| " #{c.name}@#{c.version}" }.join("\n")}"
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
def after_delete
|
|
15
|
+
statusnet "#{organization}#{current_user} deleted the following cookbooks: #{misc_output}"
|
|
16
|
+
end
|
|
17
|
+
|
|
14
18
|
def after_promote_remote
|
|
15
19
|
statusnet "#{organization}#{current_user} promoted the following cookbooks:\n#{cookbooks.collect{ |c| " #{c.name}@#{c.version}" }.join("\n")} to #{environments.collect{ |e| "#{e.name}" }.join(", ")}"
|
|
16
20
|
end
|
data/lib/knife-spork/runner.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: knife-spork
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.6.
|
|
4
|
+
version: 1.6.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jon Cowie
|
|
8
|
+
- Katherine Daniels
|
|
8
9
|
autorequire:
|
|
9
10
|
bindir: bin
|
|
10
11
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
12
|
+
date: 2016-12-12 00:00:00.000000000 Z
|
|
12
13
|
dependencies:
|
|
13
14
|
- !ruby/object:Gem::Dependency
|
|
14
15
|
name: rake
|
|
@@ -112,7 +113,9 @@ description: KnifeSpork is a workflow plugin for Chef::Knife which helps multipl
|
|
|
112
113
|
developers work on the same Chef Server and repository without treading on each
|
|
113
114
|
other's toes. This plugin was designed around the workflow we have here at Etsy,
|
|
114
115
|
where several people are working on the Chef repository and Chef Server simultaneously.
|
|
115
|
-
email:
|
|
116
|
+
email:
|
|
117
|
+
- jonlives@gmail.com
|
|
118
|
+
- kdaniels@etsy.com
|
|
116
119
|
executables: []
|
|
117
120
|
extensions: []
|
|
118
121
|
extra_rdoc_files: []
|
|
@@ -133,6 +136,7 @@ files:
|
|
|
133
136
|
- lib/chef/knife/spork-databag-delete.rb
|
|
134
137
|
- lib/chef/knife/spork-databag-edit.rb
|
|
135
138
|
- lib/chef/knife/spork-databag-fromfile.rb
|
|
139
|
+
- lib/chef/knife/spork-delete.rb
|
|
136
140
|
- lib/chef/knife/spork-environment-check.rb
|
|
137
141
|
- lib/chef/knife/spork-environment-create.rb
|
|
138
142
|
- lib/chef/knife/spork-environment-delete.rb
|
|
@@ -216,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
216
220
|
version: '0'
|
|
217
221
|
requirements: []
|
|
218
222
|
rubyforge_project:
|
|
219
|
-
rubygems_version: 2.
|
|
223
|
+
rubygems_version: 2.5.1
|
|
220
224
|
signing_key:
|
|
221
225
|
specification_version: 4
|
|
222
226
|
summary: A workflow plugin to help many devs work with the same chef repo/server
|