knife-spork 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: be55378787dc1240c670fc01b68de5b616c0df95
4
- data.tar.gz: b7d5be3123fec39a5a9d85504c9574758ed918c6
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZDQ0OGMxOWQxZjQ5OWQ4OTIxM2NjZjg0ZGFiZmIxYjEwYWRlZDYyZg==
5
+ data.tar.gz: !binary |-
6
+ MDBiYmMzMjMxMjQxNzZhYmMwYzQ0MTVjNzczY2M5NTgxZWZhZTA1Nw==
5
7
  SHA512:
6
- metadata.gz: 748924e200608f02f47e63e84e1ac2acf5de5c5411d8d9d6ec2ba47fa8523bdf2580ac7c5d584757f7baa9179004bc7a4c9278cd15ba4f1e78d21e43f6714daf
7
- data.tar.gz: 5de3995fea10c3a725ec446abddb34312d7eaf48bf09c79088e67e5151656062aadde13eb6b73bc5cb2770ac51d88d8881c7f4b129cf018b90d6eca69426de79
8
+ metadata.gz: !binary |-
9
+ ZDkwOWZmNjEyNzQ3YTgzOWJmOTJkNGU1NTFhYjMwNGMwMWE5ZjAwNjJhY2M4
10
+ MGYyODgwMDdkMGY2ZTRjY2JiNDgyM2Y2NTlkNWFiYTlhMzMzNjM0YzExZjAy
11
+ MWJjMzY3YmNmZjk1NDNiYjZlOTA5YmNkZmY0NDcwNDRkZjU3YTA=
12
+ data.tar.gz: !binary |-
13
+ MTg4MGRlN2Q5YzgxNWJmZjFkODZjNDZkNTcxZDI5MDIyMTQzOTEyMDY3NGIy
14
+ MTI1NDRjMmE2OTI3NTU2OWVkY2I4NmQ3MjY0YzA1MjlmNDVkOGFkMGQyMDli
15
+ YmY5ZTlkYjE4YmRiMDYwM2RlNmI1NjZkNTFmYjVjMjZlM2Y4Nzc=
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
19
  .idea
