comrad 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7dfa87d9578aa1e1a8b8b7a97478bcf05bd1cf44
4
- data.tar.gz: bd6185ef69ad44addb7361a29bccb76d6911390f
3
+ metadata.gz: 2926a0719cb7f9bd18f2524c428aaf197d5511f9
4
+ data.tar.gz: 6abec92ec8804e07c3442480bde7328128c5f1e2
5
5
  SHA512:
6
- metadata.gz: ce3f3ffcc9414ec1961e6b42036698bdf7d3baef589775de4e150c958a0ba51f0a38c3e2a079ff8208c2c1da6f19304d8caed793853e193487a506dffe4506e3
7
- data.tar.gz: 8dac30ea4540aceda52244d4aeb376ee1e46c4a6f05b142bc657de30c2760574976e792e937582060cca7e48e0da2f9d091bd59e3e9e4be1fef08c851ea73e40
6
+ metadata.gz: 742c737000629566f0f19e25d2e31edf4735daec6c1911e607f580996003e71be6d00a30b84c56556a0bd28641c28fe82dacce3ad3ad9e1bbdb835c3292c115a
7
+ data.tar.gz: 05999c5cabf106dd56f267db5c7aa7f949921203a062167063c55e5eafb72ad660b2cbec93620e42e3603e48a17593959af0ffca88a50dc9f9733bdf4db3c619
@@ -1,3 +1,4 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  cache:
3
4
  - bundler
data/README.md CHANGED
@@ -23,7 +23,7 @@ Example YAML config:
23
23
  ---
24
24
  slack:
25
25
  webhook_url: 'https://hooks.slack.com/services/123/123/123
26
- channel: 'ops-channel'
26
+ channel: '#ops-channel'
27
27
  jenkins:
28
28
  workspace_dir: '/var/jenkins/workspaces/myjob/'
29
29
  url: 'http://jenkins.int.myco.co/'
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'comrad'
3
- s.version = '0.1.4'
3
+ s.version = '0.2.0'
4
4
  s.date = Date.today.to_s
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.extra_rdoc_files = ['README.md', 'LICENSE']
@@ -14,9 +14,9 @@ Gem::Specification.new do |s|
14
14
  s.required_ruby_version = '>= 1.9.3'
15
15
  s.add_dependency 'rest-client', '~> 1.7.0'
16
16
  s.add_dependency 'chef', '>= 11.0'
17
- s.add_dependency 'slack-post', '~> 0.3', '>= 0.3.1'
17
+ s.add_dependency 'slack-post', '~> 0.3', '>= 0.3.2'
18
18
  s.add_development_dependency 'rake', '~> 10.0'
19
- s.add_development_dependency 'rubocop', '~> 0.32.0'
19
+ s.add_development_dependency 'rubocop', '~> 0.33.0'
20
20
 
21
21
  s.files = `git ls-files -z`.split("\x0")
22
22
  s.executables = s.name
@@ -15,8 +15,6 @@
15
15
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
- require 'pp'
19
-
20
18
  require 'core_ext/string'
21
19
 
22
20
  require 'comrad/config'
@@ -44,7 +42,7 @@ module Comrad
44
42
  end
45
43
 
46
44
  'The following chef objects will be changed'.marquee
47
- pp Changeset.changes
45
+ puts Changeset.changes.to_yaml.gsub("---\n", '')
48
46
 
49
47
  'Making Chef Changes'.marquee
50
48
  Chef.process_changes
@@ -42,12 +42,28 @@ module Comrad
42
42
  ]
43
43
  end
44
44
 
45
- # run the provided knife command
46
- def self::excute_knife_cmd(cmd)
45
+ # handle the actual shell out
46
+ def self::shell_out(cmd)
47
+ require 'open3'
48
+ puts "Running #{cmd}..."
49
+ Open3.popen3(cmd) do |_stdin, _stdout, stderr, thread|
50
+ unless thread.value.success?
51
+ puts 'Failed to run the knife command with the following error:'.to_red
52
+ puts stderr.read
53
+ end
54
+ end
55
+ end
56
+
57
+ # determine if we should shell out or print and then do it
58
+ def self::execute_knife_cmd(cmd)
59
+ # dry mode will just show what we would do
47
60
  if Config.config['flags']['dryrun']
48
61
  puts "I would be running '#{cmd}'"
49
- else
50
- puts "Live mode is not implemented. Not performing '#{cmd}'"
62
+ # are we in scary mode or not running a delete command
63
+ elsif Config.config['flags']['scary'] || !cmd.include?('delete')
64
+ shell_out(cmd)
65
+ else # we're trying to delete something w/o scary mode enabled
66
+ puts "#{cmd} skipped. Enable scary-mode to allow deletes."
51
67
  end
52
68
  end
53
69
 
@@ -56,7 +72,7 @@ module Comrad
56
72
  Changeset.changes.each_pair do |item_class, action_pairs|
57
73
  next if action_pairs.empty?
58
74
  action_pairs.each_pair do |item, action|
59
- excute_knife_cmd(knife_command(item_class, item, action))
75
+ execute_knife_cmd(knife_command(item_class, item, action))
60
76
  end
61
77
  end
62
78
  end
@@ -45,7 +45,7 @@ module Comrad
45
45
  # make sure we have a build number
46
46
  def self::validate_config(conf)
47
47
  if conf['buildnum'].nil?
48
- puts "Jenkins set BUILD_NUMBER environmental variable not set, and Comrad --buildnum CLI flag not used. Cannot continue without a build number.\n\n"
48
+ puts "Jenkins set BUILD_NUMBER environmental variable not set, and Comrad --build-num CLI flag not used. Cannot continue without a build number.\n\n"
49
49
  exit!
50
50
  end
51
51
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comrad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-10 00:00:00.000000000 Z
11
+ date: 2015-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -47,7 +47,7 @@ dependencies:
47
47
  version: '0.3'
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
- version: 0.3.1
50
+ version: 0.3.2
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -57,7 +57,7 @@ dependencies:
57
57
  version: '0.3'
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: 0.3.1
60
+ version: 0.3.2
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rake
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -78,14 +78,14 @@ dependencies:
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: 0.32.0
81
+ version: 0.33.0
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: 0.32.0
88
+ version: 0.33.0
89
89
  description: Your rad comrade - Sync changes from git to Chef Server via Jenkins
90
90
  email: tim@cozy.co
91
91
  executables:
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  version: '0'
137
137
  requirements: []
138
138
  rubyforge_project:
139
- rubygems_version: 2.4.5
139
+ rubygems_version: 2.4.8
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: Your rad comrade - Sync changes from git to Chef Server via Jenkins