comrad 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/comrad.gemspec +1 -1
  3. data/lib/chef.rb +5 -4
  4. data/lib/config.rb +10 -0
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c025f9b0f7635289a2928c16ecd2abd75aca50ac
4
- data.tar.gz: d9ad964457654495bc3e72ea4a5089d4c71bc408
3
+ metadata.gz: 66c6919f9e828f044c58110f1f249c397bf8b30f
4
+ data.tar.gz: bfe6cea60a7b4284a42f4cfff6e46684da3520ff
5
5
  SHA512:
6
- metadata.gz: 956d61a82b6afcf60e235acf4ad1b5cdde4e60902eb5c713795f7942c5bcc08d2cc64daeba4451fd041d2abcf815bdcd6b63df61c0e243031fe9087573b08b8f
7
- data.tar.gz: 02beca7237741be37ceb76ff74983fa4534f554377310632b76c1da55b4a6126d09254cc6a80343188f416f0513963b4cca89fad0bce69d9bf9f33ec0e3cdb4d
6
+ metadata.gz: 8a3c112332856871089428d59ea4ad98f0ba0f8c5b7e155552c8854961e74b62849a3d66f0e59f88c207b1083565f6252c989854b2d5f91bbc230b9d039dd715
7
+ data.tar.gz: 2b8c623f22b0d0ea2fd7ac9611a5c2625bb6f7612d1cb8632d0320006fc68d9937f4ea3c93a8bb2aafedb79cac9d908f7dbe250ac0d62f23e5b204ec43bd0d36
data/comrad.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'comrad'
3
- s.version = '0.0.2'
3
+ s.version = '0.0.3'
4
4
  s.date = Date.today.to_s
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.extra_rdoc_files = ['README.md', 'LICENSE']
data/lib/chef.rb CHANGED
@@ -31,6 +31,7 @@ module Comrad
31
31
  @slack = Comrad::Slack.new(config)
32
32
  end
33
33
 
34
+ # builds a string of what the action is / would be depending on dry run or not
34
35
  def action_string(action, trailing_text)
35
36
  string = @config['flags']['dryrun'] ? " - I would #{action} " : " - #{action.capitalize.chomp('e')}ing "
36
37
  string + trailing_text
@@ -45,20 +46,20 @@ module Comrad
45
46
  elsif type == 'cookbooks'
46
47
  "knife cookbook #{action == 'update' ? 'upload' : 'delete'} #{item1}"
47
48
  else
48
- "knife #{type.chomp('s')} from file #{type}s/#{item1}"
49
+ "knife #{type.chomp('s')} from file #{type}/#{item1}"
49
50
  end
50
51
  end
51
52
 
52
53
  # run the provided knife command
53
54
  def excute_knife_cmd(cmd)
54
55
  if @config['flags']['dryrun']
55
- @slack.slack_put(" - I would be running #{cmd}")
56
- else
56
+ @slack.slack_put(" - I would be running #{cmd}")
57
+ else
57
58
  @slack.slack_put(' - Non-dry mode is not implemented. Doing nothing')
58
59
  end
59
60
  end
60
61
 
61
- # Perform actual actions on chef server and log to slack
62
+ # main method of the class. Iterates over the changes passed in and kicks off actions / slack messaging
62
63
  def take_actions
63
64
  @changes.each_pair do |type, name|
64
65
  next if name.empty?
data/lib/config.rb CHANGED
@@ -33,8 +33,18 @@ module Comrad
33
33
  @settings = merge_configs
34
34
  end
35
35
 
36
+ # make sure the BUILD_NUMBER Jenkins variable exists. If not force help
37
+ def check_jenkins_env_variable
38
+ if ENV['BUILD_NUMBER'].nil?
39
+ puts "Jenkins set BUILD_NUMBER environmental variable not set. Cannot continue.\n\n"
40
+ ARGV[0] = '-h'
41
+ end
42
+ end
43
+
36
44
  # grabs the flags passed in via command line
37
45
  def parse_flags
46
+ check_jenkins_env_variable
47
+
38
48
  flags = { config: '/etc/comrad.yml', print_config: false, quiet: false }
39
49
  OptionParser.new do |opts|
40
50
  opts.banner = 'Usage: comrad [options]'
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.0.2
4
+ version: 0.0.3
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-04-17 00:00:00.000000000 Z
11
+ date: 2015-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client