config_o_mat 0.5.0.beta0 → 0.5.0.beta1

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: f62a5fad3fe328d90a14019d838f16de18fe9398a380c02d9f49882c90bcb4e3
4
- data.tar.gz: 1f2d4bcfacefe5481d965bf4898e8c53f980c4ffbaab84bc3d51fb9a513ac7e0
3
+ metadata.gz: bb9ec5b07f001551fee80b15ba613646a295d35a1aa0d341e1cdd7924f014b17
4
+ data.tar.gz: 60a37f95f84bb1d0c29de65cbe43110a7dd4e1eab1f41b7c1952268a200d0776
5
5
  SHA512:
6
- metadata.gz: 15243ce8aff37e6218459cf7f629394200eb309b649edc99ce260d44ecb11150be97dad200a0d78a20b599f3af3bd9b38cd06d467400aaa8b8dfee3cce0fbd09
7
- data.tar.gz: 62ba31b15aabb2a19ba22354d7837be93f17d9455564da40da878fb9949a6fe1eabfbf9db27baed5ecfb23bb49a7421717311d6d182135914dc9830fd7b7fca5
6
+ metadata.gz: 14de2abaa1de0b6d6fb5b8301fb628f7c7315d7ac8ed302a5392115a754ba24c9b263784e2862ea3abafb0850b3f4b1626f2a74fe0b5bc97b9a461ac73c7bdfc
7
+ data.tar.gz: 483f4cfd52cd9d0e835490249602abb87167ae65bb07aa29113b33cce4d679e2e1a1364e2916a1c84784d32749be6fba7631c26d0254a94720bf6efe36242024
data/CHANGELOG.md CHANGED
@@ -1,8 +1,8 @@
1
- ## 0.5.0.beta0
1
+ ## 0.5.0.beta1
2
2
 
3
3
  NEW FEATURES:
4
4
 
5
- * Profiles can now specify an s3_fallback hash with bucket: and object:. If AWS AppConfig is unreachable, we will fall back to loading the specified S3 object and interpreting it as a response from AWS AppConfig. For best results enable versioning on the bucket.
5
+ * Profiles can now specify an s3_fallback key. If AWS AppConfig is unreachable, we will fall back to loading the specified S3 object from the top level configured fallback_s3_bucket and interpreting it as a response from AWS AppConfig. For best results enable versioning on the bucket. It is an error to specify an s3_fallback key if the configuration does not have a top level fallback_s3_bucket.
6
6
  * AppConfig responses can request that the s3_fallback be used by setting a top level "aws:chaos_config" key to true. This allows for deployments which AppConfig deployments which can test the fallback mechanism. If a chaos config load fails, the source AppConfig profile will remain in use. Chaos config is ignored in error recovery scenarios.
7
7
 
8
8
  BUG FIXES:
@@ -26,7 +26,8 @@ module ConfigOMat
26
26
  :generated_templates, :services_to_reload, :profiles_to_apply,
27
27
  :last_refresh_time, :next_state, :retry_count, :retries_left, :retry_wait,
28
28
  :region, :appconfig_client, :secretsmanager_client, :s3_client,
29
- :systemd_interface, :secrets_loader_memory, :gc_compact, :gc_stat
29
+ :systemd_interface, :secrets_loader_memory, :gc_compact, :gc_stat,
30
+ :fallback_s3_bucket
30
31
 
31
32
  def initialize(
32
33
  argv: [],
@@ -61,7 +62,8 @@ module ConfigOMat
61
62
  systemd_interface: nil,
62
63
  secrets_loader_memory: nil,
63
64
  gc_compact: 0,
64
- gc_stat: 0
65
+ gc_stat: 0,
66
+ fallback_s3_bucket: nil
65
67
  )
66
68
  super()
67
69
 
@@ -98,6 +100,7 @@ module ConfigOMat
98
100
  @secrets_loader_memory = secrets_loader_memory
99
101
  @gc_compact = gc_compact
100
102
  @gc_stat = gc_stat
103
+ @fallback_s3_bucket = fallback_s3_bucket
101
104
  end
102
105
  end
103
106
  end
@@ -22,7 +22,7 @@ module ConfigOMat
22
22
  module Op
23
23
  class RefreshAllProfiles < LifecycleVM::OpBase
24
24
  reads :profile_defs, :applied_profiles, :client_id, :appconfig_client, :secrets_loader_memory,
25
- :secretsmanager_client, :s3_client
25
+ :secretsmanager_client, :s3_client, :fallback_s3_bucket
26
26
  writes :profiles_to_apply, :last_refresh_time, :secrets_loader_memory
27
27
 
28
28
  def call
@@ -57,13 +57,12 @@ module ConfigOMat
57
57
  end
58
58
 
59
59
  def request_from_s3(profile_name, definition, ignore_errors)
60
- fallback = definition.s3_fallback
61
60
  begin
62
- s3_response = s3_client.get_object(bucket: fallback[:bucket], key: fallback[:object])
61
+ s3_response = s3_client.get_object(bucket: fallback_s3_bucket, key: definition.s3_fallback)
63
62
  OpenStruct.new(
64
63
  content: s3_response.body,
65
64
  content_type: s3_response.content_type,
66
- configuration_version: s3_response.version_id
65
+ configuration_version: s3_response.version_id || s3_response.etag
67
66
  )
