pangea 0.0.13 → 0.0.15

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: 684ecb24ce055428b4bbfbfaeac6c5b2b65eb21a079e8ca8b6777cd569e6d742
4
- data.tar.gz: df884786973df927acb56ef8e6ed7e18a46746e5a276c280117b9b5c03de3ac4
3
+ metadata.gz: 9cec392028a8590a6c4aa563625017362f433f797d7fe76ca97fb39d28c0f4c4
4
+ data.tar.gz: '008dc255233ea0ae11b9194be668fc0a6cdd599a6e2e4afd4c26c29e4ad24145'
5
5
  SHA512:
6
- metadata.gz: 16253f6e954e6d7a2f40afc53bc23229c9ba25a84b656ad50bf8a18ca75280f0a5e012f6a44c81e972e4f57d06796e9247d09ce23be4b608ad7332ff8ef2e097
7
- data.tar.gz: 529b6fdd469d29238b1f91121e01ca71980db78d03a8db226d1e84a31e5ee08f1b639322166185cac23ba9ef1dca617d91a8f75d0d36b489c5faf5b2cf05559d
6
+ metadata.gz: a4b1414395a7c8d2af4a917fb8c11b9f9107b51c3698f7b9a176bffb2325e9bd5f3c80cdbd78a846fe0bb160302390bdc023a79f57563c122f1c954db685e2a6
7
+ data.tar.gz: 55fe669186c7451318454b1eb353f3524eaa913da31aad5e52f46598b9293c2a83cb476d7286b19fb39b5a045ebe9b715e47f4f362cf52322dd9c5a0a711d816
data/Gemfile CHANGED
@@ -17,6 +17,7 @@ end
17
17
 
18
18
  group :production do
19
19
  %w[
20
+ aws-sdk-dynamodb
20
21
  terraform-synthesizer
21
22
  abstract-synthesizer
22
23
  tty-progressbar
data/Gemfile.lock CHANGED
@@ -3,12 +3,25 @@ GEM
3
3
  specs:
4
4
  abstract-synthesizer (0.0.1)
5
5
  ast (2.4.2)
6
+ aws-eventstream (1.2.0)
7
+ aws-partitions (1.791.0)
8
+ aws-sdk-core (3.178.0)
9
+ aws-eventstream (~> 1, >= 1.0.2)
10
+ aws-partitions (~> 1, >= 1.651.0)
11
+ aws-sigv4 (~> 1.5)
12
+ jmespath (~> 1, >= 1.6.1)
13
+ aws-sdk-dynamodb (1.92.0)
14
+ aws-sdk-core (~> 3, >= 3.177.0)
15
+ aws-sigv4 (~> 1.1)
16
+ aws-sigv4 (1.6.0)
17
+ aws-eventstream (~> 1, >= 1.0.2)
6
18
  backport (1.2.0)
7
19
  benchmark (0.2.1)
8
20
  citrus (3.0.2)
9
21
  diff-lcs (1.5.0)
10
22
  e2mmap (0.1.0)
11
23
  jaro_winkler (1.5.6)
24
+ jmespath (1.6.2)
12
25
  json (2.6.3)
13
26
  keycutter (1.0.2)
14
27
  kramdown (2.4.0)
@@ -16,7 +29,7 @@ GEM
16
29
  kramdown-parser-gfm (1.1.0)
17
30
  kramdown (~> 2.0)
18
31
  language_server-protocol (3.17.0.3)
19
- nokogiri (1.15.2-x86_64-darwin)
32
+ nokogiri (1.15.3)
20
33
  racc (~> 1.4)
21
34
  parallel (1.23.0)
22
35
  parser (3.2.2.3)
@@ -41,11 +54,11 @@ GEM
41
54
  rspec-expectations (3.12.3)
42
55
  diff-lcs (>= 1.2.0, < 2.0)
43
56
  rspec-support (~> 3.12.0)
44
- rspec-mocks (3.12.5)
57
+ rspec-mocks (3.12.6)
45
58
  diff-lcs (>= 1.2.0, < 2.0)
46
59
  rspec-support (~> 3.12.0)
47
60
  rspec-support (3.12.1)
48
- rubocop (1.54.0)
61
+ rubocop (1.54.2)
49
62
  json (~> 2.3)
50
63
  language_server-protocol (>= 3.17.0)
51
64
  parallel (~> 1.10)
@@ -117,10 +130,11 @@ GEM
117
130
  yard (0.9.34)
118
131
 
119
132
  PLATFORMS
120
- x86_64-darwin-22
133
+ ruby
121
134
 
122
135
  DEPENDENCIES
123
136
  abstract-synthesizer
137
+ aws-sdk-dynamodb
124
138
  keycutter
125
139
  rake
126
140
  rspec
data/gemset.nix CHANGED
@@ -19,6 +19,59 @@
19
19
  };
