pangea 0.0.22 → 0.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 590fc18f1a9dc85713d60759225426826b3bd1d43d7d5bbda7a0789c639de979
4
- data.tar.gz: 9f7c9fd0f304d159d5a4c718339bc190be2ddc49df3796cea7d478661dbb00cc
3
+ metadata.gz: 6664d8cf753fd5e4a36c6525af5208c6629076f635c2afe2a951d73251a54951
4
+ data.tar.gz: 49027000adecf0a2e1657ef530b58ddc05b1fc723655e187a1086925d7462080
5
5
  SHA512:
6
- metadata.gz: 9ba30fa475937b382a47aeed087a35ce365a0ac5ac1cd9d26f67a91c6c7a57c07a1dfe5d056c795ea703c1a5583f2c2c8214cd06adf361e43f90eea4aa2d33d8
7
- data.tar.gz: 44ae22e85c67efac5de7e9c688f20bd38ae04e2b574ee63174bd8e053ac5d6a99c04b1102e593f0e9b06a6e77cdb640fe350702e565944fac27887e16637f88d
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
- Usage: pangea config [OPTIONS] SUBCOMMAND
23
+ Usage: pangea config [OPTIONS] SUBCOMMAND
23
24
 
24
- Arguments:
25
- SUBCOMMAND subcommand for config
25
+ Arguments:
26
+ SUBCOMMAND subcommand for config
26
27
 
27
- Options:
28
- -h, --help Print usage
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
- return true
36
-
36
+ true
37
37
  rescue Aws::DynamoDB::Errors::ResourceNotFoundException
38
- return false
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 %(init)
81
- puts "intializing pangea configuration..."
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
- if ctx[:state_config][:terraform][:s3]
89
- ###################################################################
90
- # dynamodb table setup
91
- ###################################################################
92
-
93
- unless table_exists?(ctx[:state_config][:terraform][:s3][:dynamodb_table])
94
- begin
95
- result = dynamodb.create_table(
96
- dynamodb_terraform_lock_spec(
97
- ctx[:state_config][:terraform][:s3][:dynamodb_table]
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
- # dynamodb table setup
107
-
108
- ###################################################################
109
- # s3 bucket setup
110
- ###################################################################
111
- bucket_name =
112
- ctx[:state_config][:terraform][:s3][:bucket]
113
- if bucket_exist?(bucket_name)
114
- puts "bucket already exists: #{bucket_name}"
115
- else
116
- s3.create_bucket(bucket: bucket_name)
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
- # end s3 bucket setup
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
- if File.exist?(File.join(
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
- synth_files = Dir.glob("#{File.join(
91
- project[:src][:location].to_s,
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
 
@@ -1,3 +1,3 @@
1
1
  module Pangea
2
- VERSION = %(0.0.22).freeze
2
+ VERSION = %(0.0.24).freeze
3
3
  end
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.22
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-22 00:00:00.000000000 Z
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
@@ -1,3 +0,0 @@
1
- # extractors
2
-
3
- take a synthesis and return appropriate hash of namespaces