68
67
  rescue StandardError => e
69
68
  logger&.error(:s3_fallback_load_failed, name: profile_name, reason: e)
@@ -20,7 +20,7 @@ module ConfigOMat
20
20
  module Op
21
21
  class RefreshProfile < LifecycleVM::OpBase
22
22
  reads :profile_defs, :client_id, :applying_profile, :appconfig_client, :secretsmanager_client,
23
- :secrets_loader_memory, :s3_client
23
+ :secrets_loader_memory, :s3_client, :fallback_s3_bucket
24
24
  writes :applying_profile, :secrets_loader_memory
25
25
 
26
26
  def call
@@ -56,13 +56,12 @@ module ConfigOMat
56
56
  end
57
57
 
58
58
  def request_from_s3(profile_name, definition)
59
- fallback = definition.s3_fallback
60
59
  begin
61
- s3_response = s3_client.get_object(bucket: fallback[:bucket], key: fallback[:object])
60
+ s3_response = s3_client.get_object(bucket: fallback_s3_bucket, key: definition.s3_fallback)
62
61
  OpenStruct.new(
63
62
  content: s3_response.body,
64
63
  content_type: s3_response.content_type,
65
- configuration_version: s3_response.version_id
64
+ configuration_version: s3_response.version_id || s3_response.etag
66
65
  )
67
66
  rescue StandardError => e
68
67
  error profile_name, e
@@ -23,7 +23,8 @@ module ConfigOMat
23
23
  :systemd_directory, :logs_directory, :profile_defs,
24
24
  :template_defs, :service_defs, :dependencies, :refresh_interval,
25
25
  :client_id, :retry_count, :retries_left, :retry_wait,
26
- :region, :systemd_interface, :gc_stat, :gc_compact
26
+ :region, :systemd_interface, :gc_stat, :gc_compact,
27
+ :fallback_s3_bucket
27
28
 
28
29
  def initialize(
29
30
  argv: [],
@@ -46,7 +47,8 @@ module ConfigOMat
46
47
  region: nil,
47
48
  systemd_interface: nil,
48
49
  gc_stat: 0,
49
- gc_copmact: 0
50
+ gc_copmact: 0,
51
+ fallback_s3_bucket: nil
50
52
  )
51
53
  super()
52
54
 
@@ -71,6 +73,7 @@ module ConfigOMat
71
73
  @systemd_interface = systemd_interface
72
74
  @gc_stat = gc_stat
73
75
  @gc_compact = gc_compact
76
+ @fallback_s3_bucket = fallback_s3_bucket
74
77
  end
75
78
  end
76
79
  end
@@ -63,7 +63,8 @@ module ConfigOMat
63
63
  reads :configuration_directory, :logs_directory, :env
64
64
  writes :profile_defs, :template_defs, :service_defs, :dependencies,
65
65
  :refresh_interval, :client_id, :logger, :retry_count, :retries_left,
66
- :retry_wait, :region, :systemd_interface, :gc_stat, :gc_compact
66
+ :retry_wait, :region, :systemd_interface, :gc_stat, :gc_compact,
67
+ :fallback_s3_bucket
67
68
 
68
69
  def call
69
70
  default_config = {
@@ -127,6 +128,11 @@ module ConfigOMat
127
128
  self.service_defs = instantiate.call(:services, Service)
128
129
  self.template_defs = instantiate.call(:templates, Template)
129
130
  self.profile_defs = instantiate.call(:profiles, Profile)
131
+ self.fallback_s3_bucket = merged_config[:fallback_s3_bucket]
132
+
133
+ if profile_defs.values.any? { |pd| pd.s3_fallback } && (fallback_s3_bucket.nil? || fallback_s3_bucket.empty?)
134
+ error :fallback_s3_bucket, 'must be present to use s3_fallback on profiles'
135
+ end
130
136
 
131
137
  facter = merged_config[:facter]
132
138
  if facter
@@ -178,13 +178,10 @@ module ConfigOMat
178
178
  error :environment, 'must be present' if @environment.nil? || @environment.empty?
179
179
  error :profile, 'must be present' if @profile.nil? || @profile.empty?
180
180
  if !@s3_fallback.nil?
181
- if !@s3_fallback.kind_of?(Hash)
182
- error :s3_fallback, 'must be a hash'
181
+ if @s3_fallback.kind_of?(String)
182
+ error :s3_fallback, 'must be non-empty' if @s3_fallback.empty?
183
183
  else
184
- bucket = @s3_fallback[:bucket]
185
- object = @s3_fallback[:object]
186
- error :s3_fallback, 'must include bucket' if bucket.nil? || bucket.empty?
187
- error :s3_fallback, 'must include object' if object.nil? || object.empty?
184
+ error :s3_fallback, 'must be a string'
188
185
  end
189
186
  end
190
187
  end
@@ -15,5 +15,5 @@
15
15
  # limitations under the License.
16
16
 
17
17
  module ConfigOMat
18
- VERSION = "0.5.0.beta0"
18
+ VERSION = "0.5.0.beta1"
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config_o_mat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0.beta0
4
+ version: 0.5.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Scarborough