20
20
  version = "2.4.2";
21
21
  };
22
+ aws-eventstream = {
23
+ groups = ["default" "production"];
24
+ platforms = [];
25
+ source = {
26
+ remotes = ["https://rubygems.org"];
27
+ sha256 = "1pyis1nvnbjxk12a43xvgj2gv0mvp4cnkc1gzw0v1018r61399gz";
28
+ type = "gem";
29
+ };
30
+ version = "1.2.0";
31
+ };
32
+ aws-partitions = {
33
+ groups = ["default" "production"];
34
+ platforms = [];
35
+ source = {
36
+ remotes = ["https://rubygems.org"];
37
+ sha256 = "0728316dwkkfw2m4pwy37dmrl7mxalxvjny2y942nd1zd16n72p9";
38
+ type = "gem";
39
+ };
40
+ version = "1.791.0";
41
+ };
42
+ aws-sdk-core = {
43
+ dependencies = ["aws-eventstream" "aws-partitions" "aws-sigv4" "jmespath"];
44
+ groups = ["default" "production"];
45
+ platforms = [];
46
+ source = {
47
+ remotes = ["https://rubygems.org"];
48
+ sha256 = "1jv5h7n0vkyjq0v3xqad5xhrl4ijnh214zq3xg4ghvsk6ah8a90r";
49
+ type = "gem";
50
+ };
51
+ version = "3.178.0";
52
+ };
53
+ aws-sdk-dynamodb = {
54
+ dependencies = ["aws-sdk-core" "aws-sigv4"];
55
+ groups = ["production"];
56
+ platforms = [];
57
+ source = {
58
+ remotes = ["https://rubygems.org"];
59
+ sha256 = "1bnm7bxpz14jggrgidddzirm20w1hj9jfafp20l8rrxrw017bdgi";
60
+ type = "gem";
61
+ };
62
+ version = "1.92.0";
63
+ };
64
+ aws-sigv4 = {
65
+ dependencies = ["aws-eventstream"];
66
+ groups = ["default" "production"];
67
+ platforms = [];
68
+ source = {
69
+ remotes = ["https://rubygems.org"];
70
+ sha256 = "0z889c4c1w7wsjm3szg64ay5j51kjl4pdf94nlr1yks2rlanm7na";
71
+ type = "gem";
72
+ };
73
+ version = "1.6.0";
74
+ };
22
75
  backport = {
23
76
  groups = ["default" "development"];
24
77
  platforms = [];
@@ -79,6 +132,16 @@
79
132
  };
80
133
  version = "1.5.6";
81
134
  };
135
+ jmespath = {
136
+ groups = ["default" "production"];
137
+ platforms = [];
138
+ source = {
139
+ remotes = ["https://rubygems.org"];
140
+ sha256 = "1cdw9vw2qly7q7r41s7phnac264rbsdqgj4l0h4nqgbjb157g393";
141
+ type = "gem";
142
+ };
143
+ version = "1.6.2";
144
+ };
82
145
  json = {
83
146
  groups = ["default" "development"];
84
147
  platforms = [];
@@ -137,10 +200,10 @@
137
200
  platforms = [];
138
201
  source = {
139
202
  remotes = ["https://rubygems.org"];
140
- sha256 = "0c3r6dxi50cy4bdn10jr08yi7hdrgy4x4l3z64703i71kv0fwzmm";
203
+ sha256 = "1jw8a20a9k05fpz3q24im19b97idss3179z76yn5scc5b8lk2rl7";
141
204
  type = "gem";
142
205
  };
143
- version = "1.15.2";
206
+ version = "1.15.3";
144
207
  };
145
208
  parallel = {
146
209
  groups = ["default" "development"];
@@ -284,10 +347,10 @@
284
347
  platforms = [];
285
348
  source = {
286
349
  remotes = ["https://rubygems.org"];
287
- sha256 = "1hfm17xakfvwya236graj6c2arr4sb9zasp35q5fykhyz8mhs0w2";
350
+ sha256 = "1gq7gviwpck7fhp4y5ibljljvxgjklza18j62qf6zkm2icaa8lfy";
288
351
  type = "gem";
289
352
  };
290
- version = "3.12.5";
353
+ version = "3.12.6";
291
354
  };
