pangea 0.0.22 → 0.0.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pangea/cli/subcommands/config.rb +120 -37
- data/lib/pangea/cli/subcommands/infra.rb +10 -10
- data/lib/pangea/version.rb +1 -1
- metadata +2 -3
- data/lib/pangea/extractors/README.md +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6664d8cf753fd5e4a36c6525af5208c6629076f635c2afe2a951d73251a54951
|
4
|
+
data.tar.gz: 49027000adecf0a2e1657ef530b58ddc05b1fc723655e187a1086925d7462080
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e26a27dcc7804b25d108481ff10e9e749a049e97a110fe2cee7a2802077b7bbdf83ee47ac4bf13e3d3fbdb14fde5a3cb7bb1fb1eef387903218435a5e1348c9
|
7
|
+
data.tar.gz: 86e207bf1d559aa63ff5f627011c6b2f9c2327748ef065e0108f442bc05c4e044eb9302b9388d7a24beea9e06b52fdcfb2a21f9b3aae0c7f31e13064f0cf3577
|
@@ -4,6 +4,7 @@ require %(pangea/cli/config)
|
|
4
4
|
require %(json)
|
5
5
|
require %(aws-sdk-dynamodb)
|
6
6
|
require %(aws-sdk-s3)
|
7
|
+
require %(terraform-synthesizer)
|
7
8
|
|
8
9
|
class ConfigCommand < PangeaCommand
|
9
10
|
usage do
|
@@ -19,23 +20,22 @@ class ConfigCommand < PangeaCommand
|
|
19
20
|
|
20
21
|
def help
|
21
22
|
<<~HELP
|
22
|
-
|
23
|
+
Usage: pangea config [OPTIONS] SUBCOMMAND
|
23
24
|
|
24
|
-
|
25
|
-
|
25
|
+
Arguments:
|
26
|
+
SUBCOMMAND subcommand for config
|
26
27
|
|
27
|
-
|
28
|
-
|
28
|
+
Options:
|
29
|
+
-h, --help Print usage
|
29
30
|
HELP
|
30
31
|
end
|
31
32
|
|
32
33
|
# check if dynamodb table exists
|
33
34
|
def table_exists?(table_name)
|
34
35
|
dynamodb.describe_table({ table_name: table_name })
|
35
|
-
|
36
|
-
|
36
|
+
true
|
37
37
|
rescue Aws::DynamoDB::Errors::ResourceNotFoundException
|
38
|
-
|
38
|
+
false
|
39
39
|
end
|
40
40
|
|
41
41
|
def s3
|
@@ -68,7 +68,7 @@ class ConfigCommand < PangeaCommand
|
|
68
68
|
provisioned_throughput: {
|
69
69
|
read_capacity_units: 5,
|
70
70
|
write_capacity_units: 5
|
71
|
-
}
|
71
|
+
}
|
72
72
|
}
|
73
73
|
end
|
74
74
|
|
@@ -77,48 +77,131 @@ class ConfigCommand < PangeaCommand
|
|
77
77
|
when %(show)
|
78
78
|
config = Config.resolve_configurations
|
79
79
|
puts JSON.pretty_generate(config)
|
80
|
-
when %(
|
81
|
-
puts
|
80
|
+
when %(plan)
|
81
|
+
puts 'planning pangea configuration...'
|
82
82
|
config = Config.resolve_configurations
|
83
83
|
|
84
84
|
config[:namespace].each_key do |ns_name|
|
85
85
|
ns = config[:namespace][ns_name]
|
86
86
|
ns.each_key do |ctx_name|
|
87
87
|
ctx = ns[ctx_name]
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
88
|
+
|
89
|
+
###################################################################
|
90
|
+
# setup modules
|
91
|
+
###################################################################
|
92
|
+
|
93
|
+
module_dirs = %w[lib src test]
|
94
|
+
modules = ctx[:modules]
|
95
|
+
synth = TerraformSynthesizer.new
|
96
|
+
|
97
|
+
modules.each_key do |mod_name|
|
98
|
+
this_mod = modules[mod_name]
|
99
|
+
|
100
|
+
if this_mod[:sandboxed]
|
101
|
+
# TODO: setup sandboxed module
|
102
|
+
nil
|
103
|
+
elsif this_mod[:path]
|
104
|
+
|
105
|
+
lib_dir = File.join(this_mod[:path], %(lib))
|
106
|
+
lib_files = Dir.glob(File.join(this_mod[:path], %(lib), %(**/*.rb)))
|
107
|
+
|
108
|
+
system(%(mkdir -p #{lib_dir})) unless Dir.exist?(lib_dir)
|
109
|
+
|
110
|
+
lib_files.each do |lib_file|
|
111
|
+
synth.synthesize(
|
112
|
+
File.read(
|
113
|
+
File.join(
|
114
|
+
this_mod[:path],
|
115
|
+
%(lib),
|
116
|
+
lib_file
|
117
|
+
)
|
98
118
|
)
|
99
119
|
)
|
100
|
-
puts "Created table. Status: #{result.table_description.table_status}"
|
101
|
-
rescue Aws::DynamoDB::Errors::ServiceError => error
|
102
|
-
puts error.message.to_s
|
103
120
|
end
|
104
|
-
end
|
105
121
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
122
|
+
# end process lib if exists
|
123
|
+
# process src if exists
|
124
|
+
|
125
|
+
src_dir = File.join(this_mod[:path], %(src))
|
126
|
+
src_files = Dir.glob(File.join(this_mod[:path], %(src), %(**/*.rb)))
|
127
|
+
|
128
|
+
system(%(mkdir -p #{src_dir})) unless Dir.exist?(src_dir)
|
129
|
+
|
130
|
+
lib_files.each do |lib_file|
|
131
|
+
synth.synthesize(
|
132
|
+
File.read(
|
133
|
+
File.join(
|
134
|
+
this_mod[:path],
|
135
|
+
%(lib),
|
136
|
+
lib_file
|
137
|
+
)
|
138
|
+
)
|
139
|
+
)
|
140
|
+
end
|
141
|
+
# read mod from a local path
|
142
|
+
# use terraform synthesizer to do it
|
143
|
+
|
144
|
+
# process lib if exists
|
145
|
+
|
117
146
|
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
puts JSON.pretty_generate(synth.synthesis)
|
150
|
+
end
|
151
|
+
when %(init)
|
152
|
+
puts 'intializing pangea configuration...'
|
153
|
+
config = Config.resolve_configurations
|
154
|
+
|
155
|
+
config[:namespace].each_key do |ns_name|
|
156
|
+
ns = config[:namespace][ns_name]
|
157
|
+
ns.each_key do |ctx_name|
|
158
|
+
ctx = ns[ctx_name]
|
159
|
+
next unless ctx[:state_config][:terraform][:s3]
|
118
160
|
|
119
|
-
|
161
|
+
###################################################################
|
162
|
+
# dynamodb table setup
|
163
|
+
###################################################################
|
120
164
|
|
165
|
+
unless table_exists?(ctx[:state_config][:terraform][:s3][:dynamodb_table])
|
166
|
+
begin
|
167
|
+
result = dynamodb.create_table(
|
168
|
+
dynamodb_terraform_lock_spec(
|
169
|
+
ctx[:state_config][:terraform][:s3][:dynamodb_table]
|
170
|
+
)
|
171
|
+
)
|
172
|
+
puts "Created table. Status: #{result.table_description.table_status}"
|
173
|
+
rescue Aws::DynamoDB::Errors::ServiceError => e
|
174
|
+
puts e.message.to_s
|
175
|
+
end
|
121
176
|
end
|
177
|
+
|
178
|
+
# dynamodb table setup
|
179
|
+
|
180
|
+
###################################################################
|
181
|
+
# s3 bucket setup
|
182
|
+
###################################################################
|
183
|
+
bucket_name =
|
184
|
+
ctx[:state_config][:terraform][:s3][:bucket]
|
185
|
+
if bucket_exist?(bucket_name)
|
186
|
+
puts "bucket already exists: #{bucket_name}"
|
187
|
+
else
|
188
|
+
s3.create_bucket(bucket: bucket_name)
|
189
|
+
end
|
190
|
+
|
191
|
+
# end s3 bucket setup
|
192
|
+
|
193
|
+
###################################################################
|
194
|
+
# setup directories
|
195
|
+
###################################################################
|
196
|
+
|
197
|
+
base_dir = File.join(ENV.fetch(%(HOME), nil), %(.pangea))
|
198
|
+
context_dir = File.join(base_dir, ctx_name)
|
199
|
+
synth_dir = File.join(base_dir, synth_dir)
|
200
|
+
|
201
|
+
system(%(mkdir -p #{context_dir})) unless Dir.exist?(context_dir)
|
202
|
+
system(%(mkdir -p #{synth_dir})) unless Dir.exist?(synth_dir)
|
203
|
+
|
204
|
+
# end setup directories
|
122
205
|
end
|
123
206
|
end
|
124
207
|
end
|
@@ -82,19 +82,19 @@ class InfraCommand < PangeaCommand
|
|
82
82
|
when :local
|
83
83
|
system %(mkdir -p #{CACHE_DIR}) unless Dir.exist?(CACHE_DIR)
|
84
84
|
PROJECT_SRC_DIRS.each do |src_dir|
|
85
|
-
|
85
|
+
next unless File.exist?(File.join(
|
86
|
+
project[:src][:location].to_s,
|
87
|
+
%(src),
|
88
|
+
src_dir.to_s
|
89
|
+
))
|
90
|
+
|
91
|
+
synth_files = Dir.glob("#{File.join(
|
86
92
|
project[:src][:location].to_s,
|
87
93
|
%(src),
|
88
94
|
src_dir.to_s
|
89
|
-
))
|
90
|
-
|
91
|
-
|
92
|
-
%(src),
|
93
|
-
src_dir.to_s
|
94
|
-
)}/**/*.rb")
|
95
|
-
synth_files.each do |synth_file|
|
96
|
-
synth.synthesize(File.read(synth_file))
|
97
|
-
end
|
95
|
+
)}/**/*.rb")
|
96
|
+
synth_files.each do |synth_file|
|
97
|
+
synth.synthesize(File.read(synth_file))
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
data/lib/pangea/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pangea
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- drzthslnt@gmail.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop-rspec
|
@@ -301,7 +301,6 @@ files:
|
|
301
301
|
- lib/pangea/errors/no_infra_target_error.rb
|
302
302
|
- lib/pangea/errors/project_not_found_error.rb
|
303
303
|
- lib/pangea/errors/site_not_found_error.rb
|
304
|
-
- lib/pangea/extractors/README.md
|
305
304
|
- lib/pangea/log/init.rb
|
306
305
|
- lib/pangea/say/init.rb
|
307
306
|
- lib/pangea/shell/README.md
|