belt 0.3.19 → 0.3.21

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: c07291b16ac92bac6281fb35d39777453d87295f41b4de57bf2e7e1f5d2e82a2
4
- data.tar.gz: 24a4b9fc917ce9f07a531a9f8d2b4d7b3a93e67d2095b1f7489f0a3551ca7748
3
+ metadata.gz: e913248aec69e4989d916f23eca445762abbdd0f3e1aa46b71bda1de8accbb68
4
+ data.tar.gz: 9865a153a7f77ffbdedccf3e0250d205fab538f57a853723d043f51d9eacd162
5
5
  SHA512:
6
- metadata.gz: 7e6a5ec05148c1fe9cd01f6da381c88f1749021f587b76c1b10154d54210da6a46b52e82d1416f8160a20d682feb12254000b3b2fbc104b25f1505aa86bce6ea
7
- data.tar.gz: ab4afd20f9f5f474bd7b4ea9fec32d17b360ff5c4d556c3b0a223b95c4d5d4210bd99fd3b4ab66bfdbee930c40eb3c26acb1705912a2bb81e77594a3f7a223d6
6
+ metadata.gz: 8bab207b1d5c59d7ededcfe54a106b971cfe9d2ce8538b339bc68206aeeb241893369c62664d92f675c6717476e747740c4b69103e5f84ec32332efa717f139b
7
+ data.tar.gz: f6ec883e69585c5e5f2ac8bbea321b1e33f751a43f5d615c638066a9c330f98ba9a03ef29c624714eae619f3ac3e7472b33d6add7850e43a2c1dea6084035fd9
@@ -215,10 +215,10 @@ module Belt
215
215
 
216
216
  def fetch_ns_records(env_name)
217
217
  env_dir = "infrastructure/#{env_name}"
218
- env_config = load_env_config(env_name)
218
+ env_config = EnvironmentConfig.load(env_name)
219
219
 
220
220
  env = {}
221
- env['AWS_PROFILE'] = env_config[:aws_profile] if env_config[:aws_profile]
221
+ env['AWS_PROFILE'] = env_config.aws_profile if env_config.aws_profile?
222
222
 
223
223
  Dir.chdir(env_dir) do
224
224
  # Try terraform output first
@@ -245,13 +245,6 @@ module Belt
245
245
  end
246
246
  end
247
247
 
248
- def load_env_config(env_name)
249
- belt_rb = "infrastructure/#{env_name}/belt.rb"
250
- return {} unless File.exist?(belt_rb)
251
-
252
- EnvironmentConfig.load(belt_rb)
253
- end
254
-
255
248
  def update_tfvars(path, env_name, ns_records)
256
249
  content = File.read(path)
257
250
 
@@ -259,19 +252,23 @@ module Belt
259
252
  ns_list = ns_records.map { |ns| " \"#{ns}\"" }.join(",\n")
260
253
  new_entry = " #{env_name} = [\n#{ns_list}\n ]"
261
254
 
262
- # Check if environment_zones already has entries
263
- if content =~ /environment_zones\s*=\s*\{([^}]*)\}/m
255
+ # Match the actual HCL block, not commented examples.
256
+ # Look for environment_zones = { at the start of a line (not preceded by #)
257
+ hcl_block_pattern = /^environment_zones\s*=\s*\{([^}]*)\}/m
258
+
259
+ if content =~ hcl_block_pattern
264
260
  existing = ::Regexp.last_match(1).strip
265
261
 
266
262
  if existing.empty?
267
263
  # Empty block - replace with our entry
268
- content.sub!(/environment_zones\s*=\s*\{\s*\}/, "environment_zones = {\n#{new_entry}\n}")
264
+ content.sub!(/^environment_zones\s*=\s*\{\s*\}/m, "environment_zones = {\n#{new_entry}\n}")
269
265
  elsif existing.include?("#{env_name} =")
270
266
  # Environment already exists - update it
271
- content.sub!(/#{env_name}\s*=\s*\[[^\]]*\]/m, "#{env_name} = [\n#{ns_list}\n ]")
267
+ # Match env name at start of line (with optional leading whitespace) to avoid comment matches
268
+ content.sub!(/^(\s*)#{env_name}\s*=\s*\[[^\]]*\]/m, "\\1#{env_name} = [\n#{ns_list}\n ]")
272
269
  else
273
- # Add to existing entries
274
- content.sub!(/environment_zones\s*=\s*\{/m, "environment_zones = {\n#{new_entry}")
270
+ # Add to existing entries (insert after opening brace)
271
+ content.sub!(/^environment_zones\s*=\s*\{/m, "environment_zones = {\n#{new_entry}")
275
272
  end
276
273
  end
277
274
 
data/lib/belt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Belt
4
- VERSION = '0.3.19'
4
+ VERSION = '0.3.21'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: belt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.19
4
+ version: 0.3.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stowzilla