magellan-cli 0.8.3 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/Gemfile.lock +18 -11
- data/lib/magellan/cli/http.rb +1 -0
- data/lib/magellan/cli/locales/en.yml +44 -3
- data/lib/magellan/cli/locales/ja.yml +44 -2
- data/lib/magellan/cli/resources.rb +3 -1
- data/lib/magellan/cli/resources/cloudsql_instance.rb +156 -0
- data/lib/magellan/cli/version.rb +1 -1
- data/magellan-cli.gemspec +1 -0
- data/reference/en/resources/stage.md +3 -1
- data/reference/ja/resources/stage.md +3 -1
- data/spec/spec_helper.rb +6 -1
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d237ca63be36c479c3d1efe64d2200e0acb8bac6
|
4
|
+
data.tar.gz: 753e9536a5ab579581839603c5d73a7f7762470a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2871fe33e13b493ba2302c34423dd9d628fb3f224e0deb420be698a789074e7d4bba23ed67ed08cb9a82f29ff29f32a4cd3ffc9788c4f7405f73c7b8e37b7e81
|
7
|
+
data.tar.gz: 7a4157af37faa12ee46b3d0b615e56cf454948edcf725eceb9a7521f5499b791da14db7f2db3e5e60edb193a2daa5670d9d574ac04f4b9a8e5b819b1b3f0b3ec
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
magellan-cli (0.
|
4
|
+
magellan-cli (0.9.0)
|
5
5
|
activesupport (~> 4.1.4)
|
6
6
|
groovenauts-thor
|
7
7
|
httpclient (~> 2.5)
|
8
8
|
i18n
|
9
9
|
libmagellan (~> 0.2.4)
|
10
|
+
logger_pipe (~> 0.3.1)
|
10
11
|
nokogiri
|
11
12
|
psych (>= 2.0.0, <= 2.0.8)
|
12
13
|
text-table (~> 1.2.3)
|
@@ -14,7 +15,7 @@ PATH
|
|
14
15
|
GEM
|
15
16
|
remote: https://rubygems.org/
|
16
17
|
specs:
|
17
|
-
activesupport (4.1.
|
18
|
+
activesupport (4.1.13)
|
18
19
|
i18n (~> 0.6, >= 0.6.9)
|
19
20
|
json (~> 1.7, >= 1.7.7)
|
20
21
|
minitest (~> 5.1)
|
@@ -32,6 +33,7 @@ GEM
|
|
32
33
|
debugger-linecache (1.2.0)
|
33
34
|
diff-lcs (1.2.5)
|
34
35
|
docile (1.1.5)
|
36
|
+
extlib (0.9.16)
|
35
37
|
faraday (0.9.1)
|
36
38
|
multipart-post (>= 1.2, < 3)
|
37
39
|
fuubar (2.0.0)
|
@@ -42,13 +44,14 @@ GEM
|
|
42
44
|
i18n (0.7.0)
|
43
45
|
json (1.8.3)
|
44
46
|
jwt (1.5.1)
|
45
|
-
libmagellan (0.2.
|
47
|
+
libmagellan (0.2.5)
|
46
48
|
activesupport
|
47
49
|
mqtt (~> 0.3.1)
|
48
|
-
signet (~> 0.
|
50
|
+
signet (~> 0.6.0)
|
51
|
+
logger_pipe (0.3.1)
|
49
52
|
method_source (0.8.2)
|
50
53
|
mini_portile (0.6.2)
|
51
|
-
minitest (5.8.
|
54
|
+
minitest (5.8.1)
|
52
55
|
mqtt (0.3.1)
|
53
56
|
multi_json (1.10.1)
|
54
57
|
multipart-post (2.0.0)
|
@@ -79,16 +82,19 @@ GEM
|
|
79
82
|
rspec-support (~> 3.0.0)
|
80
83
|
rspec-support (3.0.4)
|
81
84
|
ruby-progressbar (1.7.1)
|
82
|
-
signet (0.
|
83
|
-
addressable (
|
84
|
-
|
85
|
-
|
86
|
-
|
85
|
+
signet (0.6.1)
|
86
|
+
addressable (~> 2.3)
|
87
|
+
extlib (~> 0.9)
|
88
|
+
faraday (~> 0.9)
|
89
|
+
jwt (~> 1.5)
|
90
|
+
multi_json (~> 1.10)
|
87
91
|
simplecov (0.9.1)
|
88
92
|
docile (~> 1.1.0)
|
89
93
|
multi_json (~> 1.0)
|
90
94
|
simplecov-html (~> 0.8.0)
|
91
95
|
simplecov-html (0.8.0)
|
96
|
+
simplecov-rcov (0.2.3)
|
97
|
+
simplecov (>= 0.4.1)
|
92
98
|
slop (3.5.0)
|
93
99
|
text-table (1.2.4)
|
94
100
|
thread_safe (0.3.5)
|
@@ -108,6 +114,7 @@ DEPENDENCIES
|
|
108
114
|
rake (~> 10.0)
|
109
115
|
rspec
|
110
116
|
simplecov
|
117
|
+
simplecov-rcov
|
111
118
|
|
112
119
|
BUNDLED WITH
|
113
|
-
1.10.
|
120
|
+
1.10.6
|
data/lib/magellan/cli/http.rb
CHANGED
@@ -8,7 +8,7 @@ en:
|
|
8
8
|
${HOME}/.config/magellan/magellan-cli
|
9
9
|
You can specify your own configuration file path by setting environment variable
|
10
10
|
MAGELLAN_CLI_CONFIG_FILE.
|
11
|
-
|
11
|
+
|
12
12
|
!! migration from 0.4.0 and before !!
|
13
13
|
magellan-cli 0.4.0 and before saves configuration file into `.magellan-cli'
|
14
14
|
in current directory.
|
@@ -109,8 +109,8 @@ en:
|
|
109
109
|
set_container_num: "Set the number of %{containers_name} for the selected %{image_name}"
|
110
110
|
reload: "Reload the last selections"
|
111
111
|
cmd_create:
|
112
|
-
type: "-t development|staging|production
|
113
|
-
size: "-s micro|standard
|
112
|
+
type: "-t development|staging|production specify Stage Type"
|
113
|
+
size: "-s micro|standard specify Stage Size"
|
114
114
|
cmd_release_now:
|
115
115
|
async: "-A async mode. release_now returns soon"
|
116
116
|
interval: "-i polling interval(seconds)"
|
@@ -120,6 +120,47 @@ en:
|
|
120
120
|
async: "-A async mode. release_now returns soon"
|
121
121
|
interval: "-i polling interval(seconds)"
|
122
122
|
timeout: "-t timeout(seconds)"
|
123
|
+
cloudsql_instance:
|
124
|
+
cmd:
|
125
|
+
create: "Create a new %{resource_name} by INSTANCE"
|
126
|
+
delete: "Delete the %{resource_name} by INSTANCE"
|
127
|
+
list: "Show list of the %{resource_name}"
|
128
|
+
cmd_create:
|
129
|
+
tier: "Tier of Cloud SQL instance. see also https://cloud.google.com/sql/pricing"
|
130
|
+
region: "Region where the Cloud SQL instance works"
|
131
|
+
activation-policy: "The activation policy for this instance. This specifies when the instance should be activated and is applicable only when the instance state is RUNNABLE."
|
132
|
+
skip-assign-ip: "Specified unless the instance must be assigned an IP address."
|
133
|
+
authorized-networks: "The list of external networks that are allowed to connect to the instance. Specified in CIDR notation, also known as 'slash' notation (e.g. 192.168.100.0/24)."
|
134
|
+
gce-zone: "The preferred Compute Engine zone (e.g. us-central1-a, us-central1-b, etc.)."
|
135
|
+
pricing-plan: "The pricing plan for this instance."
|
136
|
+
password: "The password for the root user."
|
137
|
+
account: "Google Cloud Platform user account to use for invocation."
|
138
|
+
log-http: "Log all HTTP server requests and responses to stderr."
|
139
|
+
project: "Google Cloud Platform project ID to use for this invocation."
|
140
|
+
trace-token: "Token used to route traces of service requests for investigation of issues."
|
141
|
+
user-output-enabled: "Print user intended output to the console."
|
142
|
+
verbosity: "Override the default verbosity for this command. This must be a standard logging verbosity level: [debug, info, warning, error, critical, none] (Default: [warning])."
|
143
|
+
aync: "Ignored even if it's given."
|
144
|
+
format: "Ignored even if it's given."
|
145
|
+
env_head: |
|
146
|
+
Set the following text to "Environment Variables" of your worker to access the database from your worker.
|
147
|
+
--------------------------------------------------
|
148
|
+
env_body: |
|
149
|
+
MYSQL_HOST: %{mysql_host}
|
150
|
+
MYSQL_PORT: %{mysql_port}
|
151
|
+
MYSQL_DATABASE: %{mysql_database}
|
152
|
+
MYSQL_USERNAME: %{mysql_username}
|
153
|
+
MYSQL_PASSWORD: %{mysql_password}
|
154
|
+
env_tail: |
|
155
|
+
--------------------------------------------------
|
156
|
+
(Modify the value for MYSQL_DATABASE if you need)
|
157
|
+
You need to use environment variables to get connection configurations like this: https://github.com/tengine/magellan-rails-example/blob/master/config/database.yml
|
158
|
+
messages:
|
159
|
+
starting_launch: "Now launching Cloud SQL instance. It will take a few minutes."
|
160
|
+
gcloud_not_found: |
|
161
|
+
gcloud command not found. Install Google Cloud SDK to use
|
162
|
+
magellan-cli cloudsql-instance command.
|
163
|
+
For more information see https://cloud.google.com/sdk/
|
123
164
|
team:
|
124
165
|
cmd:
|
125
166
|
create: "Create a new %{resource_name} with NAME and ROLE"
|
@@ -6,7 +6,7 @@ ja:
|
|
6
6
|
magellan-cli はログイン情報、リソースの選択状態などの情報を設定ファイルに保存します。
|
7
7
|
設定ファイルのファイルパスは ${HOME}/.config/magellan/magellan-cli が用いられます。
|
8
8
|
設定ファイルのファイルパスは環境変数 MAGELLAN_CLI_CONFIG_FILE で指定可能です。
|
9
|
-
|
9
|
+
|
10
10
|
!! 0.4.0 からの移行について !!
|
11
11
|
magellan-cli 0.4.0 までは設定ファイルとしてカレントディレクトリに .magellan-cli ファイルを
|
12
12
|
作成していました。
|
@@ -108,7 +108,7 @@ ja:
|
|
108
108
|
reload: "最後にselectされたものをロードし直します"
|
109
109
|
cmd_create:
|
110
110
|
type: "-t development|staging|production いずれかのTYPEを指定してください"
|
111
|
-
size: "-s micro|standard
|
111
|
+
size: "-s micro|standard いずれかのSIZEを指定してください"
|
112
112
|
cmd_release_now:
|
113
113
|
async: "-A 非同期モード。リリースの終了を待たずにコマンドを終了します"
|
114
114
|
interval: "-i 状態を取得する間隔を秒で指定します"
|
@@ -118,6 +118,48 @@ ja:
|
|
118
118
|
async: "-A 非同期モード。リリースの終了を待たずにコマンドを終了します"
|
119
119
|
interval: "-i 状態を取得する間隔を秒で指定します"
|
120
120
|
timeout: "-t タイムアウトを秒で指定します"
|
121
|
+
cloudsql_instance:
|
122
|
+
cmd:
|
123
|
+
create: "INSTANCEを指定して%{resource_name}を登録します"
|
124
|
+
delete: "INSTANCEを指定して%{resource_name}を削除します"
|
125
|
+
list: "%{resource_name}の一覧を表示します"
|
126
|
+
cmd_create:
|
127
|
+
# それぞれの訳はDevelopers Consoleのものを使っています
|
128
|
+
tier: "Cloud SQLのインスタンスの階層。詳しくは https://cloud.google.com/sql/pricing を参照してください。"
|
129
|
+
region: "Cloud SQLのインスタンスを動かす地域"
|
130
|
+
activation-policy: "Cloud SQLのインスタンスを有効にするポリシー"
|
131
|
+
skip-assign-ip: "IPv4 アドレスを割り当てない"
|
132
|
+
authorized-networks: "承認済みネットワーク"
|
133
|
+
gce-zone: "希望する場所"
|
134
|
+
pricing-plan: "料金プラン"
|
135
|
+
password: "Cloud SQLのrootユーザのパスワード"
|
136
|
+
account: "GCPユーザアカウント"
|
137
|
+
log-http: "全てのHTTPのリクエストとレスポンスを標準エラー出力に出力します"
|
138
|
+
project: "GCPプロジェクト"
|
139
|
+
trace-token: "トレーストークン"
|
140
|
+
user-output-enabled: "コンソールにユーザを出力します"
|
141
|
+
verbosity: "ログレベル"
|
142
|
+
async: "指定しても無視されます"
|
143
|
+
format: "指定しても無視されます"
|
144
|
+
env_head: |
|
145
|
+
起動したDBにWorkerから接続するためには、下記の設定を起動するWorkerの"Environment Variables"に設定してください
|
146
|
+
--------------------------------------------------
|
147
|
+
env_body: |
|
148
|
+
MYSQL_HOST: %{mysql_host}
|
149
|
+
MYSQL_PORT: %{mysql_port}
|
150
|
+
MYSQL_DATABASE: %{mysql_database}
|
151
|
+
MYSQL_USERNAME: %{mysql_username}
|
152
|
+
MYSQL_PASSWORD: %{mysql_password}
|
153
|
+
env_tail: |
|
154
|
+
--------------------------------------------------
|
155
|
+
(MYSQL_DATABASEの値は必要に応じて変更してください)
|
156
|
+
Workerには予め https://github.com/tengine/magellan-rails-example/blob/master/config/database.yml のように環境変数から接続先を取得する設定が必要です。
|
157
|
+
messages:
|
158
|
+
starting_launch: "Cloud SQLのインスタンスを起動しています。数分かかりますのでお待ち下さい。"
|
159
|
+
gcloud_not_found: |
|
160
|
+
gcloudコマンドが見つかりませんでした。
|
161
|
+
ご利用になるためにはGoogle Cloud SDKをインストールして頂く必要があります。
|
162
|
+
詳しくはこちらをご覧ください。 https://cloud.google.com/sdk/
|
121
163
|
team:
|
122
164
|
cmd:
|
123
165
|
create: "NAMEとROLEを指定して%{resource_name}を登録します"
|
@@ -24,6 +24,7 @@ module Magellan
|
|
24
24
|
autoload :Container , "magellan/cli/resources/container"
|
25
25
|
|
26
26
|
autoload :Cloudsql, "magellan/cli/resources/cloudsql"
|
27
|
+
autoload :CloudsqlInstance, "magellan/cli/resources/cloudsql_instance"
|
27
28
|
|
28
29
|
autoload :Deletable, "magellan/cli/resources/deletable"
|
29
30
|
|
@@ -41,6 +42,7 @@ module Magellan
|
|
41
42
|
"Image" => "image",
|
42
43
|
"Container" => "container",
|
43
44
|
"Cloudsql" => "cloudsql",
|
45
|
+
"CloudsqlInstance" => "cloudsql_instance",
|
44
46
|
}
|
45
47
|
|
46
48
|
class << self
|
@@ -51,7 +53,7 @@ module Magellan
|
|
51
53
|
def dependants_on(klass)
|
52
54
|
name = klass.name.split(/::/).last
|
53
55
|
res_name = MAPPING[name] or raise "unknown class named #{klass.name}"
|
54
|
-
concrete_classes.select{|c| c.resource_dependency && !!c.resource_dependency[res_name] }
|
56
|
+
concrete_classes.select{|c| c.respond_to?(:resource_dependency) &&c.resource_dependency && !!c.resource_dependency[res_name] }
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
@@ -0,0 +1,156 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require "magellan/cli/resources"
|
3
|
+
|
4
|
+
require 'logger'
|
5
|
+
require 'securerandom'
|
6
|
+
|
7
|
+
require 'logger_pipe'
|
8
|
+
require 'text-table'
|
9
|
+
|
10
|
+
module Magellan
|
11
|
+
module Cli
|
12
|
+
module Resources
|
13
|
+
|
14
|
+
class CloudsqlInstance < ::Magellan::Cli::Base
|
15
|
+
|
16
|
+
desc "create INSTANCE", I18n.t(:create, scope: [:resources, :cloudsql_instance, :cmd], resource_name: "CloudSQL instance")
|
17
|
+
OPTIONS = {
|
18
|
+
create: {
|
19
|
+
"tier" => {type: :string , default: "D0" , enum: %w[D0 D1 D2 D4 D8 D16 D32]},
|
20
|
+
"region" => {type: :string , default: "asia-east1"},
|
21
|
+
"activation-policy" => {type: :string , default: "ON_DEMAND" , enum: %w[ALWAYS NEVER ON_DEMAND]},
|
22
|
+
"skip-assign-ip" => {type: :boolean },
|
23
|
+
"authorized-networks" => {type: :string , default: "0.0.0.0/0" },
|
24
|
+
"gce-zone" => {type: :string , default: "asia-east1-c"},
|
25
|
+
"pricing-plan" => {type: :string , default: "PER_USE" , enum: %w[PACKAGE PER_USE]},
|
26
|
+
},
|
27
|
+
password: {
|
28
|
+
"password" => {aliases: "-p", type: :string},
|
29
|
+
},
|
30
|
+
common: {
|
31
|
+
"account" => {type: :string},
|
32
|
+
"log-http" => {type: :boolean},
|
33
|
+
"project" => {type: :string},
|
34
|
+
"trace-token" => {type: :string},
|
35
|
+
"user-output-enabled" => {type: :boolean},
|
36
|
+
"verbosity" => {type: :string, default: "info", enum: %w[debug info warning error critical none]},
|
37
|
+
},
|
38
|
+
removed: {"async" => {type: :boolean}},
|
39
|
+
overwritten: { "format" => {type: :string, default: "json"}, }
|
40
|
+
}
|
41
|
+
CREATE_OPTION_SCOPE = [:resources, :cloudsql_instance, :cmd_create]
|
42
|
+
OPTIONS.each do |cmd, options|
|
43
|
+
options.each do |name, hash|
|
44
|
+
method_option(name, {desc: I18n.t(name, scope: CREATE_OPTION_SCOPE)}.update(hash))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
def create(instance, *args)
|
48
|
+
$stderr.puts(I18n.t(:starting_launch, scope: [:resources, :cloudsql_instance, :messages]))
|
49
|
+
options["format"] = "json"
|
50
|
+
create_args = build_args(options, [:common, :create])
|
51
|
+
create_args << "--assign-ip" unless options["skip-assign-ip"]
|
52
|
+
res1_text = gcloud("sql instances create #{instance}", create_args + args)
|
53
|
+
res1 = res1_text.nil? ? nil : JSON.parse(res1_text)
|
54
|
+
|
55
|
+
# p res1
|
56
|
+
# res1
|
57
|
+
# {
|
58
|
+
# "currentDiskSize"=>"281069967", "databaseVersion"=>"MYSQL_5_6", "etag"=>"\"wEP3hMpsWqL85yYiZI8N_zVwr4g/MQ\"",
|
59
|
+
# "instance"=>"magellan-cli-testdbi03", "instanceType"=>"CLOUDSQL_INSTANCE",
|
60
|
+
# "ipAddresses"=>[{"ipAddress"=>"173.194.229.107"}],
|
61
|
+
# "ipv6Address"=>"2001:4860:4864:1:fb5a:76f:71c1:f2f3",
|
62
|
+
# "kind"=>"sql#instance", "maxDiskSize"=>"268435456000", "project"=>"scenic-doodad-617",
|
63
|
+
# "region"=>"asia-east1",
|
64
|
+
# "serverCaCert"=>{...},
|
65
|
+
# "settings"=>{
|
66
|
+
# "activationPolicy"=>"ON_DEMAND",
|
67
|
+
# "backupConfiguration"=>[{"binaryLogEnabled"=>false, "enabled"=>false, "id"=>"2057f912-faf7-4a5d-a16d-c5a12a9dceca", "kind"=>"sql#backupConfiguration", "startTime"=>"23:00"}],
|
68
|
+
# "ipConfiguration"=>{"authorizedNetworks"=>["0.0.0.0/0"], "enabled"=>true, "kind"=>"sql#ipConfiguration"},
|
69
|
+
# "kind"=>"sql#settings",
|
70
|
+
# "locationPreference"=>{"kind"=>"sql#locationPreference", "zone"=>"asia-east1-c"},
|
71
|
+
# "pricingPlan"=>"PACKAGE", "replicationType"=>"SYNCHRONOUS", "settingsVersion"=>"1",
|
72
|
+
# "tier"=>"D0"
|
73
|
+
# },
|
74
|
+
# "state"=>"RUNNABLE"
|
75
|
+
# }
|
76
|
+
|
77
|
+
# % gcloud sql instances create magellan-cli-testdbi06 --tier=D0 --region=asia-east1 --activation-policy=ON_DEMAND --authorized-networks=0.0.0.0/0 --gce-zone=asia-east1-c --verbosity=debug --assign-ip
|
78
|
+
# DEBUG: Running gcloud.sql.instances.create with Namespace(__calliope_internal_deepest_parser=ArgumentParser(prog='gcloud.sql.instances.create', usage=None, description='Creates a new Cloud SQL instance.', version=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=False), account=None, activation_policy='ON_DEMAND', api_version=None, assign_ip=True, async=False, authorized_gae_apps=[], authorized_networks=['0.0.0.0/0'], backup=True, backup_start_time=None, cmd_func=<bound method Command.Run of <googlecloudsdk.calliope.backend.Command object at 0x10767cc50>>, command_path=['gcloud', 'sql', 'instances', 'create'], configuration=None, database_flags=None, database_version='MYSQL_5_6', document=None, enable_bin_log=None, follow_gae_app=None, format=None, gce_zone='asia-east1-c', h=None, help=None, http_timeout=None, instance='magellan-cli-testdbi06', log_http=None, master_instance_name=None, pricing_plan='PER_USE', project=None, quiet=None, region='asia-east1', replication=None, require_ssl=None, tier='D0', trace_email=None, trace_log=False, trace_token=None, user_output_enabled=None, verbosity='debug', version=None).
|
79
|
+
# Creating Cloud SQL instance...done.
|
80
|
+
# Created [https://www.googleapis.com/sql/v1beta3/projects/scenic-doodad-617/instances/magellan-cli-testdbi06].
|
81
|
+
# DEBUG: Explict Display.
|
82
|
+
# NAME REGION TIER ADDRESS STATUS
|
83
|
+
# magellan-cli-testdbi06 asia-east1 D0 173.194.249.189 RUNNABLE
|
84
|
+
|
85
|
+
host = res1['ipAddresses'].first['ipAddress']
|
86
|
+
t = Text::Table.new
|
87
|
+
t.head = %w[NAME REGION TIER ADDRESS STATUS]
|
88
|
+
t.rows = [[res1['instance'], res1['region'], res1['settings']['tier'], host, res1['state']]]
|
89
|
+
$stderr.puts t.to_s
|
90
|
+
|
91
|
+
pw_options = options.dup
|
92
|
+
pw_options["password"] ||= SecureRandom.hex(8)
|
93
|
+
pw_args = build_args(pw_options, [:common, :password])
|
94
|
+
res2 = gcloud("sql instances set-root-password #{instance}", pw_args)
|
95
|
+
# res2.inspect #=> []
|
96
|
+
$stderr.puts "\e[32mCOMPLETE\e[0m"
|
97
|
+
|
98
|
+
$stderr.puts I18n.t(:env_head, scope: CREATE_OPTION_SCOPE)
|
99
|
+
env_options = {
|
100
|
+
scope: CREATE_OPTION_SCOPE,
|
101
|
+
mysql_host: host,
|
102
|
+
mysql_port: 3306,
|
103
|
+
mysql_database: "#{instance}_production",
|
104
|
+
mysql_username: "root",
|
105
|
+
mysql_password: pw_options["password"],
|
106
|
+
}
|
107
|
+
$stdout.puts I18n.t(:env_body, env_options)
|
108
|
+
$stderr.puts I18n.t(:env_tail, scope: CREATE_OPTION_SCOPE)
|
109
|
+
end
|
110
|
+
|
111
|
+
desc "delete INSTANCE", I18n.t(:delete, scope: [:resources, :cloudsql_instance, :cmd], resource_name: "CloudSQL instance")
|
112
|
+
def delete(instance, *args)
|
113
|
+
check_gcloud_command
|
114
|
+
system("gcloud sql instances delete #{instance} #{args.join(' ')} 2>&1")
|
115
|
+
end
|
116
|
+
|
117
|
+
desc "list", I18n.t(:list, scope: [:resources, :cloudsql_instance, :cmd], resource_name: "CloudSQL instance")
|
118
|
+
def list(*args)
|
119
|
+
check_gcloud_command
|
120
|
+
system("gcloud sql instances list #{args.join(' ')} 2>&1")
|
121
|
+
end
|
122
|
+
|
123
|
+
no_commands do
|
124
|
+
def logger
|
125
|
+
unless @logger
|
126
|
+
@logger = Logger.new($stderr)
|
127
|
+
@logger.level = verbose? ? Logger::INFO : Logger::WARN
|
128
|
+
end
|
129
|
+
@logger
|
130
|
+
end
|
131
|
+
|
132
|
+
def build_args(options, commands)
|
133
|
+
opts = options.dup
|
134
|
+
OPTIONS[:removed].keys.each{|k| opts.delete(k)}
|
135
|
+
cmd_keys = (commands + [:overwritten]).map{|cmd| OPTIONS[cmd].keys }.flatten
|
136
|
+
opts.delete_if{|k,_| !cmd_keys.include?(k)}
|
137
|
+
opts.map{|k,v| "--#{k}=#{v}"}
|
138
|
+
end
|
139
|
+
|
140
|
+
def gcloud(subcommand, arguments)
|
141
|
+
check_gcloud_command
|
142
|
+
cmd = "gcloud #{subcommand} #{arguments.join(' ')}"
|
143
|
+
LoggerPipe.run(logger, cmd, dry_run: dryrun?, returns: :stdout, logging: :stderr)
|
144
|
+
end
|
145
|
+
|
146
|
+
def check_gcloud_command
|
147
|
+
return true unless `which gcloud`.empty?
|
148
|
+
$stderr.puts("\e[31m%s\e[0m" % I18n.t(:gcloud_not_found, scope: [:resources, :cloudsql_instance, :messages]))
|
149
|
+
exit(1)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
data/lib/magellan/cli/version.rb
CHANGED
data/magellan-cli.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_runtime_dependency "i18n"
|
27
27
|
spec.add_runtime_dependency "psych", ">= 2.0.0", "<= 2.0.8"
|
28
28
|
spec.add_runtime_dependency "libmagellan", "~> 0.2.4"
|
29
|
+
spec.add_runtime_dependency "logger_pipe", "~> 0.3.1"
|
29
30
|
|
30
31
|
spec.add_development_dependency "bundler", "~> 1.6"
|
31
32
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -83,8 +83,10 @@ magellan-cli stage create NAME [-t development|staging|production]
|
|
83
83
|
|
84
84
|
```text
|
85
85
|
Options:
|
86
|
-
[-t=T] # -t development|staging|production
|
86
|
+
[-t=T] # -t development|staging|production specify Stage Type
|
87
87
|
# Default: development
|
88
|
+
[-s=S] # -s micro|standard specify Stage Size
|
89
|
+
# Default: micro
|
88
90
|
|
89
91
|
```
|
90
92
|
|
@@ -83,8 +83,10 @@ magellan-cli stage create NAME [-t development|staging|production]
|
|
83
83
|
|
84
84
|
```text
|
85
85
|
Options:
|
86
|
-
[-t=T] # -t development|staging|production
|
86
|
+
[-t=T] # -t development|staging|production いずれかのTYPEを指定してください
|
87
87
|
# Default: development
|
88
|
+
[-s=S] # -s micro|standard いずれかのSIZEを指定してください
|
89
|
+
# Default: micro
|
88
90
|
|
89
91
|
```
|
90
92
|
|
data/spec/spec_helper.rb
CHANGED
@@ -2,7 +2,12 @@ require "pry"
|
|
2
2
|
|
3
3
|
if ENV["COVERAGE"] =~ /true|yes|on|1/i
|
4
4
|
require "simplecov"
|
5
|
-
|
5
|
+
require 'simplecov-rcov'
|
6
|
+
SimpleCov.formatters = [
|
7
|
+
SimpleCov::Formatter::HTMLFormatter,
|
8
|
+
SimpleCov::Formatter::RcovFormatter
|
9
|
+
]
|
10
|
+
SimpleCov.start
|
6
11
|
end
|
7
12
|
|
8
13
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magellan-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akm2000
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -128,6 +128,20 @@ dependencies:
|
|
128
128
|
- - "~>"
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: 0.2.4
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: logger_pipe
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 0.3.1
|
138
|
+
type: :runtime
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 0.3.1
|
131
145
|
- !ruby/object:Gem::Dependency
|
132
146
|
name: bundler
|
133
147
|
requirement: !ruby/object:Gem::Requirement
|
@@ -209,6 +223,7 @@ files:
|
|
209
223
|
- lib/magellan/cli/resources/base.rb
|
210
224
|
- lib/magellan/cli/resources/client_version.rb
|
211
225
|
- lib/magellan/cli/resources/cloudsql.rb
|
226
|
+
- lib/magellan/cli/resources/cloudsql_instance.rb
|
212
227
|
- lib/magellan/cli/resources/container.rb
|
213
228
|
- lib/magellan/cli/resources/deletable.rb
|
214
229
|
- lib/magellan/cli/resources/image.rb
|
@@ -294,7 +309,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
294
309
|
version: '0'
|
295
310
|
requirements: []
|
296
311
|
rubyforge_project:
|
297
|
-
rubygems_version: 2.4.5
|
312
|
+
rubygems_version: 2.4.5.1
|
298
313
|
signing_key:
|
299
314
|
specification_version: 4
|
300
315
|
summary: commandline tools for magellanic cloud service.
|