Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omni config #122

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -99,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"
Expand Down Expand Up @@ -289,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
Expand All @@ -299,12 +304,14 @@ Alternatively, you can specify any of the following options:

```--environment ENVIRONMENT```: Environment to promote the cookbook to',

```--promote```: Omni will run promote, overrides config setting.

```--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, --promote]
```

#### Example (default options, default_environments set to development and production)
Expand Down
10 changes: 9 additions & 1 deletion lib/chef/knife/spork-omni.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -49,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!'
Expand Down Expand Up @@ -101,7 +107,9 @@ def omni(cookbook)
ui.msg ""
upload(cookbook)
ui.msg ""
promote(cookbook)
if config[:omni_promote]
promote(cookbook)
end
end
end
end
4 changes: 4 additions & 0 deletions lib/knife-spork/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down