souls 1.9.8 → 1.9.12

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: '0894d11de68247464cb9e18e72d8669ab76bc595aba139a7755d0dd03095a6e4'
4
- data.tar.gz: 1c83ac29578d9197df03f50c5a9d496953989456736d5fbd7fc4fb5d52b4c241
3
+ metadata.gz: 30e75a60a55603333c57c9cfbd45ec5c9a16854cda31c29d1a840439c221967f
4
+ data.tar.gz: 2019911a647b0784122a025f8225b8b277544bbe96055e6851277e2da7974ebc
5
5
  SHA512:
6
- metadata.gz: 5c38578d8bd6c041b865972362b32f2b31b6fdb323752772a357e43e15be4dc2cd854a096046a01183a6d238913d06ed082036b96ac686e3ae7ec08c5556cd9d
7
- data.tar.gz: b0663a6b95b83a7f4f49a8b95e864e08d723f8430eb8631de8c70518b05a0ea4a56b504caf6820ac3ad74c6eeb2fdb535f289df76f90ee101e3979ec86753de1
6
+ metadata.gz: d75036d900131455cd301b3170b51a778c99bae004123e9be4ffc0ace011bcdc98848a931ad76713cf4a8f10afe57bca4d7e41ecf14bd328e9fbdd5696fd46fc
7
+ data.tar.gz: e5d25f3dfd8617030124e34de5e0c1ad374099e5a57da3c4bdf44c63354adc72e907d106e3cb9173dab7d29093f8d26f77104386e43e6ed45d309a33932ffd75
data/README.md CHANGED
@@ -21,22 +21,27 @@
21
21
  <a aria-label="License" href="https://github.com/elsoul/souls/blob/master/LICENSE.txt">
22
22
  <img alt="" src="https://badgen.net/badge/license/Apache/blue">
23
23
  </a>
24
+ <a aria-label="Code of Conduct" href="https://github.com/elsoul/souls/blob/master/CODE_OF_CONDUCT.md">
25
+ <img alt="" src="https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg">
26
+ </a>
24
27
  </p>
25
28
 
26
29
 
27
- ## SOULs Serverless Application Framework Document
30
+ ## Ruby Serverless Application Framework SOULs Document
28
31
 
29
32
  - [Go to SOULs Document](https://souls.elsoul.nl/)
30
33
 
31
34
  <p>
32
- <a aria-label="SOULs Document" href="https://souls.elsoul.nl/">
35
+ <a aria-label="Ruby Serverless Application Framework SOULs Document" href="https://souls.elsoul.nl/">
33
36
  <img src="https://souls.elsoul.nl/imgs/gifs/souls-new-video.gif">
34
37
  </a>
35
38
  </p>
36
39
 
37
40
  ## What's SOULs?
38
41
 
39
- Welcome to SOULs Serverless Application Framework!
42
+ Ruby Serverless Framework 'SOULs'.
43
+
44
+ The SOULs project was launched with the goal of reducing software development, operation and maintenance costs.
40
45
 
41
46
  Build Serverless Apps faster like Rails.
42
47
  Powered by Ruby GraphQL, RBS/Steep, Active Record, RSpec, RuboCop, and Google Cloud.
@@ -1,4 +1,5 @@
1
1
  require_relative "graphql/souls_query"
2
+ require_relative "utils/souls_logger"
2
3
 
3
4
  module Souls
4
5
  end
@@ -0,0 +1,55 @@
1
+ module Souls
2
+ module SoulsLogger
3
+ class Configuration
4
+ attr_accessor :logger
5
+
6
+ def initialize
7
+ @logger = nil
8
+ end
9
+ end
10
+
11
+ class << self
12
+ attr_writer :configuration
13
+ end
14
+
15
+ def self.configuration
16
+ @configuration ||= Configuration.new
17
+ end
18
+
19
+ def self.configure
20
+ yield(configuration)
21
+ end
22
+
23
+ def self.critical_log(message)
24
+ entry = write_log(message)
25
+ entry.critical!
26
+
27
+ configuration.logger.write_entries(entry)
28
+ end
29
+
30
+ def self.warning_log(message)
31
+ entry = write_log(message)
32
+ entry.warning!
33
+
34
+ configuration.logger.write_entries(entry)
35
+ end
36
+
37
+ def self.info_log(message)
38
+ entry = write_log(message)
39
+ entry.info!
40
+
41
+ configuration.logger.write_entries(entry)
42
+ end
43
+
44
+ def self.write_log(message)
45
+ entry = configuration.logger.entry
46
+ entry.payload = "#{message}\n #{message.backtrace.join("\n")}"
47
+ entry.log_name = "error"
48
+ entry.resource.type = "cloud_run_revision"
49
+ entry.resource.labels[:service_name] = "souls"
50
+ entry.resource.labels[:revision_name] = Souls::VERSION
51
+
52
+ entry
53
+ end
54
+ end
55
+ end
@@ -2,11 +2,13 @@ module Souls
2
2
  class Iam < Thor
3
3
  desc "setup_key", "Create Google Cloud IAM Service Account Key And Set All Permissions"
4
4
  def setup_key
5
+ region = Souls.configuration.region
5
6
  Souls::Gcloud.new.auth_login
6
7
  create_service_account
7
8
  create_service_account_key
8
9
  Souls::Gcloud.new.enable_permissions
9
10
  add_permissions
11
+ system("gcloud app create --region=#{region} --quiet")
10
12
  begin
11
13
  set_gh_secret_json
12
14
  rescue StandardError
@@ -92,7 +94,8 @@ module Souls
92
94
  "roles/run.admin",
93
95
  "roles/storage.admin",
94
96
  "roles/storage.objectAdmin",
95
- "roles/cloudscheduler.admin"
97
+ "roles/cloudscheduler.admin",
98
+ "roles/appengine.appCreator"
96
99
  ]
