pangea 0.0.14 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86f52127adf20541f5f038f3aa1c3cbc65a3ea8dbbc29c31b5d4235aefc1cafb
4
- data.tar.gz: 27e5dadf8c8fd18ccff33514c716dbb4bf25956bd47e0787988cf8d99376272d
3
+ metadata.gz: d4e6d0e30376541027edb2ef4697b7063702a15d55e5f83edfda9df7cf37c4a2
4
+ data.tar.gz: ffbb952d9094f42fbb6b1e1fab484e5cd7a27cda4b42ce0592cf94724d48655b
5
5
  SHA512:
6
- metadata.gz: 774b42a5d83744f922cd6484ff9571c070f3fd6da311aa65a6ed265af14af871940e3f5649179538c41ce40e7fae49b27f5d10008215ed9e0509f6131404bde7
7
- data.tar.gz: a85a89d009b7eb2e66f9853cfa38be9141d586d3c0c96a565e7781f2ded9347196bfe40e016c0d9a6ea61a392b9836a136159c574b80501e36df6e45181b5121
6
+ metadata.gz: b725de8b3a0089d3307f569ad1b676e4c6d516d5bf08771b34c3c0406701472cd810fb433c9398796325f9c63f99bc4147adebdccbd4a4dd9b1833325b644756
7
+ data.tar.gz: 7d36b9abdc9cd69cb1947a8ac4efa1ad3ed1ccd89d21782e0616be3278b95d2d175ca41d712030bda7c455b10ccd6dc88ab8be50be0a9708ea2e3675c9e44a24
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.14).freeze
2
+ VERSION = %(0.0.16).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.14
4
+ version: 0.0.16
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