chambermaid 0.5.4 → 0.5.5

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: f6d34e355553e694cc493b9fbae6200d0d508d4ada00f4e5f6b934a0582996a2
4
- data.tar.gz: a02864caeeeddf4237aa412a2d8b53ffb626f301e7cd1d037287ae75d37d7c83
3
+ metadata.gz: bac5b5a18928996ec0eff656de94105639482b427795b54cddf825232ff83667
4
+ data.tar.gz: 4382e36051f155568e2a77a84a79bdb39d55eb0f9e640941aa6d0b85c1071661
5
5
  SHA512:
6
- metadata.gz: 2777ce46568aeebb40defa53d0a3acaf64b8e5812ffc7b4381b19bf2318255990be65d28d8cd628664bdb4fc15e5c87bdaec924b3a01329e9acbb3567f0cd14b
7
- data.tar.gz: b8e8ed1343b17c9d7db2c05f9569fff8eae5b958e9744f8561e315369727d3692baea182815e52072c03f6591d4d8260cc819c62c5df8795551722f06dad3549
6
+ metadata.gz: e28ac0a2b70366e8f60b882ff2e6e62b5261f6d7056f0f95e4ffd2a4c15ba9431ba8ae3610cd7be6faa040207c6edf3a3a9e0ef11d99359c1f597b25250d19bd
7
+ data.tar.gz: 80f638eb0c1c445c73e37dda7e9c67c08c3009d012cb28ed8e203f5063675b79cac9cd60dc01847630eaa2ddc3c7c160be0bb9a999b5bf15d373530b1312dc25
@@ -1,3 +1,9 @@
1
+ ## [0.5.4](https://github.com/mileszim/chambermaid/compare/v0.5.3...v0.5.4) (2020-08-03)
2
+
3
+ ### Bug Fixes
4
+
5
+ - **release:** chmod 0600 ~/.gem/credentials after generating ([ed85d5b](https://github.com/mileszim/chambermaid/commit/ed85d5b1d9b76762bcc50734c806a6e1cd224ad5))
6
+
1
7
  ## [0.5.3](https://github.com/mileszim/chambermaid/compare/v0.5.2...v0.5.3) (2020-08-03)
2
8
 
3
9
  ### Bug Fixes
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chambermaid (0.5.4)
4
+ chambermaid (0.5.5)
5
5
  aws-sdk-ssm (~> 1.85)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -4,6 +4,8 @@ Companion RubyGem for [chamber](https://github.com/segmentio/chamber).
4
4
 
5
5
  Chambermaid injects AWS SSM params into your ENV. Plays nice with other ENV gems like dotenv.
6
6
 
7
+ - [RubyDocs](https://rubydoc.info/gems/chambermaid)
8
+
7
9
  ## Installation
8
10
 
9
11
  Add this line to your application's Gemfile:
@@ -16,6 +16,8 @@ Gem::Specification.new do |spec|
16
16
  spec.metadata["homepage_uri"] = spec.homepage
17
17
  spec.metadata["source_code_uri"] = "https://github.com/mileszim/chambermaid"
18
18
  spec.metadata["changelog_uri"] = "https://github.com/mileszim/chambermaid/blob/master/CHANGELOG.md"
19
+ spec.metadata["documentation_uri"] = "https://rubydoc.info/gems/chambermaid"
20
+ spec.metadata["bug_tracker_uri"] = "https://github.com/mileszim/chambermaid/issues"
19
21
 
20
22
  # Specify which files should be added to the gem when it is released.
21
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -1,4 +1,9 @@
1
1
  module Chambermaid
2
+ # Environment keeps a set of params available to load into ENV. It also
3
+ # maintains a copy of ENV at the time of its initialization, in order to
4
+ # restore it.
5
+ #
6
+ # @attr_reader [Hash] params
2
7
  class Environment < Hash
3
8
  attr_reader :params
4
9
 
@@ -35,16 +40,22 @@ module Chambermaid
35
40
  end
36
41
 
37
42
  # Inject into ENV without overwriting duplicates
43
+ #
44
+ # @return [Hash]
38
45
  def load!
39
46
  each { |k, v| ENV[k] ||= v }
40
47
  end
41
48
 
42
49
  # Inject into ENV and overwrite duplicates
50
+ #
51
+ # @return [Hash]
43
52
  def overload!
44
53
  each { |k, v| ENV[k] = v }
45
54
  end
46
55
 
47
56
  # Restore to original ENV
57
+ #
58
+ # @return [ENV]
48
59
  def unload!
49
60
  ENV.replace(@_original_env)
50
61
  end
@@ -1,4 +1,6 @@
1
1
  module Chambermaid
2
+ # Namespaces each contain a ParameterStore and Environment instance,
3
+ # along with the overload flag
2
4
  class Namespace
3
5
  # @param [String] path
4
6
  # @param [Boolean] overload
@@ -10,23 +12,45 @@ module Chambermaid
10
12
  @env = Environment.new({})
11
13
  end
12
14
 
15
+ # Create a namespace and immediately fetch and inject params to ENV
16
+ #
17
+ # @see Chambermaid::Namespace.load!
18
+ #
19
+ # @param [String] path
20
+ # @param [Boolean] overload
21
+ #
22
+ # @return [Chambermaid::Namespace]
13
23
  def self.load!(path:, overload: false)
14
24
  namespace = new(path: path, overload: overload)
15
25
  namespace.load!
16
26
  namespace
17
27
  end
18
28
 
29
+ # Load ParameterStore and inject into ENV
30
+ #
31
+ # @see Chambermaid::ParameterStore#load!
32
+ # @see Chambermaid::Environment#load!
33
+ # @see Chambermaid::Environment#overload!
19
34
  def load!
20
35
  @store.load!
21
36
  load_env!
22
37
  end
23
38
 
39
+ # Unload params from ENV, reload ParameterStore, and inject into ENV
40
+ #
41
+ # @see Chambermaid::Environment#unload!
42
+ # @see Chambermaid::ParameterStore#reload!
43
+ # @see Chambermaid::Environment#load!
44
+ # @see Chambermaid::Environment#overload!
24
45
  def reload!
25
46
  @env.unload!
26
47
  @store.reload!
27
48
  load_env!
28
49
  end
29
50
 
51
+ # Unload params from ENV
52
+ #
53
+ # @see Chambermaid::Environment#unload!
30
54
  def unload!
31
55
  @env.unload!
32
56
  Chambermaid.logger.info("unloaded #{@env.size} params from ENV")
@@ -1,30 +1,52 @@
1
1
  require "aws-sdk-ssm"
2
2
 
3
3
  module Chambermaid
4
+ # ParameterStore instances fetch all parameters under a namespace/path
5
+ # from AWS SSM
6
+ #
7
+ # @note AWS authentication requires configuration via ENV (IAM credentials/STS)
4
8
  class ParameterStore
9
+ # @param [String] path
5
10
  def initialize(path:)
6
11
  @path = path
7
12
  end
8
13
 
14
+ # Fetch and decrypt all parameters selected by a namespace/path string
15
+ #
16
+ # @return [Boolean]
9
17
  def load!
10
18
  fetch_ssm_params!
11
19
  end
12
20
 
21
+ # Clear cached parameters and re-fetch parameters from AWS SSM
22
+ #
23
+ # @return [Boolean]
13
24
  def reload!
14
25
  clear_params!
15
26
  fetch_ssm_params!
16
27
  end
17
28
 
29
+ # Returns true if parameters have been fetched from AWS SSM
30
+ #
31
+ # @return [Boolean]
18
32
  def loaded?
19
33
  !@params_list.empty?
20
34
  end
21
35
 
36
+ # Create a ParameterStore and fetch from AWS SSM immediately
37
+ #
38
+ # @see Chambermaid::ParameterStore#load!
39
+ #
40
+ # @return [Chambermaid::ParameterStore]
22
41
  def self.load!(path:)
23
42
  store = new(path: path)
24
43
  store.load!
25
44
  store
26
45
  end
27
46
 
47
+ # ENV formatted Hash of parameters loaded from AWS SSM
48
+ #
49
+ # @return [Hash]
28
50
  def params
29
51
  @params ||= @param_list.map { |p|
30
52
  [p.name.split("/").last.upcase, p.value]
@@ -1,3 +1,3 @@
1
1
  module Chambermaid
2
- VERSION = "0.5.4"
2
+ VERSION = "0.5.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chambermaid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Zimmerman
@@ -88,6 +88,8 @@ metadata:
88
88
  homepage_uri: https://github.com/mileszim/chambermaid
89
89
  source_code_uri: https://github.com/mileszim/chambermaid
90
90
  changelog_uri: https://github.com/mileszim/chambermaid/blob/master/CHANGELOG.md
91
+ documentation_uri: https://rubydoc.info/gems/chambermaid
92
+ bug_tracker_uri: https://github.com/mileszim/chambermaid/issues
91
93
  post_install_message:
92
94
  rdoc_options: []
93
95
  require_paths: