knife-spork 1.0.17 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,30 @@
1
+ ## 1.2.0 (26th June, 2013)
2
+
3
+ Features:
4
+
5
+ - StatusNet plugin (Thanks to Tomasz Napierala - https://github.com/zen)
6
+ - GroveIO plugin (Thanks to Greg Karékinian - https://github.com/gkarekinian)
7
+ - Configurable irccat message templates (Thanks to Tobias Schmidt - https://github.com/grobie)
8
+ - Environment Groups - Spork Promote can update multitiple environments at once by specifying the environment group name. (Thanks to Pivotal Casebook - https://github.com/pivotal-casebook)
9
+
10
+ Bugfixes:
11
+
12
+ - Fix spork bump to not change quote style or whitespace (Thanks to Tobias Schmidt - https://github.com/grobie)
13
+ - Correct Markdown formatting error (Thanks to Jeff Blaine - https://github.com/jblaine)
14
+ - Fix pretty printing of environments (Thanks to Peter Schultz - https://github.com/pschultz)
15
+
16
+ ## 1.0.17 (15th February, 2013)
17
+
18
+ Bugfixes:
19
+
20
+ - Fix git plugin to work nicely with Cygwin and its unpredictable exit codes
21
+
22
+ ## 1.0.16 (13th February, 2013)
23
+
24
+ Bugfixes:
25
+
26
+ - Reverted broken foodcritic plugin to that in 1.0.14
27
+
1
28
  ## 1.0.15 (12th February, 2013)
2
29
 
3
30
  Bugfixes:
data/README.md CHANGED
@@ -38,6 +38,13 @@ 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
+ environment_groups:
42
+ qa_group:
43
+ - quality_assurance
44
+ - staging
45
+ test_group:
46
+ - user_testing
47
+ - acceptance_testing
41
48
  version_change_threshold: 2
42
49
  environment_path: "/home/me/environments"
43
50
  plugins:
@@ -77,6 +84,9 @@ plugins:
77
84
  #### Default Environments
78
85
  The `default_environments` directive allows you to specify a default list of environments you want to promote changes to. If this option is configured and you *omit* the environment parameter when promoting KnifeSpork will promote to all environments in this list.
79
86
 
87
+ #### Environment Groups
88
+ The `environment_groups` directive allows you to specify a list of environments referenced by group names that you want to promote changes to.
89
+
80
90
  #### Version Change Threshold
81
91
  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.
82
92
 
@@ -195,12 +205,13 @@ knife spork bump COOKBOOK [MAJOR | MINOR | PATCH | MANUAL x.x.x]
195
205
  ```text
196
206
  $ knife spork bump apache2
197
207
  Successfully bumped apache2 to v2.0.4!
208
+ ```
198
209
 
199
210
  #### Example (Bumping patch level)
200
211
  ```text
201
212
  $ knife spork bump apache2 patch
202
213
  Successfully bumped apache2 to v2.0.4!
203
- ````
214
+ ```
204
215
 
205
216
  #### Example (Manually setting version)
206
217
  ```text
@@ -225,14 +236,14 @@ Successfully uploaded apache2@1.0.13!
225
236
 
226
237
  Spork Promote
227
238
  -------------
228
- This function lets you easily set a version constraint in an environment for a particular cookbook. By default it will set the version constraint to whatever the local version of the specified cookbook is. Optionally, you can include a `--version` option which will set the version constraint for the specified cookbook to whatever version number you provide. You might want to use this if, for example, you pushed a version constraint for a cookbook version you don't want your nodes to use anymore, so you want to "roll back" the environment to a previous version. You can also specify the `--remote` option if you'd like to automatically upload your changed local environment file to the server.
239
+ This function lets you easily set a version constraint in an environment or group of environments for a particular cookbook. By default it will set the version constraint to whatever the local version of the specified cookbook is. Optionally, you can include a `--version` option which will set the version constraint for the specified cookbook to whatever version number you provide. You might want to use this if, for example, you pushed a version constraint for a cookbook version you don't want your nodes to use anymore, so you want to "roll back" the environment to a previous version. You can also specify the `--remote` option if you'd like to automatically upload your changed local environment file to the server.
229
240
 
230
- If you don't specify an environment, the default_environments config directive will be used if set.
241
+ If you don't specify an environment or environment group, the default_environments config directive will be used if set.
231
242
 
232
243
  #### Usage
233
244
 
234
245
  ```bash
235
- knife spork promote [ENVIRONMENT] COOKBOOK [--version, --remote]
246
+ knife spork promote [ENVIRONMENT OR ENVIRONMENT GROUP NAME] COOKBOOK [--version, --remote]
236
247
  ```
237
248
 
238
249
  #### Example (Using local cookbook version number)
@@ -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.17'
5
+ gem.version = '1.2.0'
6
6
  gem.authors = ["Jon Cowie"]
7
7
  gem.email = 'jonlives@gmail.com'
8
8
  gem.homepage = 'https://github.com/jonlives/knife-spork'
@@ -11,7 +11,7 @@ module KnifeSpork
11
11
 
12
12
  def run
13
13
  self.config = Chef::Config.merge!(config)
14
-
14
+
15
15
  if @name_args.empty?
16
16
  show_usage
17
17
  ui.error("You must specify at least a cookbook name")
@@ -46,7 +46,7 @@ module KnifeSpork
46
46
  new_version = version_array.join('.')
47
47
 
48
48
  metadata_file = "#{@cookbook.root_dir}/metadata.rb"
49
- new_contents = File.read(metadata_file).gsub(/version\s+['"][0-9\.]+['"]/, "version \"#{new_version}\"")
49
+ new_contents = File.read(metadata_file).gsub(/(version\s+['"])[0-9\.]+(['"])/, "\\1#{new_version}\\2")
50
50
  File.open(metadata_file, 'w'){ |f| f.write(new_contents) }
51
51
 
52
52
  ui.info "Successfully bumped #{@cookbook.name} to v#{new_version}!"
@@ -62,7 +62,7 @@ module KnifeSpork
62
62
 
63
63
  ui.msg "Saving changes to #{e}.json"
64
64
 
65
- new_environment_json = pretty_print_json(environment)
65
+ new_environment_json = pretty_print_json(environment.to_hash)
66
66
  save_environment_changes(e, new_environment_json)
67
67
 
68
68
  if config[:remote]
@@ -0,0 +1,41 @@
1
+ require 'knife-spork/plugins/plugin'
2
+
3
+ module KnifeSpork
4
+ module Plugins
5
+ class Grove < Plugin
6
+ name :grove
7
+
8
+ def perform; end
9
+
10
+ def after_upload
11
+ grove <<-EOH
12
+ #{current_user} froze the following cookbooks on Chef Server: #{cookbooks.collect{|c| "#{c.name}@#{c.version}"}.join(', ')}
13
+ EOH
14
+ end
15
+
16
+ def after_promote_remote
17
+ grove <<-EOH
18
+ #{current_user} promoted #{cookbooks.collect{|c| "#{c.name}@#{c.version}"}.join(', ')} on #{environments.collect{|e| "#{e.name}"}.join(', ')}
19
+ EOH
20
+ end
21
+
22
+ private
23
+ def grove(message)
24
+ safe_require 'rest_client'
25
+
26
+ config.tokens.each do |token|
27
+ # Grove can't handle multi-line messages, so let's split by line
28
+ message.split("\n").flatten.delete_if(&:empty?).each do |line|
29
+ RestClient.post "https://grove.io/api/notice/#{token}/",
30
+ :message => line,
31
+ :service => 'knife-spork'
32
+ end
33
+ end
34
+ end
35
+
36
+ def tokens
37
+ Array(config.token || config.tokens)
38
+ end
39
+ end
40
+ end
41
+ end
@@ -5,17 +5,32 @@ module KnifeSpork
5
5
  class Irccat < Plugin
6
6
  name :irccat
7
7
 
8
+ TEMPLATES = {
9
+ :upload => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} uploaded #TEAL%{cookbooks}#NORMAL',
10
+ :promote => '#BOLD#PURPLECHEF:#NORMAL %{organization}%{current_user} promoted #TEAL%{cookbooks}#NORMAL to %{environment} %{gist}'
11
+ }
12
+
8
13
  def perform; end
9
14
 
10
15
  def after_upload
11
- irccat("#BOLD#PURPLECHEF:#NORMAL #{organization}#{current_user} uploaded #TEAL#{cookbooks.collect{ |c| "#{c.name}@#{c.version}" }.join(", ")}#NORMAL")
16
+ irccat(template(:upload) % {
17
+ :organization => organization,
18
+ :current_user => current_user,
19
+ :cookbooks => cookbooks.collect { |c| "#{c.name}@#{c.version}" }.join(", ")
20
+ })
12
21
  end
13
22
 
14
23
  def after_promote_remote
15
24
  environments.each do |environment|
16
25
  diff = environment_diffs[environment.name]
17
26
  env_gist = gist(environment, diff) if config.gist
18
- irccat("#BOLD#PURPLECHEF:#NORMAL #{organization}#{current_user} promoted #TEAL#{cookbooks.collect{ |c| "#{c.name}@#{c.version}" }.join(", ")}#NORMAL to #{environment.name} #{env_gist}")
27
+ irccat(template(:promote) % {
28
+ :organization => organization,
29
+ :current_user => current_user,
30
+ :cookbooks => cookbooks.collect{ |c| "#{c.name}@#{c.version}" }.join(", "),
31
+ :environment => environment.name,
32
+ :gist => env_gist
33
+ })
19
34
  end
20
35
  end
21
36
 
@@ -43,6 +58,10 @@ module KnifeSpork
43
58
  def channels
44
59
  [ config.channel || config.channels ].flatten
45
60
  end
61
+
62
+ def template(name)
63
+ (config.template && config.template[name]) || TEMPLATES[name]
64
+ end
46
65
  end
47
66
  end
48
67
  end
@@ -0,0 +1,38 @@
1
+ require 'knife-spork/plugins/plugin'
2
+
3
+ module KnifeSpork
4
+ module Plugins
5
+ class StatusNet < Plugin
6
+ name :statusnet
7
+
8
+ def perform; end
9
+
10
+ def after_upload
11
+ statusnet "#{organization}#{current_user} uploaded the following cookbooks:\n#{cookbooks.collect{ |c| " #{c.name}@#{c.version}" }.join("\n")}"
12
+ end
13
+
14
+ def after_promote_remote
15
+ 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
+ end
17
+
18
+ private
19
+
20
+ def statusnet(message)
21
+ safe_require 'curb'
22
+
23
+ begin
24
+ c = Curl::Easy.new(config.url)
25
+ c.http_auth_types = :basic
26
+ c.username = config.username
27
+ c.password = config.password
28
+ c.post_body = message
29
+ c.perform
30
+ rescue Exception => e
31
+ ui.error 'Something went wrong sending to StatusNet.'
32
+ ui.error e.to_s
33
+ end
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -45,15 +45,20 @@ module KnifeSpork
45
45
  ensure_environment_provided!
46
46
 
47
47
  if @name_args.size == 2
48
- [ [@name_args[0]].flatten, @name_args[1] ]
48
+ environments = load_specified_environment_group(@name_args[0])
49
+ [ environments, @name_args[1] ]
49
50
  elsif @name_args.size == 1
50
51
  [ [default_environments].flatten, @name_args[0] ]
51
52
  end
52
53
  end
53
54
 
55
+ def load_specified_environment_group(name)
56
+ spork_config.environment_groups[name] || [name]
57
+ end
58
+
54
59
  def ensure_environment_provided!
55
60
  if default_environments.empty? && @name_args.size < 2
56
- ui.error('You must specify a cookbook name and an environment')
61
+ ui.error('You must specify an environment or environment group and a cookbook name')
57
62
  exit(1)
58
63
  end
59
64
  end
@@ -0,0 +1,31 @@
1
+ Campfire
2
+ ========
3
+ Automatically posts informational messages to Grove.io
4
+
5
+ Gem Requirements
6
+ ----------------
7
+ This plugin requires the following gems:
8
+
9
+ ```ruby
10
+ gem 'rest_client'
11
+ ```
12
+
13
+ Hooks
14
+ -----
15
+ - `after_promote`
16
+ - `after_upload`
17
+
18
+ Configuration
19
+ -------------
20
+ ```yaml
21
+ plugins:
22
+ grove:
23
+ tokens:
24
+ - ABC
25
+ - XYZ
26
+ ```
27
+
28
+ #### Tokens
29
+ This is an array of tokens (channels) to post messages to.
30
+
31
+ - Type: `String`
@@ -21,6 +21,8 @@ plugins:
21
21
  - #chef
22
22
  - #knife
23
23
  gist: "/usr/bin/gist"
24
+ template:
25
+ upload: "foo bar! #REDCHEF:#NORMAL %{organization}%{current_user} uploaded #GREEN%{cookbooks}#NORMAL"
24
26
  ```
25
27
 
26
28
  #### server
@@ -41,4 +43,8 @@ The channels to post to.
41
43
  #### gist
42
44
  Optional path to gist binary installed by https://rubygems.org/gems/gist
43
45
 
44
- - Type: `String`
46
+ - Type: `String`
47
+
48
+
49
+ ### template
50
+ Optional irccat message template if you want to change the formatting of irccat alerts. Supports overriding alerts for upload and promote
@@ -0,0 +1,41 @@
1
+ StatusNet
2
+ =======
3
+ StatusNet posts messages to a your StatusNet instance
4
+
5
+ Gem Requirements
6
+ ----------------
7
+ This plugin requires the following gems:
8
+
9
+ ```ruby
10
+ gem 'curb'
11
+ ```
12
+
13
+ Hooks
14
+ -----
15
+ - `after_upload`
16
+ - `after_promote`
17
+
18
+ Configuration
19
+ -------------
20
+ ```yaml
21
+ plugins:
22
+ statusnet:
23
+ url: YOUR INSTANCE API URL
24
+ username: YOURUSER
25
+ password: YOURPASSWORD
26
+ ```
27
+
28
+ #### url
29
+ Your StatusNet instance API url, usually server url + /api/statuses/update.xml
30
+
31
+ - Type: `Srtring`
32
+
33
+ #### username
34
+ Your StatusNet username.
35
+
36
+ - Type: `String`
37
+
38
+ #### password
39
+ Your StatusNet password.
40
+
41
+ - Type: `String`
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.17
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-15 00:00:00.000000000 Z
12
+ date: 2013-06-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef
@@ -85,20 +85,24 @@ files:
85
85
  - lib/knife-spork/plugins/foodcritic.rb
86
86
  - lib/knife-spork/plugins/git.rb
87
87
  - lib/knife-spork/plugins/graphite.rb
88
+ - lib/knife-spork/plugins/grove.rb
88
89
  - lib/knife-spork/plugins/hipchat.rb
89
90
  - lib/knife-spork/plugins/irccat.rb
90
91
  - lib/knife-spork/plugins/jabber.rb
91
92
  - lib/knife-spork/plugins/plugin.rb
93
+ - lib/knife-spork/plugins/statusnet.rb
92
94
  - lib/knife-spork/runner.rb
93
95
  - plugins/Campfire.md
94
96
  - plugins/Eventinator.md
95
97
  - plugins/Foodcritic.md
96
98
  - plugins/Git.md
97
99
  - plugins/Graphite.md
100
+ - plugins/Grove.md
98
101
  - plugins/HipChat.md
99
102
  - plugins/Irccat.md
100
103
  - plugins/Jabber.md
101
104
  - plugins/README.md
105
+ - plugins/StatusNet.md
102
106
  - plugins/Template.md
103
107
  homepage: https://github.com/jonlives/knife-spork
104
108
  licenses: []