From 44082ea5fc311bfc06652862215529beecf03684 Mon Sep 17 00:00:00 2001 From: chazzly Date: Wed, 23 Apr 2014 00:18:40 -0700 Subject: [PATCH 1/6] Create Rubocop.md --- plugins/Rubocop.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 plugins/Rubocop.md diff --git a/plugins/Rubocop.md b/plugins/Rubocop.md new file mode 100644 index 0000000..eb8a248 --- /dev/null +++ b/plugins/Rubocop.md @@ -0,0 +1,34 @@ +Rubocop +========== +Automatically runs rubocop against your cookbooks on check and upload. +This is based entirely off of the Foodcritic plug-in + +Gem Requirements +---------------- +This plugin requires the following gems: + +```ruby +gem 'rubocop' +``` + +Hooks +----- +- `after_check` +- `before_upload` + +Configuration +------------- +```yaml +plugins: + foodcritic: + epic_fail: true +``` + +#### epic_fail: +If set to true, `epic_fail` will prevent you from uploading a cookbook until all foodcritic rules pass. + +- Type: `Boolean` +- Default: `true` + +#### TO-DO +Would like to include options to set severity-level and possibly specifiying output file. From 41b893f6530183059c1cb42858a9e586f071d6c7 Mon Sep 17 00:00:00 2001 From: Chaz Ruhl Date: Fri, 2 May 2014 16:19:51 -0500 Subject: [PATCH 2/6] First pass at making promote optional for omni --- README.md | 5 ++++- lib/chef/knife/spork-omni.rb | 9 ++++++++- lib/knife-spork/runner.rb | 4 ++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 89a1a4c..adc5d58 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ environment_path: "/home/me/environments" role_path: "/home/me/roles" custom_plugin_path: "/home/me/spork-plugins" always_promote_remote: true +omni_promote: true plugins: campfire: account: myaccount @@ -299,12 +300,14 @@ Alternatively, you can specify any of the following options: ```--environment ENVIRONMENT```: Environment to promote the cookbook to', +```--no_promote```: Does NOT promote the cookbook', + ```--remote```: Make omni perform a promote --remote instead of a local promote', #### Usage ```bash -knife spork omni COOKBOOK [--bump-level, --cookbook-path, --include-dependencies, --environment, --remote] +knife spork omni COOKBOOK [--bump-level, --cookbook-path, --include-dependencies, --environment, --remote, --no_promote] ``` #### Example (default options, default_environments set to development and production) diff --git a/lib/chef/knife/spork-omni.rb b/lib/chef/knife/spork-omni.rb index 5f8b889..ac9a58e 100644 --- a/lib/chef/knife/spork-omni.rb +++ b/lib/chef/knife/spork-omni.rb @@ -34,6 +34,11 @@ class SporkOmni < Chef::Knife :description => 'Environment to promote the cookbook to', :default => nil + option :omni_promote, + :long => '--promote', + :description => 'Omni will run promote, overrides config setting', + :default => nil + option :remote, :long => '--remote', :description => 'Make omni finish with promote --remote instead of a local promote', @@ -101,7 +106,9 @@ def omni(cookbook) ui.msg "" upload(cookbook) ui.msg "" - promote(cookbook) + if config[:omni_promote] + promote(cookbook) + end end end end diff --git a/lib/knife-spork/runner.rb b/lib/knife-spork/runner.rb index 20fc601..73a8b27 100644 --- a/lib/knife-spork/runner.rb +++ b/lib/knife-spork/runner.rb @@ -114,6 +114,10 @@ def cookbook_path [config[:cookbook_path] ||= ::Chef::Config.cookbook_path].flatten[0] end + def omni_promote + spork_config[:omni_promote] || true + end + def environment_path spork_config[:environment_path] || cookbook_path.gsub("/cookbooks","/environments") end From 7123032bafd89247a56c7c69fbfc2e69b74ffe6f Mon Sep 17 00:00:00 2001 From: Chaz Ruhl Date: Mon, 5 May 2014 09:32:32 -0700 Subject: [PATCH 3/6] Delete Rubocop.md added this to the wrong branch - removing to correct. --- plugins/Rubocop.md | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 plugins/Rubocop.md diff --git a/plugins/Rubocop.md b/plugins/Rubocop.md deleted file mode 100644 index eb8a248..0000000 --- a/plugins/Rubocop.md +++ /dev/null @@ -1,34 +0,0 @@ -Rubocop -========== -Automatically runs rubocop against your cookbooks on check and upload. -This is based entirely off of the Foodcritic plug-in - -Gem Requirements ----------------- -This plugin requires the following gems: - -```ruby -gem 'rubocop' -``` - -Hooks ------ -- `after_check` -- `before_upload` - -Configuration -------------- -```yaml -plugins: - foodcritic: - epic_fail: true -``` - -#### epic_fail: -If set to true, `epic_fail` will prevent you from uploading a cookbook until all foodcritic rules pass. - -- Type: `Boolean` -- Default: `true` - -#### TO-DO -Would like to include options to set severity-level and possibly specifiying output file. From 8bf2ee0dfe87495a92aa91c8cf43f8b76da109d7 Mon Sep 17 00:00:00 2001 From: Chaz Ruhl Date: Mon, 5 May 2014 09:46:03 -0700 Subject: [PATCH 4/6] Update README.md Corrected and expanded on Omnit_promote option description. --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index adc5d58..80bad98 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,8 @@ The `version_change_threshold` directive allows you to customise the threshold u #### Always Promote Remote The `always_promote_remote` directive allows you to tell spork promote to always act as if the --remote option had been specified. This will also have the same effect on spork omni. This option should only be used if you're sure you want all changes to be uploaded to the server as soon as you run promote. +#### Omni Promote +The omni_promote directive tells spork omni whether or not to promote your cookbook to the provided environment. True(default) means omni will run the promote. False means omni will skip the promote step. The bump and upload steps will still be performned. A setting of false can be overridden on the command line with the --promote option. #### Environment Path The `environment_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" @@ -290,6 +292,8 @@ As omni is designed for use only in those cases where you want to perform all th If you run omni with no extra options, it will default to performing a ```patch``` level bump, and promote locally to the environments listed in the ```default_environments``` variable in your spork configuration file. +Omni can be configured to skip the promote step by specifing "omni_promote: false" in the config file. By default, this is set to true. + Alternatively, you can specify any of the following options: ```--cookbook-path PATH:PATH```: A colon-separated path to look for cookbooks in @@ -300,7 +304,7 @@ Alternatively, you can specify any of the following options: ```--environment ENVIRONMENT```: Environment to promote the cookbook to', -```--no_promote```: Does NOT promote the cookbook', +```--promote```: Omni will run promote, overrides config setting. ```--remote```: Make omni perform a promote --remote instead of a local promote', From 7ff735d97342935b8c10c73986cd968d98f00686 Mon Sep 17 00:00:00 2001 From: Chaz Ruhl Date: Mon, 5 May 2014 09:50:32 -0700 Subject: [PATCH 5/6] Update README.md Corrected typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 80bad98..58be37e 100644 --- a/README.md +++ b/README.md @@ -311,7 +311,7 @@ Alternatively, you can specify any of the following options: #### Usage ```bash -knife spork omni COOKBOOK [--bump-level, --cookbook-path, --include-dependencies, --environment, --remote, --no_promote] +knife spork omni COOKBOOK [--bump-level, --cookbook-path, --include-dependencies, --environment, --remote, --promote] ``` #### Example (default options, default_environments set to development and production) From 6cc7eed4ee5c17dedff24c379af52d8139ab8482 Mon Sep 17 00:00:00 2001 From: chazzly Date: Wed, 7 May 2014 16:52:13 -0500 Subject: [PATCH 6/6] Was referencing config file incorrectly. Fixed. --- lib/chef/knife/spork-omni.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/chef/knife/spork-omni.rb b/lib/chef/knife/spork-omni.rb index ac9a58e..7f24835 100644 --- a/lib/chef/knife/spork-omni.rb +++ b/lib/chef/knife/spork-omni.rb @@ -54,6 +54,7 @@ class SporkOmni < Chef::Knife def run self.config = Chef::Config.merge!(config) + config[:omni_promote] ||= spork_config.omni_promote if name_args.empty? ui.fatal 'You must specify a cookbook name!'