97
100
  roles.each do |role|
98
101
  add_service_account_role(role: role)
@@ -15,15 +15,44 @@ module Souls
15
15
  require("./app")
16
16
  Souls::Gcloud.new.config_set
17
17
  project_id = Souls.configuration.project_id
18
- region = Souls.configuration.region
18
+
19
+ schedules_list = current_schedules
20
+
19
21
  Queries::BaseQuery.all_schedules.each do |k, v|
20
22
  worker_name = FileUtils.pwd.split("/").last
21
- job_name = "#{worker_name}_#{k.to_s.underscore}"
22
- system("gcloud scheduler jobs delete #{job_name} -q >/dev/null 2>&1")
23
- system(
24
- <<~COMMAND)
25
- gcloud scheduler jobs create pubsub #{job_name} --project=#{project_id} --quiet --schedule="#{v}" --topic="#{k}" --attributes="" --message-body="#{k}" --location=#{region}
26
- COMMAND
23
+ job_name = "#{worker_name}_#{k.to_s.underscore}".to_sym
24
+
25
+ if schedules_list.include?(job_name)
26
+ schedule = schedules_list[job_name]
27
+ schedules_list.delete(job_name)
28
+ next if schedule == v
29
+
30
+ system(
31
+ <<~COMMAND)
32
+ gcloud scheduler jobs update pubsub #{job_name} --project=#{project_id} --quiet --schedule="#{v}" --topic="#{k}" --attributes="" --message-body="#{k}"
33
+ COMMAND
34
+ else
35
+ system(
36
+ <<~COMMAND)
37
+ gcloud scheduler jobs create pubsub #{job_name} --project=#{project_id} --quiet --schedule="#{v}" --topic="#{k}" --attributes="" --message-body="#{k}"
38
+ COMMAND
39
+ end
40
+ end
41
+
42
+ schedule_list.each do |k, _|
43
+ system("gcloud scheduler jobs delete #{k} -q >/dev/null 2>&1")
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def current_schedules
50
+ current_schedules = {}
51
+ `gcloud scheduler jobs list`.split("\n")[1..].each do |line|
52
+ columns = line.split(/\t| {2,}/)
53
+ job_name = columns[0].to_sym
54
+ crontab = columns[2].split(" (")[0]
55
+ current_schedules[job_name] = crontab
27
56
  end
28
57
  end
29
58
  end
@@ -105,16 +105,38 @@ module Souls
105
105
  end
106
106
 
107
107
  desc "assgin_ip", "Add Current Grobal IP to White List"
108
- def assign_ip(instance_name: "", ip: "")
109
- ip = `curl inet-ip.info` if ip.blank?
110
- project_id = Souls.configuration.project_id if instance_name.blank?
111
- instance_name = Souls.configuration.instance_name if instance_name.blank?
108
+ method_option :ip, default: "", aliases: "--ip", desc: "Adding IP to Google Cloud SQL White List: e.g.'11.11.1.1'"
109
+ def assign_ip
110
+ project_id = Souls.configuration.project_id
111
+ instance_name = Souls.configuration.instance_name
112
+ ips = []
113
+ ip =
114
+ if options[:ip].blank?
115
+ `curl inet-ip.info`.strip
116
+ else
117
+ options[:ip].strip
118
+ end
119
+ ips << ip
120
+ cloud_sql = JSON.parse(
121
+ `curl -X GET \
122
+ -H "Authorization: Bearer "$(gcloud auth print-access-token) \
123
+ "https://sqladmin.googleapis.com/v1/projects/#{project_id}/instances/#{instance_name}?fields=settings"`
124
+ )
125
+ unless cloud_sql["settings"]["ipConfiguration"]["authorizedNetworks"].blank?
126
+ white_ips =
127
+ cloud_sql["settings"]["ipConfiguration"]["authorizedNetworks"].map do |sql_ips|
128
+ sql_ips["value"]
129
+ end
130
+ ips = (ips + white_ips).uniq
131
+ end
132
+ ips = ips.join(",")
112
133
  system(
113
134
  "
114
135
  gcloud sql instances patch #{instance_name} \
115
136
  --project=#{project_id} \
116
137
  --assign-ip \
117
- --authorized-networks=#{ip}
138
+ --authorized-networks=#{ips} \
139
+ --quiet
118
140
  "
119
141
  )
120
142
  end
@@ -2,6 +2,7 @@ module Souls
2
2
  class Sync < Thor
3
3
  desc "pubsub", "Sync Worker Jobs & Google Cloud Pubsub Subscriptions"
4
4
  def pubsub
5
+ get_worker_endpoints
5
6
  Souls::Gcloud.new.config_set
6
7
  get_topics(workers: get_workers)
7
8
  puts(Paint["All Jobs Synced with PubSub Subscription!", :green])
@@ -9,6 +10,17 @@ module Souls
9
10
 
10
11
  private
11
12
 
13
+ def get_worker_endpoints
14
+ require("#{Souls.get_mother_path}/config/souls")
15
+ worker_paths = Souls.configuration.workers
16
+ worker_paths.each do |worker|
17
+ endpoint = worker[:endpoint]
18
+ unless endpoint.include?("https://")
19
+ raise(StandardError, "You need to set endpoint.\nPlease Run:\n\n$ souls sync conf\n\n")
20
+ end
21
+ end
22
+ end
23
+
12
24
  def get_topics(workers: {})
13
25
  project_id = Souls.configuration.project_id
14
26
  pubsub = Google::Cloud::Pubsub.new(project_id: project_id)
data/lib/souls/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "1.9.8".freeze
2
+ VERSION = "1.9.12".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 1.9.8
1
+ 1.9.12
@@ -1 +1 @@
1
- 1.9.8
1
+ 1.9.12
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: souls
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.8
4
+ version: 1.9.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI
8
8
  - KishiTheMechanic
9
9
  - James Neve
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-11-25 00:00:00.000000000 Z
13
+ date: 2021-11-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -110,8 +110,10 @@ dependencies:
110
110
  - - ">="
111
111
  - !ruby/object:Gem::Version
112
112
  version: 1.1.0
113
- description: "Build Serverless Apps faster like Rails.\n Powered by Ruby GraphQL,
114
- RBS/Steep, Active Record, RSpec, RuboCop, and Google Cloud. "
113
+ description: "Ruby Serverless Framework 'SOULs'. The SOULs project was launched with
114
+ the goal of reducing software development, operation and maintenance costs. Build
115
+ Serverless Apps faster like Rails.\n Powered by Ruby GraphQL, RBS/Steep, Active
116
+ Record, RSpec, RuboCop, and Google Cloud. "
115
117
  email:
116
118
  - f.kawasaki@elsoul.nl
117
119
  - s.kishi@elsoul.nl
@@ -128,6 +130,7 @@ files:
128
130
  - lib/souls.rb
129
131
  - lib/souls/app/graphql/souls_query.rb
130
132
  - lib/souls/app/index.rb
133
+ - lib/souls/app/utils/souls_logger.rb
131
134
  - lib/souls/cli.rb
132
135
  - lib/souls/cli/cli_exception.rb
133
136
  - lib/souls/cli/console/index.rb
@@ -229,7 +232,7 @@ licenses:
229
232
  - Apache-2.0
230
233
  metadata:
231
234
  rubygems_mfa_required: 'true'
232
- post_install_message:
235
+ post_install_message:
233
236
  rdoc_options: []
234
237
  require_paths:
235
238
  - lib
@@ -244,9 +247,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
247
  - !ruby/object:Gem::Version
245
248
  version: '0'
246
249
  requirements: []
247
- rubygems_version: 3.2.22
248
- signing_key:
250
+ rubygems_version: 3.2.32
251
+ signing_key:
249
252
  specification_version: 4
250
- summary: Build Serverless Apps faster like Rails. Powered by Ruby GraphQL, RBS/Steep,
251
- Active Record, RSpec, RuboCop, and Google Cloud.
253
+ summary: Ruby Serverless Framework 'SOULs'. The SOULs project was launched with the
254
+ goal of reducing software development, operation and maintenance costs. Build Serverless
255
+ Apps faster like Rails. Powered by Ruby GraphQL, RBS/Steep, Active Record, RSpec,
256
+ RuboCop, and Google Cloud.
252
257
  test_files: []