souls 1.2.2 → 1.3.3
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/lib/souls/cli/create/index.rb +1 -1
- data/lib/souls/cli/db/index.rb +0 -1
- data/lib/souls/cli/gcloud/sql/index.rb +47 -5
- data/lib/souls/version.rb +1 -1
- data/lib/souls/versions/.souls_api_version +1 -1
- data/lib/souls/versions/.souls_worker_version +1 -1
- data/lib/souls.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56948b07884486be23ef9be575ff30331999c0fbcdf02d63991d30d23a161a57
|
4
|
+
data.tar.gz: dec91f275f65b3c2d8e2bc114eecfc6c43fd7d16473905b60866db5453c38816
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04a255e490b590891b25e1f4c33409fba65ff677e556bca9dd90ff5eb62358cf5f80b0ec840b09c301a85bcabc06786e4d44a1512004c32f134e399317bfaad3
|
7
|
+
data.tar.gz: b2278cc9e0b024cee8559972a71d99f26e880bd22da4b44c9453500e2fd492601ecad085c4725de4e2a2d5cf0cce16d55a7a2b364235b7827ec1bf57bccfce78
|
@@ -192,7 +192,7 @@ end
|
|
192
192
|
--service-account=${{ secrets.APP_NAME }}@${{ secrets.GCP_PROJECT_ID }}.iam.gserviceaccount.com \\
|
193
193
|
--image=gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{secrets.APP_NAME}}-#{worker_name} \\
|
194
194
|
--memory=4Gi \\
|
195
|
-
--region
|
195
|
+
--region=${{ secrets.GCP_REGION }} \\
|
196
196
|
--allow-unauthenticated \\
|
197
197
|
--platform=managed \\
|
198
198
|
--quiet \\
|
data/lib/souls/cli/db/index.rb
CHANGED
@@ -3,15 +3,51 @@ module Souls
|
|
3
3
|
desc "create_instance", "Create Google Cloud SQL - PostgreSQL13"
|
4
4
|
method_option :region, default: "", aliases: "--region", desc: "Google Cloud Platform Region"
|
5
5
|
method_option :root_password, default: "", aliases: "--root-password", desc: "Set Cloud SQL Root Password"
|
6
|
+
method_option :mysql, type: :boolean, default: false, aliases: "--mysql", desc: "Set Cloud SQL Type to MySQL"
|
6
7
|
def create_instance
|
7
|
-
|
8
|
+
app_name = Souls.configuration.app
|
9
|
+
project_id = Souls.configuration.project_id
|
10
|
+
region = Souls.configuration.region
|
11
|
+
instance_name = Souls.configuration.instance_name if instance_name.blank?
|
8
12
|
region = Souls.configuration.region if options[:region].blank?
|
13
|
+
db_type = options[:mysql] ? "MYSQL_8_0" : "POSTGRES_13"
|
14
|
+
|
9
15
|
zone = "#{region}-b"
|
10
16
|
system(
|
11
17
|
"gcloud sql instances create #{instance_name} \
|
12
|
-
--database-version
|
18
|
+
--database-version=#{db_type} --cpu=1 --memory=3750MB --zone=#{zone} \
|
13
19
|
--root-password='#{options[:root_password]}' --database-flags cloudsql.iam_authentication=on"
|
14
20
|
)
|
21
|
+
Dir.chdir(Souls.get_api_path.to_s) do
|
22
|
+
file_path = ".env"
|
23
|
+
File.open(file_path, "w") do |line|
|
24
|
+
line.write(<<~TEXT)
|
25
|
+
DB_HOST=#{get_sql_ip.strip}
|
26
|
+
DB_PW=#{options[:root_password]}
|
27
|
+
DB_USER=postgres
|
28
|
+
SLACK=YOUR_WEB_HOOK_URL
|
29
|
+
TZ="Asia/Tokyo"
|
30
|
+
SECRET_KEY_BASE=xxxxxxxxxxxxxx
|
31
|
+
TEXT
|
32
|
+
end
|
33
|
+
end
|
34
|
+
Dir.chdir(Souls.get_mother_path.to_s) do
|
35
|
+
file_path = ".env.production"
|
36
|
+
File.open(file_path, "w") do |line|
|
37
|
+
line.write(<<~TEXT)
|
38
|
+
DB_HOST="/cloudsql/#{project_id}:#{region}:#{instance_name}"
|
39
|
+
DB_PW=#{options[:root_password]}
|
40
|
+
DB_USER=postgres
|
41
|
+
APP_NAME=#{app_name}
|
42
|
+
GCP_PROJECT_ID=#{project_id}
|
43
|
+
GCP_REGION=#{region}
|
44
|
+
GCLOUDSQL_INSTANCE="#{project_id}:#{region}:#{instance_name}"
|
45
|
+
TZ="Asia/Tokyo"
|
46
|
+
SLACK="https://YOUR.WEB_HOOK_URL"
|
47
|
+
SECRET_KEY_BASE="XXXXXXXSecureTokenXXXXXXXXXX"
|
48
|
+
TEXT
|
49
|
+
end
|
50
|
+
end
|
15
51
|
rescue Thor::Error => e
|
16
52
|
raise(Thor::Error, e)
|
17
53
|
end
|
@@ -35,7 +71,7 @@ module Souls
|
|
35
71
|
desc "assign_network", "Assign Network"
|
36
72
|
def assign_network
|
37
73
|
app_name = Souls.configuration.app
|
38
|
-
instance_name =
|
74
|
+
instance_name = Souls.configuration.instance_name
|
39
75
|
project_id = Souls.configuration.project_id
|
40
76
|
system("gcloud beta sql instances patch #{instance_name} --project=#{project_id} --network=#{app_name}")
|
41
77
|
rescue Thor::Error => e
|
@@ -80,8 +116,8 @@ module Souls
|
|
80
116
|
desc "assgin_ip", "Add Current Grobal IP to White List"
|
81
117
|
def assign_ip(instance_name: "", ip: "")
|
82
118
|
ip = `curl inet-ip.info` if ip.blank?
|
83
|
-
project_id = Souls.configuration.project_id
|
84
|
-
instance_name =
|
119
|
+
project_id = Souls.configuration.project_id if instance_name.blank?
|
120
|
+
instance_name = Souls.configuration.instance_name if instance_name.blank?
|
85
121
|
system(
|
86
122
|
"
|
87
123
|
gcloud beta sql instances patch #{instance_name} \
|
@@ -94,5 +130,11 @@ module Souls
|
|
94
130
|
rescue Thor::Error => e
|
95
131
|
raise(Thor::Error, e)
|
96
132
|
end
|
133
|
+
|
134
|
+
private
|
135
|
+
|
136
|
+
def get_sql_ip
|
137
|
+
`gcloud sql instances list | grep james | awk '{print $5}'`
|
138
|
+
end
|
97
139
|
end
|
98
140
|
end
|
data/lib/souls/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.3
|
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.3.3
|
data/lib/souls.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: 1.
|
4
|
+
version: 1.3.3
|
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-
|
13
|
+
date: 2021-11-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|