souls 0.51.2 → 0.52.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/exe/souls +4 -202
- data/lib/souls/api/generate/application.rb +97 -94
- data/lib/souls/api/generate/connection.rb +5 -4
- data/lib/souls/api/generate/edge.rb +5 -4
- data/lib/souls/api/generate/index.rb +0 -1
- data/lib/souls/api/generate/manager.rb +9 -7
- data/lib/souls/api/generate/model.rb +16 -18
- data/lib/souls/api/generate/mutation.rb +217 -218
- data/lib/souls/api/generate/policy.rb +5 -5
- data/lib/souls/api/generate/query.rb +51 -51
- data/lib/souls/api/generate/resolver.rb +115 -115
- data/lib/souls/api/generate/rspec_factory.rb +53 -53
- data/lib/souls/api/generate/rspec_model.rb +5 -5
- data/lib/souls/api/generate/rspec_mutation.rb +178 -178
- data/lib/souls/api/generate/rspec_policy.rb +5 -5
- data/lib/souls/api/generate/rspec_query.rb +111 -111
- data/lib/souls/api/generate/rspec_resolver.rb +163 -163
- data/lib/souls/api/generate/type.rb +66 -66
- data/lib/souls/api/index.rb +7 -4
- data/lib/souls/api/update/index.rb +15 -0
- data/lib/souls/api/update/mutation.rb +68 -64
- data/lib/souls/api/update/resolver.rb +59 -60
- data/lib/souls/api/update/rspec_factory.rb +40 -39
- data/lib/souls/api/update/rspec_mutation.rb +84 -83
- data/lib/souls/api/update/rspec_resolver.rb +70 -69
- data/lib/souls/api/update/type.rb +39 -38
- data/lib/souls/cli/console/index.rb +13 -1
- data/lib/souls/cli/create/index.rb +97 -93
- data/lib/souls/cli/db/index.rb +122 -1
- data/lib/souls/cli/docker/index.rb +30 -38
- data/lib/souls/cli/gcloud/compute/index.rb +100 -98
- data/lib/souls/cli/gcloud/iam/index.rb +84 -69
- data/lib/souls/cli/gcloud/index.rb +36 -35
- data/lib/souls/cli/gcloud/pubsub/subscriptions.rb +40 -27
- data/lib/souls/cli/gcloud/pubsub/topics.rb +16 -10
- data/lib/souls/cli/gcloud/run/index.rb +23 -17
- data/lib/souls/cli/gcloud/sql/index.rb +66 -47
- data/lib/souls/cli/index.rb +3 -20
- data/lib/souls/cli/init/index.rb +140 -140
- data/lib/souls/cli/release/release.rb +106 -105
- data/lib/souls/cli/server/index.rb +12 -1
- data/lib/souls/cli/sync/conf.rb +39 -38
- data/lib/souls/cli/sync/model.rb +19 -20
- data/lib/souls/cli/sync/pubsub.rb +69 -70
- data/lib/souls/cli/upgrade/gemfile.rb +108 -0
- data/lib/souls/cli/upgrade/index.rb +1 -1
- data/lib/souls/cli.rb +57 -0
- data/lib/souls/index.rb +1 -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/worker/generate/index.rb +1 -1
- data/lib/souls/worker/generate/job.rb +45 -0
- data/lib/souls/worker/generate/mailer.rb +38 -43
- data/lib/souls/worker/index.rb +3 -1
- data/lib/souls.rb +2 -0
- metadata +19 -5
- data/lib/souls/api/generate/migration.rb +0 -51
- data/lib/souls/cli/upgrade/gem_update.rb +0 -107
- data/lib/souls/worker/generate/mutation.rb +0 -44
@@ -1,125 +1,127 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
2
|
+
class Compute < Thor
|
3
|
+
desc "setup_vpc_nat", "Set Up VPC Cloud Nat"
|
4
|
+
method_option :range, default: "10.124.0.0/28", aliases: "--range", desc: "GCP VPC Network IP Range"
|
5
|
+
def setup_vpc_nat
|
6
|
+
create_network
|
7
|
+
create_firewall_tcp(range: options[:range])
|
8
|
+
create_firewall_ssh
|
9
|
+
create_subnet(range: options[:range])
|
10
|
+
create_connector
|
11
|
+
create_router
|
12
|
+
create_external_ip
|
13
|
+
create_nat
|
14
|
+
nat_credit
|
15
|
+
rescue Thor::Error => e
|
16
|
+
raise(Thor::Error, e)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
16
20
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
+
def create_network
|
22
|
+
app_name = Souls.configuration.app
|
23
|
+
system("gcloud compute networks create #{app_name}")
|
24
|
+
end
|
21
25
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
+
def create_firewall_tcp(range: "10.124.0.0/28")
|
27
|
+
app_name = Souls.configuration.app
|
28
|
+
system(
|
29
|
+
"gcloud compute firewall-rules create #{app_name} \
|
26
30
|
--network #{app_name} --allow tcp,udp,icmp --source-ranges #{range}"
|
27
|
-
|
28
|
-
|
31
|
+
)
|
32
|
+
end
|
29
33
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
+
def create_firewall_ssh
|
35
|
+
app_name = Souls.configuration.app
|
36
|
+
system(
|
37
|
+
"gcloud compute firewall-rules create #{app_name}-ssh --network #{app_name} \
|
34
38
|
--allow tcp:22,tcp:3389,icmp"
|
35
|
-
|
36
|
-
|
39
|
+
)
|
40
|
+
end
|
37
41
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
def create_subnet(range: "10.124.0.0/28")
|
43
|
+
app_name = Souls.configuration.app
|
44
|
+
region = Souls.configuration.region
|
45
|
+
system(
|
46
|
+
"gcloud compute networks subnets create #{app_name}-subnet \
|
43
47
|
--range=#{range} --network=#{app_name} --region=#{region}"
|
44
|
-
|
45
|
-
|
48
|
+
)
|
49
|
+
end
|
46
50
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
51
|
+
def create_connector
|
52
|
+
app_name = Souls.configuration.app
|
53
|
+
project_id = Souls.configuration.project_id
|
54
|
+
region = Souls.configuration.region
|
55
|
+
system(
|
56
|
+
"gcloud compute networks vpc-access connectors create #{app_name}-connector \
|
53
57
|
--region=#{region} \
|
54
58
|
--subnet-project=#{project_id} \
|
55
59
|
--subnet=#{app_name}-subnet"
|
56
|
-
|
57
|
-
|
60
|
+
)
|
61
|
+
end
|
58
62
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
63
|
+
def create_router
|
64
|
+
app_name = Souls.configuration.app
|
65
|
+
region = Souls.configuration.region
|
66
|
+
system("gcloud compute routers create #{app_name}-router --network=#{app_name} --region=#{region}")
|
67
|
+
end
|
64
68
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
69
|
+
def create_external_ip
|
70
|
+
app_name = Souls.configuration.app
|
71
|
+
region = Souls.configuration.region
|
72
|
+
system("gcloud compute addresses create #{app_name}-worker-ip --region=#{region}")
|
73
|
+
end
|
70
74
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
75
|
+
def create_nat
|
76
|
+
app_name = Souls.configuration.app
|
77
|
+
region = Souls.configuration.region
|
78
|
+
system(
|
79
|
+
"gcloud compute routers nats create #{app_name}-worker-nat \
|
76
80
|
--router=#{app_name}-router \
|
77
81
|
--region=#{region} \
|
78
82
|
--nat-custom-subnet-ip-ranges=#{app_name}-subnet \
|
79
83
|
--nat-external-ip-pool=#{app_name}-worker-ip"
|
80
|
-
|
81
|
-
|
84
|
+
)
|
85
|
+
end
|
82
86
|
|
83
|
-
|
84
|
-
|
85
|
-
|
87
|
+
def network_list
|
88
|
+
system("gcloud compute network list")
|
89
|
+
end
|
86
90
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
91
|
+
def nat_credit
|
92
|
+
app_name = Souls.configuration.app
|
93
|
+
line = Paint["====================================", :yellow]
|
94
|
+
puts("\n")
|
95
|
+
puts(line)
|
96
|
+
txt2 = <<~TEXT
|
97
|
+
_____ ____ __ ____#{' '}
|
98
|
+
/ ___// __ \\/ / / / / %{red1}
|
99
|
+
\\__ \\/ / / / / / / / %{red2}
|
100
|
+
___/ / /_/ / /_/ / /___%{red3}#{' '}
|
101
|
+
/____/\\____/\\____/_____%{red4}#{' '}
|
102
|
+
TEXT
|
103
|
+
red1 = ["_____", :red]
|
104
|
+
red2 = ["/ ___/", :red]
|
105
|
+
red3 = ["(__ )", :red]
|
106
|
+
red4 = ["/____/", :red]
|
107
|
+
ms = Paint % [txt2, :cyan, { red1: red1, red2: red2, red3: red3, red4: red4 }]
|
108
|
+
puts(ms)
|
109
|
+
puts(line)
|
110
|
+
welcome = Paint["VPC Network is All Set!", :white]
|
111
|
+
puts(welcome)
|
112
|
+
puts(line)
|
113
|
+
endroll = <<~TEXT
|
110
114
|
|
111
|
-
|
115
|
+
Edit `.github/workflow/worker.yml`
|
112
116
|
|
113
|
-
|
114
|
-
|
115
|
-
|
117
|
+
Add these 2 options in \n`- name: Deploy to Cloud Run` step
|
118
|
+
\n--vpc-connector=#{app_name}-connector \
|
119
|
+
\n--vpc-egress=all \
|
116
120
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
end
|
122
|
-
end
|
121
|
+
TEXT
|
122
|
+
cd = Paint[endroll, :white]
|
123
|
+
puts(cd)
|
124
|
+
puts(line)
|
123
125
|
end
|
124
126
|
end
|
125
127
|
end
|
@@ -1,83 +1,98 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
class Iam < Thor
|
3
|
+
desc "setup_key", "Create Google Cloud IAM Service Account Key And Set All Permissions"
|
4
|
+
def setup_key
|
5
|
+
Souls::Gcloud.new.auth_login
|
6
|
+
create_service_account
|
7
|
+
create_service_account_key
|
8
|
+
Souls::Gcloud.new.enable_permissions
|
9
|
+
add_permissions
|
10
|
+
export_key_to_console
|
11
|
+
rescue Thor::Error => e
|
12
|
+
raise(Thor::Error, e)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
desc "create_service_account", "Create Google Cloud IAM Service Account"
|
18
|
+
def create_service_account
|
19
|
+
app_name = Souls.configuration.app
|
20
|
+
system(
|
21
|
+
"gcloud iam service-accounts create #{app_name} \
|
8
22
|
--description='Souls Service Account' \
|
9
|
-
--display-name=#{
|
10
|
-
|
11
|
-
|
23
|
+
--display-name=#{app_name}"
|
24
|
+
)
|
25
|
+
end
|
12
26
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
27
|
+
desc "create_service_account_key", "Create Google Cloud Service Account Key"
|
28
|
+
def create_service_account_key
|
29
|
+
app_name = Souls.configuration.app
|
30
|
+
project_id = Souls.configuration.project_id
|
31
|
+
system(
|
32
|
+
"gcloud iam service-accounts keys create ./config/keyfile.json \
|
33
|
+
--iam-account #{app_name}@#{project_id}.iam.gserviceaccount.com"
|
34
|
+
)
|
35
|
+
end
|
19
36
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
+
def export_key_to_console
|
38
|
+
file_path = "config/keyfile.json"
|
39
|
+
puts(Paint["======= below(ここから)=======", :cyan])
|
40
|
+
text = []
|
41
|
+
File.open(file_path, "r") do |line|
|
42
|
+
line.each_line do |l|
|
43
|
+
text << l
|
44
|
+
end
|
45
|
+
end
|
46
|
+
key = text.join(",").gsub(/^,/, "").chomp!
|
47
|
+
github_repo = `git remote show origin -n | grep 'Fetch URL:' | awk '{print $3}'`.strip
|
48
|
+
github_repo = "https://github.com/#{github_repo.match(/:(.+).git/)[1]}" if github_repo.include?("git@github")
|
49
|
+
puts(Paint[key, :white])
|
50
|
+
puts(Paint["======= above(ここまで)=======", :cyan])
|
51
|
+
github_secret_url = "#{github_repo}/settings/secrets/actions"
|
52
|
+
souls_doc_url = "https://souls.elsoul.nl/docs/tutorial/zero-to-deploy/#github-シークレットキーの登録"
|
53
|
+
txt1 = <<~TEXT
|
37
54
|
|
38
|
-
|
55
|
+
⬆⬆⬆ Copy the service account key above ⬆⬆⬆⬆
|
39
56
|
|
40
|
-
|
57
|
+
And
|
41
58
|
|
42
|
-
|
59
|
+
Go to %{yellow_text}
|
43
60
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
61
|
+
Reference: %{yellow_text2}
|
62
|
+
TEXT
|
63
|
+
puts(
|
64
|
+
Paint % [
|
65
|
+
txt1,
|
66
|
+
:white,
|
67
|
+
{ yellow_text: [github_secret_url, :yellow], yellow_text2: [souls_doc_url, :yellow] }
|
68
|
+
]
|
69
|
+
)
|
70
|
+
FileUtils.rm(file_path)
|
71
|
+
end
|
55
72
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
--member='serviceAccount:#{
|
73
|
+
def add_service_account_role(role: "roles/firebase.admin")
|
74
|
+
app_name = Souls.configuration.app
|
75
|
+
project_id = Souls.configuration.project_id
|
76
|
+
system(
|
77
|
+
"gcloud projects add-iam-policy-binding #{project_id} \
|
78
|
+
--member='serviceAccount:#{app_name}@#{project_id}.iam.gserviceaccount.com' \
|
62
79
|
--role=#{role}"
|
63
|
-
|
64
|
-
|
80
|
+
)
|
81
|
+
end
|
65
82
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
80
|
-
end
|
83
|
+
def add_permissions
|
84
|
+
roles = [
|
85
|
+
"roles/cloudsql.editor",
|
86
|
+
"roles/containerregistry.ServiceAgent",
|
87
|
+
"roles/pubsub.editor",
|
88
|
+
"roles/datastore.user",
|
89
|
+
"roles/iam.serviceAccountUser",
|
90
|
+
"roles/run.admin",
|
91
|
+
"roles/storage.admin",
|
92
|
+
"roles/storage.objectAdmin"
|
93
|
+
]
|
94
|
+
roles.each do |role|
|
95
|
+
add_service_account_role(role: role)
|
81
96
|
end
|
82
97
|
end
|
83
98
|
end
|
@@ -5,45 +5,46 @@ require_relative "./sql/index"
|
|
5
5
|
require_relative "./compute/index"
|
6
6
|
|
7
7
|
module Souls
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
project_id = Souls.configuration.project_id if project_id.blank?
|
12
|
-
system("gcloud config set project #{project_id}")
|
13
|
-
system("gcloud auth login")
|
14
|
-
end
|
15
|
-
|
16
|
-
def enable_permissions
|
17
|
-
system("gcloud services enable compute.googleapis.com")
|
18
|
-
puts("Operating permission to compute.googleapis.com ...")
|
19
|
-
system("gcloud services enable iam.googleapis.com")
|
20
|
-
puts("Operating permission to iam.googleapis.com ...")
|
21
|
-
system("gcloud services enable dns.googleapis.com")
|
22
|
-
puts("Operating permission to dns.googleapis.com ...")
|
23
|
-
system("gcloud services enable sqladmin.googleapis.com")
|
24
|
-
puts("Operating permission to sqladmin.googleapis.com ...")
|
25
|
-
system("gcloud services enable sql-component.googleapis.com")
|
26
|
-
puts("Operating permission to sql-component.googleapis.com ...")
|
27
|
-
system("gcloud services enable servicenetworking.googleapis.com")
|
28
|
-
puts("Operating permission to servicenetworking.googleapis.com ...")
|
29
|
-
system("gcloud services enable containerregistry.googleapis.com")
|
30
|
-
puts("Operating permission to containerregistry.googleapis.com")
|
31
|
-
system("gcloud services enable run.googleapis.com")
|
32
|
-
puts("Operating permission to run.googleapis.com")
|
33
|
-
system("gcloud services enable vpcaccess.googleapis.com")
|
34
|
-
puts("Operating permission to vpcaccess.googleapis.com")
|
35
|
-
end
|
36
|
-
end
|
37
|
-
module Iam
|
38
|
-
end
|
8
|
+
class Gcloud < Thor
|
9
|
+
desc "iam [COMMAND]", "souls gcloud iam Commands"
|
10
|
+
subcommand "iam", Iam
|
39
11
|
|
40
|
-
|
41
|
-
|
12
|
+
desc "pubsub [COMMAND]", "souls gcloud pubsub Commands"
|
13
|
+
subcommand "pubsub", Pubsub
|
14
|
+
|
15
|
+
desc "sql [COMMAND]", "souls gcloud sql Commands"
|
16
|
+
subcommand "sql", Sql
|
17
|
+
|
18
|
+
desc "compute [COMMAND]", "souls gcloud compute Commands"
|
19
|
+
subcommand "compute", Compute
|
20
|
+
|
21
|
+
desc "run [COMMAND]", "souls gcloud run Commands"
|
22
|
+
subcommand "cloud_run", CloudRun
|
23
|
+
|
24
|
+
map run: "cloud_run"
|
42
25
|
|
43
|
-
|
26
|
+
desc "auth_login", "gcloud config set and gcloud auth login"
|
27
|
+
def auth_login
|
28
|
+
project_id = Souls.configuration.project_id
|
29
|
+
system("gcloud config set project #{project_id}")
|
30
|
+
system("gcloud auth login")
|
31
|
+
rescue Thor::Error => e
|
32
|
+
raise(Thor::Error, e)
|
44
33
|
end
|
45
34
|
|
46
|
-
|
35
|
+
desc "enable_permissions", "Enable Google Cloud APIs for SOULs Framework"
|
36
|
+
def enable_permissions
|
37
|
+
system("gcloud services enable compute.googleapis.com")
|
38
|
+
system("gcloud services enable iam.googleapis.com")
|
39
|
+
system("gcloud services enable dns.googleapis.com")
|
40
|
+
system("gcloud services enable sqladmin.googleapis.com")
|
41
|
+
system("gcloud services enable sql-component.googleapis.com")
|
42
|
+
system("gcloud services enable servicenetworking.googleapis.com")
|
43
|
+
system("gcloud services enable containerregistry.googleapis.com")
|
44
|
+
system("gcloud services enable run.googleapis.com")
|
45
|
+
system("gcloud services enable vpcaccess.googleapis.com")
|
46
|
+
rescue Thor::Error => e
|
47
|
+
raise(Thor::Error, e)
|
47
48
|
end
|
48
49
|
end
|
49
50
|
end
|