mikoshi 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +29 -7
- data/exe/mikoshi +1 -1
- data/lib/mikoshi/cli.rb +128 -33
- data/lib/mikoshi/version.rb +1 -1
- data/mikoshi.gemspec +0 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11ffacd388fe1d9f9e14b9a6b4996a49e6a1dd01
|
4
|
+
data.tar.gz: b9024f9536b02d92f818382df4efd5ccd3e38340
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05e402e23adebac0612a4e4c20ea1a35b6cbec586338d3417251983cd3f08a593b22ff53332c5271a834b1963695b3ae3dcdcc7c3c927476818f253fe5001152
|
7
|
+
data.tar.gz: 5c3d49d7caff0699368be992558a33827ee0a494ade3cedd3a4876f5591631fa46c46ff13da27d781015d4bd010b785b0f02951e1d80d5fc80023e7c26e16065
|
data/README.md
CHANGED
@@ -85,15 +85,37 @@ $ mikoshi deploy -g ping2googledns
|
|
85
85
|
|
86
86
|
# show help
|
87
87
|
$ mikoshi help
|
88
|
-
|
89
|
-
mikoshi deploy # Deploy task definition and service
|
90
|
-
mikoshi help [COMMAND] # Describe available commands or one specific command
|
91
|
-
mikoshi update_service SERVICE_NAME # Update service
|
92
|
-
mikoshi update_task TASK_NAME # Update task definition
|
88
|
+
Usage of the mikoshi
|
93
89
|
|
94
|
-
|
95
|
-
|
90
|
+
Global option
|
91
|
+
-r, --region=REGION : Set aws region
|
92
|
+
-h, --help : Print this help message
|
93
|
+
-v, --version : Print mikoshi version
|
96
94
|
|
95
|
+
Subcommands
|
96
|
+
update_task_definition
|
97
|
+
Update task definition to given task definition yaml file.
|
98
|
+
Set TASK_DEF_REVISION to updated task definition revision number.
|
99
|
+
|
100
|
+
Option
|
101
|
+
--potdr
|
102
|
+
Acronym of the "Print Only Task Definition Revision".
|
103
|
+
|
104
|
+
update_service
|
105
|
+
Update service to given service yaml file.
|
106
|
+
Wait for success to update the service. (Maximum 300 min)
|
107
|
+
|
108
|
+
deploy
|
109
|
+
invoke update_task_definition and update_service.
|
110
|
+
|
111
|
+
Option
|
112
|
+
-g, --group=GROUP
|
113
|
+
If task definition file name and service file name are
|
114
|
+
same, that a shorthand of pass both.
|
115
|
+
|
116
|
+
Common options
|
117
|
+
-s, --service=SERVICE
|
118
|
+
-t, --task-definition=TASK_DEFINITION
|
97
119
|
```
|
98
120
|
|
99
121
|
## Development
|
data/exe/mikoshi
CHANGED
data/lib/mikoshi/cli.rb
CHANGED
@@ -1,67 +1,162 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
# rubocop: disable Metrics/AbcSize
|
4
|
+
# rubocop: disable Metrics/ClassLength
|
5
|
+
|
4
6
|
require 'aws-sdk'
|
5
7
|
require 'mikoshi/plan'
|
6
8
|
require 'mikoshi/plan/task_definition'
|
7
9
|
require 'mikoshi/plan/service'
|
10
|
+
require 'optparse'
|
8
11
|
|
9
12
|
module Mikoshi
|
10
|
-
class Cli
|
13
|
+
class Cli
|
14
|
+
attr_reader :options
|
15
|
+
|
11
16
|
TASK_DEFINITION_PATH = 'task_definitions'
|
12
17
|
SERVICE_PATH = 'services'
|
13
18
|
PLAN_EXT = '.yml.erb'
|
14
19
|
FETCH_INTERVAL = 10
|
15
20
|
DEPLOY_TIMEOUT = 300
|
16
21
|
|
17
|
-
|
22
|
+
def initialize(argv: nil)
|
23
|
+
raise ArgumentError, 'argv is required.' if argv.nil?
|
24
|
+
|
25
|
+
@argv = argv
|
26
|
+
@options = { region: nil, command: nil, config: {} }
|
27
|
+
end
|
28
|
+
|
29
|
+
def start
|
30
|
+
parse
|
31
|
+
exit_when_flag
|
32
|
+
|
33
|
+
case @options[:command]
|
34
|
+
when :update_task_definition
|
35
|
+
update_task_definition(@options[:config][:task_definition])
|
36
|
+
when :update_service
|
37
|
+
update_service(@options[:config][:service])
|
38
|
+
when :deploy
|
39
|
+
deploy
|
40
|
+
when :version
|
41
|
+
version
|
42
|
+
when :help
|
43
|
+
usage
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def parse
|
48
|
+
opt = OptionParser.new
|
49
|
+
|
50
|
+
opt.on('-r', '--region=REGION') { |v| @options[:region] = v }
|
51
|
+
opt.on('-s', '--service=SERVICE') { |v| @options[:config][:service] = v }
|
52
|
+
opt.on('-t', '--task-definition=TASK_DEFINITION') { |v| @options[:config][:task_definition] = v }
|
53
|
+
opt.on('--potdr') { |v| @options[:config][:potdr] = v }
|
54
|
+
opt.on('-g', '--group=GROUP') { |v| @options[:config][:group] = v }
|
55
|
+
opt.on('-h', '--help') { |v| @options[:config][:help] = v }
|
56
|
+
opt.on('-v', '--version') { |v| @options[:config][:version] = v }
|
57
|
+
|
58
|
+
opt.permute!(@argv)
|
59
|
+
@options[:command] = @argv.first.to_sym unless @argv.first.nil?
|
60
|
+
end
|
61
|
+
|
62
|
+
def exit_when_flag
|
63
|
+
usage if @options[:config][:help]
|
64
|
+
version if @options[:config][:version]
|
65
|
+
exit if @options[:config][:help] || @options[:config][:version]
|
66
|
+
end
|
67
|
+
|
68
|
+
def usage
|
69
|
+
puts <<~USAGE
|
70
|
+
Usage of the mikoshi
|
71
|
+
|
72
|
+
Global option
|
73
|
+
-r, --region=REGION : Set aws region
|
74
|
+
-h, --help : Print this help message
|
75
|
+
-v, --version : Print mikoshi version
|
76
|
+
|
77
|
+
Subcommands
|
78
|
+
update_task_definition
|
79
|
+
Update task definition to given task definition yaml file.
|
80
|
+
Set TASK_DEF_REVISION to updated task definition revision number.
|
81
|
+
|
82
|
+
Option
|
83
|
+
--potdr
|
84
|
+
Acronym of the "Print Only Task Definition Revision".
|
85
|
+
|
86
|
+
update_service
|
87
|
+
Update service to given service yaml file.
|
88
|
+
Wait for success to update the service. (Maximum 300 min)
|
89
|
+
|
90
|
+
deploy
|
91
|
+
invoke update_task_definition and update_service.
|
92
|
+
|
93
|
+
Option
|
94
|
+
-g, --group=GROUP
|
95
|
+
If task definition file name and service file name are
|
96
|
+
same, that a shorthand of pass both.
|
97
|
+
|
98
|
+
Common options
|
99
|
+
-s, --service=SERVICE
|
100
|
+
-t, --task-definition=TASK_DEFINITION
|
101
|
+
USAGE
|
102
|
+
end
|
103
|
+
|
104
|
+
def version
|
105
|
+
puts "mikoshi version #{Mikoshi::VERSION}"
|
106
|
+
end
|
107
|
+
|
108
|
+
def update_task_definition(task_def_name)
|
109
|
+
if task_def_name.nil?
|
110
|
+
warn '--task-definition=TASK_DEFINITION is require option.'
|
111
|
+
abort
|
112
|
+
end
|
18
113
|
|
19
|
-
desc 'update_task TASK_NAME', 'Update task definition'
|
20
|
-
def update_task_definition(task_name)
|
21
114
|
task = ::Mikoshi::Plan::TaskDefinition.new(
|
22
|
-
yaml_path:
|
23
|
-
client:
|
115
|
+
yaml_path: File.join(TASK_DEFINITION_PATH, task_def_name + PLAN_EXT),
|
116
|
+
client: aws_client,
|
24
117
|
)
|
25
|
-
|
118
|
+
|
119
|
+
# print only task definition revision
|
120
|
+
potdr = @options[:config][:potdr]
|
121
|
+
|
122
|
+
puts "Update task definition: #{task_def_name}" unless potdr
|
26
123
|
task.register_task_definition
|
27
|
-
puts "Done update task definition: #{
|
124
|
+
puts "Done update task definition: #{task_def_name} revision: #{ENV['TASK_DEF_REVISION']}" unless potdr
|
125
|
+
puts ENV['TASK_DEF_REVISION'] if potdr
|
28
126
|
end
|
29
127
|
|
30
|
-
desc 'update_service SERVICE_NAME', 'Update service'
|
31
128
|
def update_service(service_name)
|
129
|
+
if service_name.nil?
|
130
|
+
warn '--service=SERVICE is require option.'
|
131
|
+
abort
|
132
|
+
end
|
133
|
+
|
32
134
|
service = ::Mikoshi::Plan::Service.new(
|
33
|
-
yaml_path:
|
34
|
-
client:
|
135
|
+
yaml_path: File.join(SERVICE_PATH, service_name + PLAN_EXT),
|
136
|
+
client: aws_client,
|
35
137
|
)
|
36
|
-
|
138
|
+
|
139
|
+
puts "Update service: #{service_name}"
|
37
140
|
service.deploy_service(message: true)
|
38
141
|
puts "Done update service #{service_name}"
|
39
142
|
end
|
40
143
|
|
41
|
-
desc 'deploy', 'Deploy task definition and service'
|
42
|
-
method_option :task_definition, type: :string, desc: 'task_definition name', aliases: '-t'
|
43
|
-
method_option :service, type: :string, desc: 'service name', aliases: '-s'
|
44
|
-
method_option :group, type: :string, desc: 'service and task definition name(if both are same)', aliases: '-g'
|
45
|
-
|
46
144
|
def deploy
|
47
|
-
|
48
|
-
|
145
|
+
task_def_name = @options[:config][:group] || @options[:config][:task_definition]
|
146
|
+
service_name = @options[:config][:group] || @options[:config][:service]
|
49
147
|
|
50
|
-
update_task_definition(
|
51
|
-
update_service(
|
148
|
+
update_task_definition(task_def_name) if task_def_name
|
149
|
+
update_service(service_name) if service_name
|
52
150
|
end
|
53
151
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
Aws::ECS::Client.new(opt)
|
64
|
-
end
|
152
|
+
def aws_client
|
153
|
+
opt =
|
154
|
+
if @options[:region].nil?
|
155
|
+
{}
|
156
|
+
else
|
157
|
+
{ region: @options[:region] }
|
158
|
+
end
|
159
|
+
Aws::ECS::Client.new(opt)
|
65
160
|
end
|
66
161
|
end
|
67
162
|
end
|
data/lib/mikoshi/version.rb
CHANGED
data/mikoshi.gemspec
CHANGED
@@ -27,7 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
|
28
28
|
spec.add_dependency 'activesupport', '~> 5'
|
29
29
|
spec.add_dependency 'aws-sdk', '~> 2'
|
30
|
-
spec.add_dependency 'thor'
|
31
30
|
|
32
31
|
spec.add_development_dependency 'bundler', '~> 1.14'
|
33
32
|
spec.add_development_dependency 'codacy-coverage'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mikoshi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yusuke Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: thor
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: bundler
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|