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 +4 -4
- data/.travis.yml +1 -0
- data/README.md +3 -0
- data/lib/milc/base.rb +3 -2
- data/lib/milc/dsl/ansible.rb +2 -1
- data/lib/milc/dsl/gcloud.rb +8 -3
- data/lib/milc/gcloud/backend/gcloud_command.rb +3 -2
- data/lib/milc/gcloud/resource.rb +7 -3
- data/lib/milc/version.rb +1 -1
- data/milc.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 134ae9236cb673f0c1182329f7da5b50f513dc85
|
4
|
+
data.tar.gz: 83b991325dfc2683fe41d392b36e151f3f458c8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3eed2dd80e4f4d4e26b1dba89c133ef207ac05330949480374463364b3fca1031e6d764d4e15684cc63fdb1a9e4951b537bf8f90aa7856754ea9ceef47367f8
|
7
|
+
data.tar.gz: 17e6a97c1d1ec6b6a1702edb4912ff7cc3167ea202f9388651b6c2de7d6159f50d4413a1cfc1087f9cac620ecb1b3f6d0d365a4b303280800c4481e18661eee5
|
data/.travis.yml
CHANGED
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
|
-
|
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
|
|
data/lib/milc/dsl/ansible.rb
CHANGED
@@ -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
|
data/lib/milc/dsl/gcloud.rb
CHANGED
@@ -4,15 +4,20 @@ module Milc::Dsl
|
|
4
4
|
module Gcloud
|
5
5
|
|
6
6
|
def gcloud(cmd, &block)
|
7
|
-
cmd
|
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 =
|
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
|
-
|
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
|
|
data/lib/milc/gcloud/resource.rb
CHANGED
@@ -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
|
-
|
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
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.
|
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.
|
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-
|
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.
|
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.
|
26
|
+
version: 0.3.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|