20
+ checksums
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-1.9.3-p448
1
+ ruby-1.9.3-p484
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## 1.4.2(3rd November, 2014)
2
+
3
+ Features:
4
+
5
+ - Improve error messages when uploading invalid JSON (Thanks to @jeunito https://github.com/jonlives/knife-spork/pull/151)
6
+ - Allow an optional comma delimited set of environments to be passed to spork promote (Thanks to @jeunito https://github.com/jonlives/knife-spork/pull/148)
7
+ - Add support for rubocop >= 0.23.0 in RuboCop plugin (Thanks to @dwradcliffe https://github.com/jonlives/knife-spork/pull/147)
8
+ - Relax foodcritic version requirement from ~> 3.0.0 to >= 3.0.0 (Thanks to @dwradcliffe https://github.com/jonlives/knife-spork/pull/146)
9
+ - Slack plugin now supports adding images in messages (Thanks to @ctrlok https://github.com/jonlives/knife-spork/pull/144)
10
+ - Git plugin can now optionally commit and push on changes (Thanks to @jeunito https://github.com/jonlives/knife-spork/pull/124)
11
+
12
+ Bugfixes:
13
+
14
+ - Fix custom plugin loading on Window (Thanks to @carpnick https://github.com/jonlives/knife-spork/pull/150)
15
+ - Fix config loading in CookbookUploader under Chef 12 (Thanks to @jordane https://github.com/jonlives/knife-spork/pull/149)
16
+ - Do not attempt to load Berksfile if not present (Thanks to @redondos https://github.com/jonlives/knife-spork/pull/142)
17
+
1
18
  ## 1.4.1 (21st August, 2014)
2
19
 
3
20
  Bugfixes:
data/README.md CHANGED
@@ -2,6 +2,7 @@ KnifeSpork
2
2
  ===========
3
3
  KnifeSpork is a workflow plugin for `Chef::Knife` which helps multiple developers work on the same Chef Server and repository without treading on each other's toes. This plugin was designed around the workflow we have here at Etsy, where several people are working on the Chef repository and Chef Server simultaneously. It contains several functions, documented below:
4
4
 
5
+ [![Build Status](https://travis-ci.org/jonlives/knife-spork.svg)](https://travis-ci.org/jonlives/knife-spork)
5
6
  [![Gem Version](https://badge.fury.io/rb/knife-spork.png)](http://badge.fury.io/rb/knife-spork)
6
7
 
7
8
  Installation
@@ -79,6 +80,8 @@ plugins:
79
80
  - systems@your.conference.com/spork
80
81
  git:
81
82
  enabled: true
83
+ auto_push: true
84
+ branch: some_branch
82
85
  irccat:
83
86
  server: irccat.mydomain.com
84
87
  port: 12345
@@ -94,6 +97,7 @@ plugins:
94
97
  channel: "#sysops"
95
98
  teamname: myteam
96
99
  username: knife
100
+ icon_url: http://example.com/image.jpg
97
101
  rubocop:
98
102
  epic_fail: true
99
103
  show_name: false
@@ -153,7 +157,7 @@ knife spork info
153
157
  ```text
154
158
  $ knife spork info
155
159
  Config Hash:
156
- {"plugins"=>{"git"=>{"enabled"=>true}, "irccat"=>{"server"=>"irccat.mydomain.com", "port"=>12345, "gist"=>"usr/bin/gist", "channel"=>["#chef-announce"]}, "graphite"=>{"server"=>"graphite.mydomain.com", "port"=>2003}, "slack"=>{"api_token"=>"abc123", "channel"=>"random", "teamname"=>"myteam"}, "eventinator"=>{"url"=>"http://eventinator.mydomain.com/events/oneshot"}}, "default_environments"=>["development", "production"], "version_change_threshold"=>2, "pplugins"=>{"foodcritic"=>{"fail_tags"=>["style,correctness,test"], "tags"=>["~portability"], "include_rules"=>["config/rules.rb"]}}}
160
+ {"plugins"=>{"git"=>{"enabled"=>true}, "irccat"=>{"server"=>"irccat.mydomain.com", "port"=>12345, "gist"=>"usr/bin/gist", "channel"=>["#chef-announce"]}, "graphite"=>{"server"=>"graphite.mydomain.com", "port"=>2003}, "slack"=>{"api_token"=>"abc123", "channel"=>"random", "teamname"=>"myteam", "icon_url"=>"http://example.com/image.jpg"}, "eventinator"=>{"url"=>"http://eventinator.mydomain.com/events/oneshot"}}, "default_environments"=>["development", "production"], "version_change_threshold"=>2, "pplugins"=>{"foodcritic"=>{"fail_tags"=>["style,correctness,test"], "tags"=>["~portability"], "include_rules"=>["config/rules.rb"]}}}
157
161
 
158
162
  Plugins:
159
163
  KnifeSpork::Plugins::Campfire: disabled
@@ -278,7 +282,7 @@ Successfully uploaded apache2@1.0.13!
278
282
 
279
283
  Spork Promote
280
284
  -------------
281
- 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.
285
+ 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. To promote to multiple environments, simply pass a list of them delimited with a comma.
282
286
 
283
287
  If you don't specify an environment or environment group, the default_environments config directive will be used if set.
284
288
 
data/Rakefile CHANGED
@@ -1,2 +1,35 @@
1
1
  #!/usr/bin/env rake
2
2
  require 'bundler/gem_tasks'
3
+
4
+ require 'rspec/core/rake_task'
5
+ require 'chef_zero/server'
6
+
7
+ RSpec::Core::RakeTask.new(:spec) do |t|
8
+ t.rspec_opts = [].tap do |a|
9
+ a.push('--color')
10
+ a.push('--format doc')
11
+ end.join(' ')
12
+ end
13
+
14
+ desc 'Run all tests'
15
+ task :test => [:spec]
16
+
17
+ task :preseed_test_environment do
18
+ puts "Creating checksums directory"
19
+ `mkdir spec/unit/fixtures/checksums`
20
+ puts "Starting chef-zero server"
21
+ @server = ChefZero::Server.new(port: 4000)
22
+ @server.start_background
23
+ puts "Uploading test data"
24
+ `knife cookbook upload example -c spec/unit/fixtures/knife.rb`
25
+ `knife environment from file spec/unit/fixtures/environments/example.json -c spec/unit/fixtures/knife.rb`
26
+ end
27
+
28
+ task :cleanup_test_environment do
29
+ puts "Stopping chef-zero server"
30
+ @server.stop
31
+ puts "Cleaning up checksums"
32
+ `rm -rf spec/unit/fixtures/checksums`
33
+ end
34
+
35
+ task :default => [:preseed_test_environment, :test, :cleanup_test_environment]
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.4.1'
5
+ gem.version = '1.4.2'
6
6
  gem.authors = ["Jon Cowie"]
7
7
  gem.email = 'jonlives@gmail.com'
8
8
  gem.homepage = 'https://github.com/jonlives/knife-spork'
@@ -16,6 +16,9 @@ Gem::Specification.new do |gem|
16
16
  gem.name = "knife-spork"
17
17
  gem.require_paths = ["lib"]
18
18
 
19
+ gem.add_development_dependency 'rake'
20
+ gem.add_development_dependency 'rspec', '>= 3.1.0'
21
+ gem.add_development_dependency 'chef-zero', '>= 3.2'
19
22
  gem.add_runtime_dependency 'chef', '>= 11.0.0'
20
23
  gem.add_runtime_dependency 'git', '>= 1.2.5'
21
24
  gem.add_runtime_dependency 'app_conf', '>= 0.4.0'
@@ -84,7 +84,11 @@ module KnifeSpork
84
84
  begin
85
85
  check_dependencies(cookbook)
86
86
  if name_args.include?(cookbook.name.to_s)
87
- uploader = Chef::CookbookUploader.new(cookbook, ::Chef::Config.cookbook_path)
87
+ if Gem::Version.new(Chef::VERSION).release >= Gem::Version.new('12.0.0')
88
+ uploader = Chef::CookbookUploader.new(cookbook)
89
+ else
90
+ uploader = Chef::CookbookUploader.new(cookbook, ::Chef::Config.cookbook_path)
91
+ end
88
92
  begin
89
93
  if uploader.respond_to?(:upload_cookbooks)
90
94
  # Chef >= 10.14.0
@@ -7,7 +7,9 @@ module KnifeSpork
7
7
  hook = options[:hook].to_sym
8
8
 
9
9
  #Load each of the drop-in plugins specified in the custom plugin path
10
- Dir[File.expand_path("#{options[:config][:custom_plugin_path]}/*.rb")].each { |f| require f }
10
+ if (options[:config][:custom_plugin_path] !=nil)
11
+ Dir[File.expand_path("#{options[:config][:custom_plugin_path]}/*.rb")].each { |f| require f }
12
+ end
11
13
 
12
14
  klasses.each do |klass|
13
15
  plugin = klass.new(options)
@@ -9,7 +9,7 @@ module KnifeSpork
9
9
  def perform
10
10
  safe_require 'foodcritic'
11
11
 
12
- if Gem::Specification.find_all_by_name("foodcritic", "~> 3.0.0").empty?
12
+ if Gem::Specification.find_all_by_name("foodcritic", ">= 3.0.0").empty?
13
13
  ui.fatal "The knife-spork foodcritic plugin requires foodcritic >= 3.0.0. Please install a more recent foodcritic version."
14
14
  exit 1
15
15
  end
@@ -44,6 +44,16 @@ module KnifeSpork
44
44
  environments.each do |environment|
45
45
  git_add(environment_path,"#{environment}.json")
46
46
  end
47
+ if config.auto_push
48
+ branch = if not config.branch.nil?
49
+ config[:branch]
50
+ else
51
+ "master"
52
+ end
53
+
54
+ git_commit(environment_path, "promote #{cookbooks.collect{ |c| "#{c.name}@#{c.version}" }.join(",")} to #{environments.join(",")}")
55
+ git_push(branch)
56
+ end
47
57
  end
48
58
 
49
59
  private
@@ -52,9 +62,10 @@ module KnifeSpork
52
62
  log = Logger.new(STDOUT)
53
63
  log.level = Logger::WARN
54
64
  @git ||= begin
55
- ::Git.open('.', :log => log)
56
- rescue
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!'
65
+ cwd = FileUtils.pwd()
66
+ ::Git.open(get_parent_dir(cwd) , :log => log)
67
+ rescue Exception => e
68
+ ui.error "You are not currently in a git repository #{cwd}. Please ensure you are in a git repo, a repo subdirectory, or remove the git plugin from your KnifeSpork configuration!"
58
69
  exit(0)
59
70
  end
60
71
  end
@@ -105,21 +116,23 @@ module KnifeSpork
105
116
  end
106
117
  end
107
118
  end
108
-
109
- # Commit changes, if any
110
- def git_commit
119
+
120
+ def git_commit(filepath, msg)
111
121
  begin
112
- git.add('.')
113
- `git ls-files --deleted`.chomp.split("\n").each{ |f| git.remove(f) }
114
- git.commit_all "[KnifeSpork] Bumping cookbooks:\n#{cookbooks.collect{|c| " #{c.name}@#{c.version}"}.join("\n")}"
115
- rescue ::Git::GitExecuteError; end
122
+ if is_repo?(filepath)
123
+ ui.msg "Git: Committing changes..."
124
+ git.commit msg
125
+ end
126
+ rescue ::Git::GitExecuteError;
127
+ end
116
128
  end
117
129
 
118
- def git_push(tags = false)
130
+ def git_push(branch)
119
131
  begin
120
- git.push remote, branch, tags
132
+ ui.msg "Git: Pushing to #{branch}"
133
+ git.push "origin", branch
121
134
  rescue ::Git::GitExecuteError => e
122
- ui.error "Could not push to remote #{remote}/#{branch}. Does it exist?"
135
+ ui.error "Could not push to master: #{e.message}"
123
136
  end
124
137
  end
125
138
 
@@ -32,7 +32,7 @@ module KnifeSpork
32
32
 
33
33
  options = [ cookbook_path ]
34
34
 
35
- cli = ::Rubocop::CLI.new
35
+ cli = defined?(RuboCop) ? ::RuboCop::CLI.new : ::Rubocop::CLI.new
36
36
  result = cli.run(options)
37
37
 
38
38
  unless result == 0
@@ -100,7 +100,7 @@ module KnifeSpork
100
100
  def slack(message)
101
101
  safe_require 'slack-notifier'
102
102
  begin
103
- notifier = ::Slack::Notifier.new( config.teamname, config.api_token, channel: channel, username: username)
103
+ notifier = ::Slack::Notifier.new( config.teamname, config.api_token, channel: channel, username: username, icon_url: config.icon_url)
104
104
  notifier.ping message
105
105
  rescue Exception => e
106
106
  ui.error 'Something went wrong sending to Slack.'
@@ -36,7 +36,7 @@ module KnifeSpork
36
36
 
37
37
  environments = [ @environments || @environment ].flatten.compact.collect{|environment| environment.is_a?(::Chef::Environment) ? environment : load_environment_from_file(environment)}.sort{|a,b| a.name.to_s <=> b.name.to_s}
38
38
  environment_diffs = @environment_diffs
39
-
39
+
40
40
  KnifeSpork::Plugins.run(
41
41
  :config => spork_config,
42
42
  :hook => hook.to_sym,
@@ -54,10 +54,10 @@ module KnifeSpork
54
54
 
55
55
  def load_environments_and_cookbook
56
56
  ensure_environment_and_cookbook_provided!
57
-
57
+
58
58
  if @name_args.size == 2
59
- environments = load_specified_environment_group(@name_args[0])
60
- [ environments, @name_args[1] ]
59
+ environments = @name_args[0].split(",").map{ |env| load_specified_environment_group(env) }
60
+ [ environments.flatten, @name_args[1] ]
61
61
  elsif @name_args.size == 1
62
62
  [ [default_environments].flatten, @name_args[0] ]
63
63
  end
@@ -176,6 +176,7 @@ module KnifeSpork
176
176
 
177
177
  def load_from_berkshelf(name)
178
178
  return unless defined?(::Berkshelf)
179
+ return unless ::File.exist?(self.config[:berksfile])
179
180
  berksfile = ::Berkshelf::Berksfile.from_file(self.config[:berksfile])
180
181
  lockfile = ::Berkshelf::Lockfile.new(berksfile)
181
182
 
@@ -228,7 +229,11 @@ module KnifeSpork
228
229
  end
229
230
 
230
231
  def load_environment_from_file(environment_name)
231
- environment_loader.object_from_file("#{environment_path}/#{environment_name}.json")
232
+ begin
233
+ environment_loader.object_from_file("#{environment_path}/#{environment_name}.json")
234
+ rescue Yajl::ParseError => e
235
+ raise "#{environment_name} environment file has syntactically incorrect json.\n #{e.to_s}"
236
+ end
232
237
  end
233
238
 
234
239
  def load_remote_environment(environment_name)
data/plugins/Git.md CHANGED
@@ -23,6 +23,7 @@ plugins:
23
23
  git:
24
24
  remote: origin
25
25
  branch: master
26
+ auto_push: true
26
27
  ```
27
28
 
28
29
  **Note** Due to the nature of the git plugin, it's possible that you accept all the defaults. In that case, you should make your configuration like this:
@@ -44,3 +45,9 @@ The git branch to push/pull to/from.
44
45
 
45
46
  - Type: `String`
46
47
  - Default: `master`
48
+
49
+ #### auto_push
50
+ An optional true / false parameter indicating whether or not changes should be automatically comitted and pushed to Git
51
+
52
+ - Type: `Boolean`
53
+ - Default: `false`
data/plugins/Slack.md CHANGED
@@ -44,4 +44,9 @@ The teamname of the slack account. ex. https://TEAMNAME.slack.com
44
44
  #### username
45
45
  The username to post as.
46
46
 
47
- - Type: `String`
47
+ - Type: `String`
48
+
49
+ #### icon_url
50
+ The url for icon. ex. https://example.com/image.jpg, default: nil
51
+
52
+ - Type: `String`
@@ -0,0 +1,10 @@
1
+ require 'test_helpers'
2
+
3
+ RSpec.configure do |c|
4
+ c.include TestHelpers
5
+ c.expect_with :rspec do |config|
6
+ config.syntax = [:should, :expect]
7
+ end
8
+ c.filter_run :focus => true
9
+ c.run_all_when_everything_filtered = true
10
+ end
@@ -0,0 +1,46 @@
1
+ require 'fileutils'
2
+ require 'tmpdir'
3
+
4
+ module TestHelpers
5
+ def tempdir
6
+ @tmpdir ||= Dir.mktmpdir("knife-spork")
7
+ File.realpath(@tmpdir)
8
+ end
9
+
10
+ def fixtures_path
11
+ File.expand_path(File.dirname(__FILE__) + "/unit/fixtures/")
12
+ end
13
+
14
+ def cookbook_path
15
+ File.expand_path('cookbooks', tempdir)
16
+ end
17
+
18
+ def environment_path
19
+ File.expand_path('environments', tempdir)
20
+ end
21
+
22
+ def stdout
23
+ stdout_io.string
24
+ end
25
+
26
+ def set_chef_config
27
+ knife.config[:chef_repo_path] = tempdir
28
+ knife.config[:cookbook_path] = File.join(tempdir, 'cookbooks')
29
+ knife.config[:environment_path] = File.join(tempdir, 'environments')
30
+ knife.config[:chef_server_url] = "http://localhost:4000"
31
+ knife.config[:client_key] = File.join(tempdir, 'test_client.pem')
32
+ knife.config[:client_name] = "test-client"
33
+ knife.config[:node_name] = "test-node"
34
+ knife.config[:cache_type] = 'BasicFile'
35
+ knife.config[:cache_options] = {:path => File.join(tempdir, 'checksums')}
36
+ end
37
+
38
+
39
+ def copy_test_data
40
+ FileUtils.cp_r "#{fixtures_path}/.", tempdir
41
+ end
42
+
43
+ def cleanup_test_data
44
+ FileUtils.rm_r Dir.glob("#{tempdir}/*")
45
+ end
46
+ end
@@ -0,0 +1 @@
1
+ plugins:
@@ -0,0 +1,7 @@
1
+ maintainer "Jon Cowie"
2
+ maintainer_email "jonlives@gmail.com"
3
+ license "All rights reserved"
4
+ description "Test cookbook for knife-spork"
5
+ long_description "Test cookbook for knife-spork"
6
+ version "0.0.1"
7
+
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "example",
3
+ "description": "This is an example environment",
4
+ "cookbook_versions": {
5
+ },
6
+ "json_class": "Chef::Environment",
7
+ "chef_type": "environment",
8
+ "default_attributes": {
9
+ },
10
+ "override_attributes": {
11
+ }
12
+ }
@@ -0,0 +1,6 @@
1
+ chef_server_url 'http://127.0.0.1:4000'
2
+ node_name 'test-node'
3
+ client_key 'test_client.pem'
4
+ chef_repo_path 'spec/unit/fixtures'
5
+ cookbook_path 'spec/unit/fixtures/cookbooks'
6
+ cache_options( :path => 'checksums' )
@@ -0,0 +1,27 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIIEowIBAAKCAQEA6NLSaRTs1vQEuFhhBjaEuVzrPoz59U+8w8bhyL5sXXzFatVm
3
+ t1uCtmOaaqE8QsOQG2rdaoW/YXjErg/xyzW3Z0q++RekYx6guvTbpKHoSzgqG8AJ
4
+ wpVXn9wXKRgOHpGCvyaqMNvHpEmQdjJfFTZ5yJtDdRQbWMincs14VbuVlNniMmmF
5
+ thw3lMgPpEs/tf7a+V23BroYBCslsAoQb4Sb4kIVVWLAuBXOdfRxOY0XH/lqKn9w
6
+ r4/Lh6Iw3Sf6zVUI0WhBhhohP2aQhZu3CwA+B2wmEcaUrnVwuJJZcJ5NEwa7ysXk
7
+ AGh4erlxl8vK7lbootF/vnvLqrYEdaleINGflwIDAQABAoIBAF/t9ao8Z/WNZ6B5
8
+ Mcj4j6k8guUr+xW7fACCoqcu5sGCVmlVclQcTXhPA+Hpe0XbBDZ3yrFIWHmV5BwA
9
+ D9V11ZKmtpc1yZLZnMpLd3CXEXpkstzqPFtDY25HpfdVpQOtWtzd1oP5GoIzmWVK
10
+ DelUn8srRhkoZrgnPO9Nf8Z7Wv+QGaanGyiTvEbP3/ZYbKs6aXMkF1eJf1iubUWq
11
+ jgtN9dGyvglhKNMNxo2O88MJOPWqmwrdYQGbCXJ2aPcjchRVQrdr55yaCvP9QV3P
12
+ TIqJwsIS6fvpuhTfjpIjGKtClWubh9sVS74G9HOus908u8VQLizjkeWa3Tmcqk+t
13
+ a8HJQZECgYEA+lk4osTUbSOQu3tSLwNoDLL1pJnJ2bZ/SM1O6yLTbpqom0dyh/xC
14
+ ffy+iua9Ngu7dHJDc69FxqPhLlWl2KzZKvh1V7J/TVBcknVP84OKSBttc4pWN5Zv
15
+ jkOoewI3e+0RA2Gx3+QuLea6iaV0lZ7pq5rbQv49z3qa2glCr6q4iykCgYEA7hRS
16
+ nDPaXnvBxglv9YobXTmkB/ZxsLO4h3Tm5CHoKYTp4f8oEaJnGVd0lzp3aGw3DSac
17
+ Z8xdStTe+6HBeFDIjaVjb693+2aE1iGoZMry93zZd5mxBS0XiG72hu7ZfFzthl3v
18
+ 72lTTj2xpRTt17p/xwl7LITPxGtl0ychUY0Y7L8CgYAz/lG35F8l54wIk/0mjHOQ
19
+ p55CuDnmwHNBAHrSdOIqh25bCYSs32RD3DkKig9j6R3eelit7wnzzldXEyyliohz
20
+ 1zQvqX+s4/LF7B1Vusz+WsvpgiKT2ueCSWT1Xyl80GiHJkQV9sLsf43gRn+nD2EC
21
+ ZeAB0uGtdI4ymFfEOhWnuQKBgDyZ+7U7Fbi7M8XfHRqZPwHp7DECsEnUVYJVZXho
22
+ kRoQdSBLvL1QY4H12v2rqj1wXksAqwtY395udRwEPqULmyFDGh6Rwa7Cl8mR47VU
23
+ W6hXpVtmScMRiU33QNVz8vRPCz8KpkqAuu3Nkmx8+VXSaTgW172rSN+snsyyxy5l
24
+ BhUtAoGBAOr4jeJKT0jzeDJwLhrxctZkSkka0wCPe17d0+IfBbZ+XyQXFt+enuH1
25
+ cMZ8IJr+nKHojjey7AunhYBtwQEv50Ul8TfvjUuqUY34xSVRAZD90LETZTVsq2QF
26
+ q3wN75pqCHF55t/L5K2drAIxcfhBo/olgTvN91vGYXNieFh9PREl
27
+ -----END RSA PRIVATE KEY-----
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+ require 'chef/knife/spork-bump'
3
+ require 'knife-spork/runner'
4
+ require 'fileutils'
5
+
6
+ module KnifeSpork
7
+ describe SporkBump do
8
+
9
+ let(:stdout_io) { StringIO.new }
10
+ let(:stderr_io) { StringIO.new }
11
+
12
+ subject(:knife) do
13
+ SporkBump.new(argv).tap do |c|
14
+ allow(c.ui).to receive(:stdout).and_return(stdout_io)
15
+ end
16
+ end
17
+
18
+ before(:all) do
19
+ copy_test_data
20
+ end
21
+
22
+ after(:all) do
23
+ cleanup_test_data
24
+ end
25
+
26
+ let(:argv) { ["example"] }
27
+
28
+ let(:metadata_file) { "#{cookbook_path}/example/metadata.rb" }
29
+
30
+ describe '#run' do
31
+ before(:each) { set_chef_config }
32
+ it 'calls bump method' do
33
+ expect(knife).to receive(:bump)
34
+ knife.run
35
+ end
36
+ end
37
+
38
+ describe '#bump' do
39
+ before(:each) { set_chef_config }
40
+ it 'automatically bumps patch level' do
41
+ knife.instance_variable_set(:@cookbook, knife.load_cookbook(argv.first))
42
+ knife.send(:bump)
43
+ File.read(metadata_file).should include "version \"0.0.2\""
44
+ end
45
+
46
+ it 'manually bumps patch version level' do
47
+ knife.instance_variable_set(:@cookbook, knife.load_cookbook(argv.first))
48
+ knife.instance_variable_set(:@name_args, ["example","patch"])
49
+ knife.send(:bump)
50
+ File.read(metadata_file).should include "version \"0.0.3\""
51
+ end
52
+
53
+ it 'manually bumps minor version level' do
54
+ knife.instance_variable_set(:@cookbook, knife.load_cookbook(argv.first))
55
+ knife.instance_variable_set(:@name_args, ["example","minor"])
56
+ knife.send(:bump)
57
+ File.read(metadata_file).should include "version \"0.1.0\""
58
+ end
59
+
60
+ it 'manually bumps major version level' do
61
+ knife.instance_variable_set(:@cookbook, knife.load_cookbook(argv.first))
62
+ knife.instance_variable_set(:@name_args, ["example","major"])
63
+ knife.send(:bump)
64
+ File.read(metadata_file).should include "version \"1.0.0\""
65
+ end
66
+
67
+ it 'manually sets version to 0.0.1' do
68
+ knife.instance_variable_set(:@cookbook, knife.load_cookbook(argv.first))
69
+ knife.instance_variable_set(:@name_args, ["example", "manual", "0.0.1"])
70
+ knife.send(:bump)
71
+ File.read(metadata_file).should include "version \"0.0.1\""
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+ require 'chef/knife/spork-info'
3
+ require 'knife-spork/runner'
4
+
5
+ module KnifeSpork
6
+ describe SporkInfo do
7
+
8
+ let(:stdout_io) { StringIO.new }
9
+ let(:stderr_io) { StringIO.new }
10
+
11
+ subject(:knife) do
12
+ SporkInfo.new(argv).tap do |c|
13
+ allow(c.ui).to receive(:stdout).and_return(stdout_io)
14
+ end
15
+ end
16
+
17
+ let(:argv) { [] }
18
+
19
+ describe '#run' do
20
+ it 'displays spork info' do
21
+ expect(knife).to receive(:info)
22
+ knife.run
23
+ end
24
+ end
25
+
26
+ describe '#info' do
27
+ before(:each) { set_chef_config }
28
+ let(:fake_ui) { double(:ui, msg: nil) }
29
+
30
+ before do
31
+ allow(knife).to receive(:ui) { fake_ui }
32
+ end
33
+
34
+ it 'only calls ui.msg' do
35
+ expect(fake_ui).to receive(:msg)
36
+ knife.send(:info)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+ require 'chef/knife/spork-promote'
3
+ require 'knife-spork/runner'
4
+
5
+ module KnifeSpork
6
+ describe SporkPromote do
7
+
8
+ let(:stdout_io) { StringIO.new }
9
+ let(:stderr_io) { StringIO.new }
10
+
11
+ before(:all) do
12
+ copy_test_data
13
+ end
14
+
15
+ after(:all) do
16
+ cleanup_test_data
17
+ end
18
+
19
+ subject(:knife) do
20
+ SporkPromote.new(argv).tap do |c|
21
+ allow(c.ui).to receive(:stdout).and_return(stdout_io)
22
+ end
23
+ end
24
+
25
+ let(:environment_file) { "#{environment_path}/example.json" }
26
+
27
+ let(:argv) { ["example", "example"] }
28
+
29
+ describe '#run' do
30
+ before(:each) { set_chef_config }
31
+ it 'calls promote method' do
32
+ expect(knife).to receive(:promote)
33
+ knife.run
34
+ end
35
+
36
+ it 'calls save_environment_changes method by default' do
37
+ expect(knife).to receive(:save_environment_changes)
38
+ knife.run
39
+ end
40
+
41
+ it 'calls save_environment_changes_remote method when --remote is specified' do
42
+ knife.config[:remote] = true
43
+ expect(knife).to receive(:save_environment_changes_remote)
44
+ knife.run
45
+ end
46
+ end
47
+
48
+ describe '#promote' do
49
+ before(:each) { set_chef_config }
50
+ it 'updates version constraint for cookbook' do
51
+ knife.instance_variable_set(:@environments, ["example"])
52
+ knife.instance_variable_set(:@cookbook, "example")
53
+ expect(knife).to receive(:update_version_constraints)
54
+ knife.send(:promote, knife.load_environment_from_file("example"), "example")
55
+ end
56
+ end
57
+
58
+ describe '#save_environment_changes' do
59
+ before(:each) { set_chef_config }
60
+ it 'updates the constraint in the environment file' do
61
+ knife.instance_variable_set(:@environments, ["example"])
62
+ knife.instance_variable_set(:@cookbook, "example")
63
+ knife.send(:save_environment_changes, "example", knife.pretty_print_json(knife.load_environment_from_file("example").to_hash))
64
+ File.read(environment_file).should include "\"example\": \"= 0.0.1\""
65
+ end
66
+ end
67
+
68
+ describe '#save_environment_changes_remote' do
69
+ before(:each) { set_chef_config }
70
+ it 'saves the environment change to the server' do
71
+ knife.instance_variable_set(:@environments, ["example"])
72
+ knife.instance_variable_set(:@cookbook, "example")
73
+ knife.send(:save_environment_changes_remote, "example")
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+ require 'chef/knife/spork-upload'
3
+ require 'chef/cookbook_uploader'
4
+ require 'knife-spork/runner'
5
+
6
+ module KnifeSpork
7
+ describe SporkUpload do
8
+
9
+ let(:stdout_io) { StringIO.new }
10
+ let(:stderr_io) { StringIO.new }
11
+
12
+ before(:all) do
13
+ copy_test_data
14
+ end
15
+
16
+ after(:all) do
17
+ cleanup_test_data
18
+ end
19
+
20
+ subject(:knife) do
21
+ SporkUpload.new(argv).tap do |c|
22
+ allow(c.ui).to receive(:stdout).and_return(stdout_io)
23
+ end
24
+ end
25
+
26
+ let(:argv) { ["example"] }
27
+
28
+ describe '#run' do
29
+ before(:each) { set_chef_config }
30
+ it 'calls upload method' do
31
+ expect(knife).to receive(:upload)
32
+ knife.run
33
+ end
34
+ end
35
+
36
+ describe '#upload' do
37
+ before(:each) { set_chef_config }
38
+ it 'uploads cookbook' do
39
+ knife.instance_variable_set(:@cookbooks, knife.load_cookbooks(argv))
40
+ knife.send(:upload)
41
+ end
42
+ end
43
+ end
44
+ end
metadata CHANGED
@@ -1,69 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-spork
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Cowie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-21 00:00:00.000000000 Z
11
+ date: 2014-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 3.1.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 3.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: chef-zero
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '3.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '3.2'
13
55
  - !ruby/object:Gem::Dependency
14
56
  name: chef
15
57
  requirement: !ruby/object:Gem::Requirement
16
58
  requirements:
17
- - - '>='
59
+ - - ! '>='
18
60
  - !ruby/object:Gem::Version
19
61
  version: 11.0.0
20
62
  type: :runtime
21
63
  prerelease: false
22
64
  version_requirements: !ruby/object:Gem::Requirement
23
65
  requirements:
24
- - - '>='
66
+ - - ! '>='
25
67
  - !ruby/object:Gem::Version
26
68
  version: 11.0.0
27
69
  - !ruby/object:Gem::Dependency
28
70
  name: git
29
71
  requirement: !ruby/object:Gem::Requirement
30
72
  requirements:
31
- - - '>='
73
+ - - ! '>='
32
74
  - !ruby/object:Gem::Version
33
75
  version: 1.2.5
34
76
  type: :runtime
35
77
  prerelease: false
36
78
  version_requirements: !ruby/object:Gem::Requirement
37
79
  requirements:
38
- - - '>='
80
+ - - ! '>='
39
81
  - !ruby/object:Gem::Version
40
82
  version: 1.2.5
41
83
  - !ruby/object:Gem::Dependency
42
84
  name: app_conf
43
85
  requirement: !ruby/object:Gem::Requirement
44
86
  requirements:
45
- - - '>='
87
+ - - ! '>='
46
88
  - !ruby/object:Gem::Version
47
89
  version: 0.4.0
48
90
  type: :runtime
49
91
  prerelease: false
50
92
  version_requirements: !ruby/object:Gem::Requirement
51
93
  requirements:
52
- - - '>='
94
+ - - ! '>='
53
95
  - !ruby/object:Gem::Version
54
96
  version: 0.4.0
55
97
  - !ruby/object:Gem::Dependency
56
98
  name: diffy
57
99
  requirement: !ruby/object:Gem::Requirement
58
100
  requirements:
59
- - - '>='
101
+ - - ! '>='
60
102
  - !ruby/object:Gem::Version
61
103
  version: 3.0.1
62
104
  type: :runtime
63
105
  prerelease: false
64
106
  version_requirements: !ruby/object:Gem::Requirement
65
107
  requirements:
66
- - - '>='
108
+ - - ! '>='
67
109
  - !ruby/object:Gem::Version
68
110
  version: 3.0.1
69
111
  description: KnifeSpork is a workflow plugin for Chef::Knife which helps multiple
@@ -78,6 +120,7 @@ files:
78
120
  - .gitignore
79
121
  - .ruby-gemset
80
122
  - .ruby-version
123
+ - .travis.yml
81
124
  - CHANGELOG.md
82
125
  - Gemfile
83
126
  - LICENSE
@@ -140,6 +183,17 @@ files:
140
183
  - plugins/Slack.md
141
184
  - plugins/StatusNet.md
142
185
  - plugins/Template.md
186
+ - spec/spec_helper.rb
187
+ - spec/test_helpers.rb
188
+ - spec/unit/fixtures/config/spork-config.yml
189
+ - spec/unit/fixtures/cookbooks/example/metadata.rb
190
+ - spec/unit/fixtures/environments/example.json
191
+ - spec/unit/fixtures/knife.rb
192
+ - spec/unit/fixtures/test_client.pem
193
+ - spec/unit/spork_bump_spec.rb
194
+ - spec/unit/spork_info_spec.rb
195
+ - spec/unit/spork_promote_spec.rb
196
+ - spec/unit/spork_upload_spec.rb
143
197
  homepage: https://github.com/jonlives/knife-spork
144
198
  licenses:
145
199
  - GPL
@@ -150,18 +204,29 @@ require_paths:
150
204
  - lib
151
205
  required_ruby_version: !ruby/object:Gem::Requirement
152
206
  requirements:
153
- - - '>='
207
+ - - ! '>='
154
208
  - !ruby/object:Gem::Version
155
209
  version: '0'
156
210
  required_rubygems_version: !ruby/object:Gem::Requirement
157
211
  requirements:
158
- - - '>='
212
+ - - ! '>='
159
213
  - !ruby/object:Gem::Version
160
214
  version: '0'
161
215
  requirements: []
162
216
  rubyforge_project:
163
- rubygems_version: 2.0.14
217
+ rubygems_version: 2.2.2
164
218
  signing_key:
165
219
  specification_version: 4
166
220
  summary: A workflow plugin to help many devs work with the same chef repo/server
167
- test_files: []
221
+ test_files:
222
+ - spec/spec_helper.rb
223
+ - spec/test_helpers.rb
224
+ - spec/unit/fixtures/config/spork-config.yml
225
+ - spec/unit/fixtures/cookbooks/example/metadata.rb
226
+ - spec/unit/fixtures/environments/example.json
227
+ - spec/unit/fixtures/knife.rb
228
+ - spec/unit/fixtures/test_client.pem
229
+ - spec/unit/spork_bump_spec.rb
230
+ - spec/unit/spork_info_spec.rb
231
+ - spec/unit/spork_promote_spec.rb
232
+ - spec/unit/spork_upload_spec.rb