souls 0.23.8 → 0.23.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/config/souls.rb +1 -1
- data/exe/souls +16 -1
- data/lib/souls.rb +4 -3
- data/lib/souls/gcloud.rb +1 -0
- data/lib/souls/gcloud/compute.rb +62 -60
- data/lib/souls/gcloud/iam.rb +24 -22
- data/lib/souls/gcloud/pubsub.rb +21 -0
- data/lib/souls/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ac8f535bffb1cffc5cc10019b62891735f888982c000bd50e8412a887983bf5
|
4
|
+
data.tar.gz: a5458cc6c2b9f94452a2362f4b62f4e33f98ce5d4e68de038586f9dc0f5ce218
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27c3d5389d371076afe009ea9839dd23ff97701bf3ef5b901a7d5c80eb01bdb2b76f01cec1ffd771cab42acec5cbe64b2baa74846a68dc982a78c46cef3e752c
|
7
|
+
data.tar.gz: e70e36f757202fcc306401e95414de79c671797aeccd27646b2f1b7fdf85552b6f8fcfb7fed0e51d9ecfc55fc1a67bbabe1240e4757349e0e68d36292d425e17
|
data/Gemfile.lock
CHANGED
data/config/souls.rb
CHANGED
data/exe/souls
CHANGED
@@ -69,7 +69,22 @@ begin
|
|
69
69
|
Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
|
70
70
|
Whirly.status = status
|
71
71
|
send_method = ARGV[1]
|
72
|
-
|
72
|
+
|
73
|
+
case send_method
|
74
|
+
when "create_pubsub_topic"
|
75
|
+
topic_name = ARGV[2]
|
76
|
+
args = { topic_name: topic_name }
|
77
|
+
Souls::Gcloud.public_send(send_method, args)
|
78
|
+
when "create_pubsub_subscription"
|
79
|
+
project_id = Souls.configuration.project_id
|
80
|
+
topic_name = ARGV[2]
|
81
|
+
service_account = "#{Souls.configuration.app}@#{project_id}iam.gserviceaccount.com"
|
82
|
+
endpoint = Souls.configuration.endpoint
|
83
|
+
args = { project_id: project_id, topic_name: topic_name, service_account: service_account, endpoint: endpoint }
|
84
|
+
Souls::Gcloud.public_send(send_method, args)
|
85
|
+
else
|
86
|
+
Souls::Gcloud.public_send(send_method)
|
87
|
+
end
|
73
88
|
Whirly.status = "Done!"
|
74
89
|
end
|
75
90
|
when "-v", "--version"
|
data/lib/souls.rb
CHANGED
@@ -185,14 +185,15 @@ module Souls
|
|
185
185
|
end
|
186
186
|
|
187
187
|
class Configuration
|
188
|
-
attr_accessor :app, :strain, :project_id, :
|
188
|
+
attr_accessor :app, :strain, :project_id, :worker_repo, :api_repo, :worker_endpoint
|
189
189
|
|
190
190
|
def initialize
|
191
191
|
@app = nil
|
192
192
|
@project_id = nil
|
193
193
|
@strain = nil
|
194
|
-
@
|
195
|
-
@
|
194
|
+
@worker_repo = nil
|
195
|
+
@api_repo = nil
|
196
|
+
@worker_endpoint = nil
|
196
197
|
end
|
197
198
|
end
|
198
199
|
end
|
data/lib/souls/gcloud.rb
CHANGED
data/lib/souls/gcloud/compute.rb
CHANGED
@@ -1,71 +1,73 @@
|
|
1
1
|
module Souls
|
2
2
|
module Gcloud
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
class << self
|
4
|
+
def auth_login
|
5
|
+
project_id = Souls.configuration.project_id
|
6
|
+
system("gcloud config set project #{project_id}")
|
7
|
+
system("gcloud auth login")
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
10
|
+
def enable_permissions
|
11
|
+
system("gcloud services enable compute.googleapis.com")
|
12
|
+
puts("Operating permission to compute.googleapis.com ...")
|
13
|
+
system("gcloud services enable iam.googleapis.com")
|
14
|
+
puts("Operating permission to iam.googleapis.com ...")
|
15
|
+
system("gcloud services enable dns.googleapis.com")
|
16
|
+
puts("Operating permission to dns.googleapis.com ...")
|
17
|
+
system("gcloud services enable sqladmin.googleapis.com")
|
18
|
+
puts("Operating permission to sqladmin.googleapis.com ...")
|
19
|
+
system("gcloud services enable sql-component.googleapis.com")
|
20
|
+
puts("Operating permission to sql-component.googleapis.com ...")
|
21
|
+
system("gcloud services enable servicenetworking.googleapis.com")
|
22
|
+
puts("Operating permission to servicenetworking.googleapis.com ...")
|
23
|
+
system("gcloud services enable containerregistry.googleapis.com")
|
24
|
+
puts("Operating permission to containerregistry.googleapis.com")
|
25
|
+
system("gcloud services enable run.googleapis.com")
|
26
|
+
puts("Operating permission to run.googleapis.com")
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
|
29
|
+
def create_network
|
30
|
+
return "Error: Please Set Souls.configuration" if Souls.configuration.app.nil?
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
network = Souls.configuration.app
|
33
|
+
system("gcloud compute networks create #{network}")
|
34
|
+
rescue StandardError => e
|
35
|
+
raise(StandardError, e)
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
38
|
+
def create_firewall(ip_range: "10.140.0.0/20")
|
39
|
+
network = Souls.configuration.app
|
40
|
+
system(
|
41
|
+
"gcloud compute firewall-rules create #{network}
|
42
|
+
--network #{network}
|
43
|
+
--allow tcp,udp,icmp
|
44
|
+
--source-ranges #{ip_range}"
|
45
|
+
)
|
46
|
+
system("gcloud compute firewall-rules create #{network}-ssh --network #{network} --allow tcp:22,tcp:3389,icmp")
|
47
|
+
end
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
49
|
+
def create_private_access
|
50
|
+
network = Souls.configuration.app
|
51
|
+
project_id = Souls.configuration.project_id
|
52
|
+
system(
|
53
|
+
"gcloud compute addresses create #{network}-my-network \
|
54
|
+
--global \
|
55
|
+
--purpose=VPC_PEERING \
|
56
|
+
--prefix-length=16 \
|
57
|
+
--description='peering range for SOULs' \
|
58
|
+
--network=#{network} \
|
59
|
+
--project=#{project_id}"
|
60
|
+
)
|
61
|
+
end
|
61
62
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
63
|
+
def create_sql_instance(root_pass: "Postgre123!", zone: "asia-northeast1-b")
|
64
|
+
app = "#{Souls.configuration.app}-db"
|
65
|
+
system(
|
66
|
+
"gcloud sql instances create #{app}
|
67
|
+
--database-version=POSTGRES_13 --cpu=2 --memory=7680MB --zone=#{zone}
|
68
|
+
--root-password='#{root_pass}' --database-flags cloudsql.iam_authentication=on"
|
69
|
+
)
|
70
|
+
end
|
69
71
|
end
|
70
72
|
end
|
71
73
|
end
|
data/lib/souls/gcloud/iam.rb
CHANGED
@@ -1,30 +1,32 @@
|
|
1
1
|
module Souls
|
2
2
|
module Gcloud
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
class << self
|
4
|
+
def create_service_account(service_account: "souls-app")
|
5
|
+
`gcloud iam service-accounts create #{service_account} \
|
6
|
+
--description="Souls Service Account" \
|
7
|
+
--display-name="#{service_account}"`
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
def create_service_account_key(service_account: "souls-app")
|
11
|
+
project_id = Souls.configuration.project_id
|
12
|
+
`gcloud iam service-accounts keys create ./config/keyfile.json \
|
13
|
+
--iam-account #{service_account}@#{project_id}.iam.gserviceaccount.com`
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
def add_service_account_role(service_account: "souls-app", role: "roles/firebase.admin")
|
17
|
+
project_id = Souls.configuration.project_id
|
18
|
+
`gcloud projects add-iam-policy-binding #{project_id} \
|
19
|
+
--member="serviceAccount:#{service_account}@#{project_id}.iam.gserviceaccount.com" \
|
20
|
+
--role="#{role}"`
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
def add_permissions(service_account: "souls-app")
|
24
|
+
add_service_account_role(service_account: service_account, role: "roles/cloudsql.serviceAgent")
|
25
|
+
add_service_account_role(service_account: service_account, role: "roles/containerregistry.ServiceAgent")
|
26
|
+
add_service_account_role(service_account: service_account, role: "roles/pubsub.serviceAgent")
|
27
|
+
add_service_account_role(service_account: service_account, role: "roles/firestore.serviceAgent")
|
28
|
+
add_service_account_role(service_account: service_account, role: "roles/iam.serviceAccountUser")
|
29
|
+
end
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Souls
|
2
|
+
module Gcloud
|
3
|
+
class << self
|
4
|
+
def create_pubsub_topic(args)
|
5
|
+
system("gcloud pubsub topics create #{args[:topic_name]}")
|
6
|
+
end
|
7
|
+
|
8
|
+
def create_pubsub_subscription(args)
|
9
|
+
system(
|
10
|
+
"gcloud pubsub subscriptions create #{args[:topic_name]}-sub \
|
11
|
+
--topic #{args[:topic_name]} \
|
12
|
+
--topic-project #{args[:project_id]} \
|
13
|
+
--push-auth-service-account #{args[:service_account]} \
|
14
|
+
--push-endpoint #{args[:endpoint]} \
|
15
|
+
--expiration-period never
|
16
|
+
"
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/souls/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: souls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.23.
|
4
|
+
version: 0.23.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- POPPIN-FUMI
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-07-
|
13
|
+
date: 2021-07-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: paint
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- lib/souls/gcloud.rb
|
76
76
|
- lib/souls/gcloud/compute.rb
|
77
77
|
- lib/souls/gcloud/iam.rb
|
78
|
+
- lib/souls/gcloud/pubsub.rb
|
78
79
|
- lib/souls/generate.rb
|
79
80
|
- lib/souls/generate/application.rb
|
80
81
|
- lib/souls/generate/connection.rb
|