292
355
  rspec-support = {
293
356
  groups = ["default" "development"];
@@ -305,10 +368,10 @@
305
368
  platforms = [];
306
369
  source = {
307
370
  remotes = ["https://rubygems.org"];
308
- sha256 = "02ysjbi1gkcpj4x1fdlbzz3vs2vqkk161smrawnaw77y7m3gvq8z";
371
+ sha256 = "1hc469ahgpfwbvv2q3hqlhp7dlzcii8dlm8k6k324sq26lilv27r";
309
372
  type = "gem";
310
373
  };
311
- version = "1.54.0";
374
+ version = "1.54.2";
312
375
  };
313
376
  rubocop-ast = {
314
377
  dependencies = ["parser"];
@@ -11,7 +11,7 @@ module Config
11
11
 
12
12
  def xdg_config_home
13
13
  ENV.fetch(
14
- %(XDG_CONFIG_HOME),
14
+ %(XDG_CONFIG_HOME),
15
15
  %(#{ENV.fetch('HOME', nil)}/.config)
16
16
  )
17
17
  end
@@ -36,7 +36,7 @@ module Config
36
36
  )
37
37
 
38
38
  # end system level configuration
39
-
39
+
40
40
  ###############################
41
41
  # home configuration
42
42
  ###############################
@@ -49,7 +49,7 @@ module Config
49
49
  )
50
50
 
51
51
  # end home configuration
52
-
52
+
53
53
  ###############################
54
54
  # local configuration
55
55
  ###############################
@@ -2,6 +2,7 @@ require %(pangea/cli/subcommands/pangea)
2
2
  require %(pangea/synthesizer/config)
3
3
  require %(pangea/cli/config)
4
4
  require %(json)
5
+ require %(aws-sdk-dynamodb)
5
6
 
6
7
  class ConfigCommand < PangeaCommand
7
8
  usage do
@@ -27,11 +28,70 @@ class ConfigCommand < PangeaCommand
27
28
  HELP
28
29
  end
29
30
 
31
+ # check if dynamodb table exists
32
+ def table_exists?(table_name)
33
+ dynamodb.describe_table({ table_name: table_name })
34
+ return true
35
+
36
+ rescue Aws::DynamoDB::Errors::ResourceNotFoundException
37
+ return false
38
+ end
39
+
40
+ def dynamodb
41
+ @dynamodb ||= Aws::DynamoDB::Client.new
42
+ end
43
+
44
+ def dynamodb_terraform_lock_spec(table_name)
45
+ {
46
+ table_name: table_name,
47
+ key_schema: [
48
+ {
49
+ attribute_name: %(LockID),
50
+ key_type: %(HASH)
51
+ }
52
+ ],
53
+ attribute_definitions: [
54
+ {
55
+ attribute_name: %(LockID),
56
+ attribute_type: %(S)
57
+ }
58
+ ],
59
+ provisioned_throughput: {
60
+ read_capacity_units: 5,
61
+ write_capacity_units: 5
62
+ },
63
+ }
64
+ end
65
+
30
66
  def run(argv)
31
67
  case argv[1].to_s
32
68
  when %(show)
33
69
  config = Config.resolve_configurations
34
70
  puts JSON.pretty_generate(config)
71
+ when %(init)
72
+ puts "intializing pangea configuration..."
73
+ config = Config.resolve_configurations
74
+
75
+ config[:namespace].each_key do |ns_name|
76
+ ns = config[:namespace][ns_name]
77
+ ns.each_key do |ctx_name|
78
+ ctx = ns[ctx_name]
79
+ if ctx[:state_config][:terraform][:s3]
80
+ unless table_exists?(ctx[:state_config][:terraform][:s3][:dynamodb_table])
81
+ begin
82
+ result = dynamodb.create_table(
83
+ dynamodb_terraform_lock_spec(
84
+ ctx[:state_config][:terraform][:s3][:dynamodb_table]
85
+ )
86
+ )
87
+ puts "Created table. Status: #{result.table_description.table_status}"
88
+ rescue Aws::DynamoDB:Errors::ServiceError => error
89
+ puts error.message.to_s
90
+ end
91
+ end
92
+ end
93
+ end
94
+
35
95
  end
36
96
  end
37
97
  end
@@ -1,3 +1,3 @@
1
1
  module Pangea
2
- VERSION = %(0.0.13).freeze
2
+ VERSION = %(0.0.15).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.13
4
+ version: 0.0.15
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-18 00:00:00.000000000 Z
11
+ date: 2023-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop-rspec