milc 0.1.3 → 0.1.4

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: 2f8e0a16eb96c30657eb8c71bf4add5bf8f88920
4
- data.tar.gz: be37765d13f6380b3ade730f2469b8ed55480c88
3
+ metadata.gz: 134ae9236cb673f0c1182329f7da5b50f513dc85
4
+ data.tar.gz: 83b991325dfc2683fe41d392b36e151f3f458c8e
5
5
  SHA512:
6
- metadata.gz: a89feb84b3d46a7e789f86dae61c6dc071297179939db727c42232d48b4ca3797d6d062f4a10719b06ebd230c5cdae2a37e0c1b09aa31675ed480fff26184e62
7
- data.tar.gz: 87a828e7b0068904507c491d2e09b2debc25a9e4ee0156eff9aa9d6f5d8309b055a36e0e633b69acfb1397064b87ec046f06eba1ca8b0e11735f0c5277e61807
6
+ metadata.gz: f3eed2dd80e4f4d4e26b1dba89c133ef207ac05330949480374463364b3fca1031e6d764d4e15684cc63fdb1a9e4951b537bf8f90aa7856754ea9ceef47367f8
7
+ data.tar.gz: 17e6a97c1d1ec6b6a1702edb4912ff7cc3167ea202f9388651b6c2de7d6159f50d4413a1cfc1087f9cac620ecb1b3f6d0d365a4b303280800c4481e18661eee5
data/.travis.yml CHANGED
@@ -1,3 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.2.0
4
+ before_install: gem install bundler --version '>= 1.8.0'
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Milc
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/milc.png)](https://rubygems.org/gems/milc)
4
+ [![Build Status](https://travis-ci.org/groovenauts/milc.svg?branch=master)](https://travis-ci.org/groovenauts/milc)
5
+
3
6
  Milc means "Magellan Infrastructure Library and Command".
4
7
 
5
8
  This gem supports portability from command to ruby library in order to realize automated orchestration.
data/lib/milc/base.rb CHANGED
@@ -28,8 +28,9 @@ module Milc
28
28
  Milc.logger
29
29
  end
30
30
 
31
- def execute(cmd)
32
- res = LoggerPipe.run(logger, cmd, dry_run: Milc.dry_run)
31
+ def execute(cmd, options = {})
32
+ options[:dry_run] = Milc.dry_run
33
+ res = LoggerPipe.run(logger, cmd, options)
33
34
  block_given? ? yield(res) : res
34
35
  end
35
36
 
@@ -7,7 +7,8 @@ module Milc::Dsl
7
7
  # https://github.com/mitchellh/vagrant/blob/0098b7604d071948fd37b16dd10b87b6df49b624/plugins/provisioners/ansible/provisioner.rb#L58
8
8
  command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook #{cmd}"
9
9
  command << " -vvvv" if Milc.verbose
10
- execute(command, &block)
10
+ execute(command, returns: :none, logging: :both, &block)
11
+ nil
11
12
  end
12
13
 
13
14
  end
@@ -4,15 +4,20 @@ module Milc::Dsl
4
4
  module Gcloud
5
5
 
6
6
  def gcloud(cmd, &block)
7
- cmd << " --project #{project}" unless cmd =~ /\s\-\-project[\s\=]/
8
- execute("gcloud #{cmd}", &block)
7
+ execute(build_gcloud_command(cmd), returns: :none, logging: :both, &block)
9
8
  end
10
9
 
11
10
  def json_gcloud(cmd)
12
- r = gcloud(cmd + " --format json")
11
+ r = execute(build_gcloud_command(cmd + " --format json"), returns: :stdout, logging: :stderr)
13
12
  res = r.nil? ? nil : JSON.parse(r)
14
13
  block_given? ? yield(res) : res
15
14
  end
16
15
 
16
+ def build_gcloud_command(cmd)
17
+ r = "gcloud #{cmd}"
18
+ r << " --project #{project}" unless cmd =~ /\s\-\-project[\s\=]/
19
+ r
20
+ end
21
+
17
22
  end
18
23
  end
@@ -9,8 +9,9 @@ module Milc
9
9
  module Backend
10
10
  class GcloudCommand
11
11
 
12
- def execute(cmd)
13
- res = LoggerPipe.run(Milc.logger, cmd, dry_run: Milc.dry_run)
12
+ def execute(cmd, options = {})
13
+ options[:dry_run] = Milc.dry_run
14
+ res = LoggerPipe.run(Milc.logger, cmd, options)
14
15
  block_given? ? yield(res) : res
15
16
  end
16
17
 
@@ -48,10 +48,10 @@ module Milc
48
48
  @commands = commands || []
49
49
  end
50
50
 
51
- def __gcloud(cmd, &block)
51
+ def __gcloud(cmd, options = {}, &block)
52
52
  c = "gcloud #{cmd} --format json"
53
53
  c << " --project #{project}" unless c =~ /\s\-\-project[\s\=]/
54
- res = Gcloud.backend.execute(c, &block)
54
+ res = Gcloud.backend.execute(c, options, &block)
55
55
  res ? JSON.parse(res) : nil
56
56
  end
57
57
 
@@ -69,7 +69,11 @@ module Milc
69
69
 
70
70
  def call_action(action, cmd_args, attrs = nil, &block)
71
71
  attr_args = attrs.nil? ? '' : build_attr_args(attrs)
72
- __gcloud("#{service} #{resource} #{action} #{cmd_args} #{attr_args}", &block)
72
+ options =
73
+ action =~ /\Alist|\Adescribe|\Aget/ ?
74
+ {returns: :stdout, logging: :stderr} :
75
+ {returns: :none , logging: :both}
76
+ __gcloud("#{service} #{resource} #{action} #{cmd_args} #{attr_args}", options, &block)
73
77
  end
74
78
 
75
79
  def call_update(cmd_args, attrs, &block)
data/lib/milc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Milc
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/milc.gemspec CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
24
24
  end
25
25
 
26
- spec.add_runtime_dependency "logger_pipe", "~> 0.3.0"
26
+ spec.add_runtime_dependency "logger_pipe", "~> 0.3.1"
27
27
  spec.add_runtime_dependency "activesupport", "~> 4.1.0"
28
28
 
29
29
  spec.add_development_dependency "bundler", "~> 1.8"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: milc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - akm
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-10 00:00:00.000000000 Z
11
+ date: 2015-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logger_pipe
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.0
19
+ version: 0.3.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.3.0
26
+ version: 0.3.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement