souls 1.9.11 → 1.9.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/souls/app/index.rb +1 -0
- data/lib/souls/app/utils/souls_logger.rb +55 -0
- data/lib/souls/cli/gcloud/iam/index.rb +2 -3
- data/lib/souls/cli/gcloud/pubsub/subscriptions.rb +1 -2
- data/lib/souls/cli/gcloud/scheduler/index.rb +38 -6
- data/lib/souls/cli/gcloud/sql/index.rb +27 -5
- data/lib/souls/cli/release/release.rb +2 -2
- data/lib/souls/cli/sync/pubsub.rb +12 -0
- 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
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5a37d4f87d7cc48d2ac150e9e2054535d92f18c973f111dbdbb1b4b0a12e495
|
4
|
+
data.tar.gz: eb4731be85e6811c8cad06a608b84be0b9ec72245a78107b8379a1835683a0f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 408873a10f3f415b3ccf4ffacd0bc5840cd7c1e42a9cbec6498790f0a56a15c5cde2ae816f0fd63c1608ab47bba678325224d872f3fc53de0f55dc1c0966fc1c
|
7
|
+
data.tar.gz: 9d38726efbf8c1c9c13cdc141000c30e5b06324ded980b005ffe5ca68464c113b1012ee647e638053713548456b85dabb259573e22a953dfcd3193738498a823
|
data/lib/souls/app/index.rb
CHANGED
@@ -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
|
@@ -71,7 +71,7 @@ module Souls
|
|
71
71
|
{ yellow_text: [github_secret_url, :yellow], yellow_text2: [souls_doc_url, :yellow] }
|
72
72
|
]
|
73
73
|
)
|
74
|
-
FileUtils.
|
74
|
+
FileUtils.rm_f(file_path)
|
75
75
|
end
|
76
76
|
|
77
77
|
def add_service_account_role(role: "roles/firebase.admin")
|
@@ -95,8 +95,7 @@ module Souls
|
|
95
95
|
"roles/storage.admin",
|
96
96
|
"roles/storage.objectAdmin",
|
97
97
|
"roles/cloudscheduler.admin",
|
98
|
-
"roles/appengine.appCreator"
|
99
|
-
"roles/cloudscheduler.admin"
|
98
|
+
"roles/appengine.appCreator"
|
100
99
|
]
|
101
100
|
roles.each do |role|
|
102
101
|
add_service_account_role(role: role)
|
@@ -15,15 +15,47 @@ module Souls
|
|
15
15
|
require("./app")
|
16
16
|
Souls::Gcloud.new.config_set
|
17
17
|
project_id = Souls.configuration.project_id
|
18
|
+
|
19
|
+
schedules_list = current_schedules
|
20
|
+
|
18
21
|
Queries::BaseQuery.all_schedules.each do |k, v|
|
19
22
|
worker_name = FileUtils.pwd.split("/").last
|
20
|
-
job_name = "#{worker_name}_#{k.to_s.underscore}"
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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}" --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
|
+
schedules_list.each do |k, _|
|
43
|
+
system("gcloud scheduler jobs delete #{k} -q >/dev/null 2>&1")
|
26
44
|
end
|
27
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
|
56
|
+
end
|
57
|
+
|
58
|
+
current_schedules
|
59
|
+
end
|
28
60
|
end
|
29
61
|
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
|
-
|
109
|
-
|
110
|
-
project_id = Souls.configuration.project_id
|
111
|
-
instance_name = Souls.configuration.instance_name
|
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=#{
|
138
|
+
--authorized-networks=#{ips} \
|
139
|
+
--quiet
|
118
140
|
"
|
119
141
|
)
|
120
142
|
end
|
@@ -139,9 +139,9 @@ module Souls
|
|
139
139
|
write_txt +=
|
140
140
|
if gem[0] == "souls"
|
141
141
|
if local
|
142
|
-
"
|
142
|
+
"gem \"souls\", \"#{version}\", path: \"~/.local_souls/\"\n"
|
143
143
|
else
|
144
|
-
"
|
144
|
+
"gem \"souls\", \"#{version}\"\n"
|
145
145
|
end
|
146
146
|
else
|
147
147
|
line
|
@@ -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 +1 @@
|
|
1
|
-
1.9.
|
1
|
+
1.9.16
|
@@ -1 +1 @@
|
|
1
|
-
1.9.
|
1
|
+
1.9.16
|
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.9.
|
4
|
+
version: 1.9.16
|
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-11-
|
13
|
+
date: 2021-11-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -54,6 +54,20 @@ dependencies:
|
|
54
54
|
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: 2.8.0
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: graphql
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 1.12.19
|
64
|
+
type: :runtime
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.12.19
|
57
71
|
- !ruby/object:Gem::Dependency
|
58
72
|
name: paint
|
59
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,6 +144,7 @@ files:
|
|
130
144
|
- lib/souls.rb
|
131
145
|
- lib/souls/app/graphql/souls_query.rb
|
132
146
|
- lib/souls/app/index.rb
|
147
|
+
- lib/souls/app/utils/souls_logger.rb
|
133
148
|
- lib/souls/cli.rb
|
134
149
|
- lib/souls/cli/cli_exception.rb
|
135
150
|
- lib/souls/cli/console/index.rb
|