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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dfd94cb490b6572839d1bbe81210f365501d29746db52da19b7802a989389f78
4
- data.tar.gz: ff24ba19313ef53a5b0be3650902963aa1035e86f26a44819431ec2c9a9290e0
3
+ metadata.gz: 56948b07884486be23ef9be575ff30331999c0fbcdf02d63991d30d23a161a57
4
+ data.tar.gz: dec91f275f65b3c2d8e2bc114eecfc6c43fd7d16473905b60866db5453c38816
5
5
  SHA512:
6
- metadata.gz: 71400c705f4fef455e14adf98ac5f2ad51ff98ec751a6ee3ff0f08ad828d238d3383256464f7e9932035ac86dc7bfb10de756c2bb1dc90932ee812304d1bab73
7
- data.tar.gz: 0c19435dad07d1e8f69213a52522d8f46c48140b415c3f420eb556a8448d003a70626132d4229a413d5518835bcf2e5c55ffe63a2cb510e2f2bc0d32987a42ec
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=asia-northeast1 \\
195
+ --region=${{ secrets.GCP_REGION }} \\
196
196
  --allow-unauthenticated \\
197
197
  --platform=managed \\
198
198
  --quiet \\
@@ -55,7 +55,6 @@ module Souls
55
55
  system("rake db:migrate:reset RACK_ENV=production DISABLE_DATABASE_ENVIRONMENT_CHECK=1")
56
56
  else
57
57
  system("rake db:migrate:reset")
58
- system("rake db:migrate:reset RACK_ENV=test")
59
58
  end
60
59
  rescue Thor::Error => e
61
60
  raise(Thor::Error, e)
@@ -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
- instance_name = "#{Souls.configuration.app}-db" if instance_name.blank?
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=POSTGRES_13 --cpu=2 --memory=7680MB --zone=#{zone} \
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 = "#{Souls.configuration.app}-db"
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 = "#{Souls.configuration.app}-db" if instance_name.blank?
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,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "1.2.2".freeze
2
+ VERSION = "1.3.3".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 1.2.2
1
+ 1.3.3
@@ -1 +1 @@
1
- 1.2.2
1
+ 1.3.3
data/lib/souls.rb CHANGED
@@ -49,5 +49,9 @@ module Souls
49
49
  @fixed_gems = nil
50
50
  @workers = nil
51
51
  end
52
+
53
+ def instance_name
54
+ "souls-#{@app}-db"
55
+ end
52
56
  end
53
57
  end
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.2.2
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-10-26 00:00:00.000000000 Z
13
+ date: 2021-11-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport