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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc320e49967853fb86acf2df6ce6a16b1c8540f15e260377d1745709a7f437ca
4
- data.tar.gz: 163a19136e695cda578091a7953385a70b2ea540bf3e59e5cfc3b2cacd256e2d
3
+ metadata.gz: 0ac8f535bffb1cffc5cc10019b62891735f888982c000bd50e8412a887983bf5
4
+ data.tar.gz: a5458cc6c2b9f94452a2362f4b62f4e33f98ce5d4e68de038586f9dc0f5ce218
5
5
  SHA512:
6
- metadata.gz: 9246426b3d5c941316b6d1db26fa42bb028b572749c4bbe0781a8582f04c95fbfec432863f1e59a065cc2bc8e9e0d8211e19b25cd3516392975340f81030d2a6
7
- data.tar.gz: 9f5545b04138034d4c4bd7ac4caef9172754fa6e42538730266ee9722cb6e98e66f573762f40433790f1cc928906b1b75d743ee807abe400772e0317efc8528c
6
+ metadata.gz: 27c3d5389d371076afe009ea9839dd23ff97701bf3ef5b901a7d5c80eb01bdb2b76f01cec1ffd771cab42acec5cbe64b2baa74846a68dc982a78c46cef3e752c
7
+ data.tar.gz: e70e36f757202fcc306401e95414de79c671797aeccd27646b2f1b7fdf85552b6f8fcfb7fed0e51d9ecfc55fc1a67bbabe1240e4757349e0e68d36292d425e17
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- souls (0.23.7)
4
+ souls (0.23.8)
5
5
  paint (= 2.2.1)
6
6
  whirly (= 0.3.0)
7
7
 
data/config/souls.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  Souls.configure do |config|
2
2
  config.app = "souls-app"
3
- config.project_id = "souls-app"
3
+ config.project_id = "el-soul"
4
4
  config.strain = "api"
5
5
  end
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
- Souls::Gcloud.public_send(send_method)
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, :worker_name, :api_name
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
- @worker_name = nil
195
- @api_name = nil
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
@@ -1,5 +1,6 @@
1
1
  require_relative "./gcloud/compute"
2
2
  require_relative "./gcloud/iam"
3
+ require_relative "./gcloud/pubsub"
3
4
 
4
5
  module Souls
5
6
  module Gcloud
@@ -1,71 +1,73 @@
1
1
  module Souls
2
2
  module Gcloud
3
- def self.auth_login
4
- project_id = Souls.configuration.project_id
5
- system("gcloud config set project #{project_id}")
6
- system("gcloud auth login")
7
- end
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
- def self.enable_permissions
10
- system("gcloud services enable compute.googleapis.com")
11
- puts("Operating permission to compute.googleapis.com ...")
12
- system("gcloud services enable iam.googleapis.com")
13
- puts("Operating permission to iam.googleapis.com ...")
14
- system("gcloud services enable dns.googleapis.com")
15
- puts("Operating permission to dns.googleapis.com ...")
16
- system("gcloud services enable sqladmin.googleapis.com")
17
- puts("Operating permission to sqladmin.googleapis.com ...")
18
- system("gcloud services enable sql-component.googleapis.com")
19
- puts("Operating permission to sql-component.googleapis.com ...")
20
- system("gcloud services enable servicenetworking.googleapis.com")
21
- puts("Operating permission to servicenetworking.googleapis.com ...")
22
- system("gcloud services enable containerregistry.googleapis.com")
23
- puts("Operating permission to containerregistry.googleapis.com")
24
- system("gcloud services enable run.googleapis.com")
25
- puts("Operating permission to run.googleapis.com")
26
- end
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
- def self.create_network
29
- return "Error: Please Set Souls.configuration" if Souls.configuration.app.nil?
29
+ def create_network
30
+ return "Error: Please Set Souls.configuration" if Souls.configuration.app.nil?
30
31
 
31
- network = Souls.configuration.app
32
- system("gcloud compute networks create #{network}")
33
- rescue StandardError => e
34
- raise(StandardError, e)
35
- end
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
- def self.create_firewall(ip_range: "10.140.0.0/20")
38
- network = Souls.configuration.app
39
- system(
40
- "gcloud compute firewall-rules create #{network}
41
- --network #{network}
42
- --allow tcp,udp,icmp
43
- --source-ranges #{ip_range}"
44
- )
45
- system("gcloud compute firewall-rules create #{network}-ssh --network #{network} --allow tcp:22,tcp:3389,icmp")
46
- end
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
- def self.create_private_access
49
- network = Souls.configuration.app
50
- project_id = Souls.configuration.project_id
51
- system(
52
- "gcloud compute addresses create #{network}-my-network \
53
- --global \
54
- --purpose=VPC_PEERING \
55
- --prefix-length=16 \
56
- --description='peering range for SOULs' \
57
- --network=#{network} \
58
- --project=#{project_id}"
59
- )
60
- end
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
- def self.create_sql_instance(root_pass: "Postgre123!", zone: "asia-northeast1-b")
63
- app = "#{Souls.configuration.app}-db"
64
- system(
65
- "gcloud sql instances create #{app}
66
- --database-version=POSTGRES_13 --cpu=2 --memory=7680MB --zone=#{zone}
67
- --root-password='#{root_pass}' --database-flags cloudsql.iam_authentication=on"
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
@@ -1,30 +1,32 @@
1
1
  module Souls
2
2
  module Gcloud
3
- def self.create_service_account(service_account: "souls-app")
4
- `gcloud iam service-accounts create #{service_account} \
5
- --description="Souls Service Account" \
6
- --display-name="#{service_account}"`
7
- end
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
- def self.create_service_account_key(service_account: "souls-app")
10
- project_id = Souls.configuration.project_id
11
- `gcloud iam service-accounts keys create ./config/keyfile.json \
12
- --iam-account #{service_account}@#{project_id}.iam.gserviceaccount.com`
13
- end
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
- def self.add_service_account_role(service_account: "souls-app", role: "roles/firebase.admin")
16
- project_id = Souls.configuration.project_id
17
- `gcloud projects add-iam-policy-binding #{project_id} \
18
- --member="serviceAccount:#{service_account}@#{project_id}.iam.gserviceaccount.com" \
19
- --role="#{role}"`
20
- end
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
- def self.add_permissions(service_account: "souls-app")
23
- add_service_account_role(service_account: service_account, role: "roles/cloudsql.serviceAgent")
24
- add_service_account_role(service_account: service_account, role: "roles/containerregistry.ServiceAgent")
25
- add_service_account_role(service_account: service_account, role: "roles/pubsub.serviceAgent")
26
- add_service_account_role(service_account: service_account, role: "roles/firestore.serviceAgent")
27
- add_service_account_role(service_account: service_account, role: "roles/iam.serviceAccountUser")
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
@@ -1,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "0.23.8".freeze
2
+ VERSION = "0.23.9".freeze
3
3
  public_constant :VERSION
4
4
  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: 0.23.8
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-18 00:00:00.000000000 Z
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