chambermaid 0.3.2 → 0.4.0

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: fbcb610044b8dd8ff4487cb6729889f18dde9a32bd09b25620b53b6c6336a9e9
4
- data.tar.gz: 80abde8476c848335de1f9557f49557322a1463f36419fe8c986a53ee18cb816
3
+ metadata.gz: 7205cca8ffd4e9f7b2e20eb02239fd42be4f9dcdbd7c85eafb2e74c000d39be6
4
+ data.tar.gz: a1b394c7dd79578e738defb6657276aa6988185d432153f900dab3b2bfeda97d
5
5
  SHA512:
6
- metadata.gz: beb4b9d61c45e48bd48497e2cf27fec7cd5055447aac237324b298ba343b3d4bed49a46151aff364a90049ac31ae78b2c9dcf51b42cfa3cf000c3adde06a9552
7
- data.tar.gz: 4228d741b603f187e69d3c900efae0241808eccabd4e3227b745cfd4e75e9c570949071c5d46c079d3ecd34992704c0390cea0f6b174c8560c2ce8ba3fe361f9
6
+ metadata.gz: 4ef58ed041bd944a89d06a72c4b4f71dfe7695ef86aa4c2a28edf6d32d6a8b46122c1bfe7b1f6461cf9199dfbe73cfcf9fadd7ee101b54f0e86be5d36cd76c9d
7
+ data.tar.gz: 9cb1b2f1781b2903a9af7121e7720a8c2f875a28472f8d0ded8b455560262917f2fec5e0cb8584886257de8141fabc90ca7d244d86435004b9c1377a121d4ee2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chambermaid (0.3.2)
4
+ chambermaid (0.4.0)
5
5
  aws-sdk-ssm (~> 1.85)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -35,13 +35,19 @@ Chambermaid.add_service("my-chamber-service")
35
35
  # config/initializers/chambermaid.rb
36
36
 
37
37
  Chambermaid.configure do |config|
38
+ # Load all values from SSM Namespace path
38
39
  config.add_namespace("/my/param/namespace")
40
+
41
+ # Load values from chamber-cli service
39
42
  config.add_service("my-chamber-service")
40
43
 
41
44
  # Set `overload: true` to choose these params over existing
42
45
  # ones in ENV when they are merged together
43
46
  config.add_namespace("/my/important/namespace", overload: true)
44
47
  end
48
+
49
+ # Load after configuration
50
+ Chambermaid.load!
45
51
  ```
46
52
 
47
53
  **Reload SSM into ENV**
@@ -55,6 +61,24 @@ Chambermaid.restore!
55
61
  Chambermaid.reset! # alias of .restore!
56
62
  ```
57
63
 
64
+ **Configure Logging**
65
+ ```ruby
66
+ Chambermaid.configure do |config|
67
+ # ... other config ...
68
+
69
+ # Change log level
70
+ config.log_level = :debug
71
+
72
+ # Set custom logger instance
73
+ config.logger = MyCoolLogger.new
74
+ end
75
+
76
+ # Outside of config block
77
+ Chambermaid.log_level = :warn
78
+ ```
79
+
80
+ _Note: Chambermaid.logger is set to Rails.logger automatically if including inside a rails app_
81
+
58
82
  ## Development
59
83
 
60
84
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,5 +1,6 @@
1
1
  require "chambermaid/base"
2
2
  require "chambermaid/version"
3
+ require "chambermaid/railtie" if defined?(Rails)
3
4
 
4
5
  module Chambermaid
5
6
  class Error < StandardError; end
@@ -1,3 +1,5 @@
1
+ require "logger"
2
+
1
3
  require "chambermaid/environment"
2
4
  require "chambermaid/namespace"
3
5
  require "chambermaid/parameter_store"
@@ -13,7 +15,6 @@ module Chambermaid
13
15
 
14
16
  def configure
15
17
  yield self
16
- load!
17
18
  end
18
19
 
19
20
  # @todo
@@ -104,6 +105,39 @@ module Chambermaid
104
105
  add_namespace(service)
105
106
  end
106
107
 
108
+ # !@attribute [r] logger
109
+ # @return [Logger]
110
+ def logger
111
+ @logger ||= Logger.new(STDOUT,
112
+ level: log_level,
113
+ progname: "Chambermaid"
114
+ )
115
+ end
116
+
117
+ # !@attribute [w] logger
118
+ # @return [Logger]
119
+ def logger=(val)
120
+ @logger = val
121
+ @logger.progname = "Chambermaid"
122
+ logger
123
+ end
124
+
125
+ # !@attribute [r] log_level
126
+ # @return [Symbol] (default = :info) current logger level
127
+ def log_level
128
+ return logger.level unless @logger.nil?
129
+ return @log_level unless @log_level.nil?
130
+ return :info
131
+ end
132
+
133
+ # !@attribute [w] log_level
134
+ # @return [Symbol] (default = :info) current logger level
135
+ def log_level=(val = :info)
136
+ @logger.level = val unless @logger.nil?
137
+ @log_level = val
138
+ val
139
+ end
140
+
107
141
  private
108
142
 
109
143
  def namespaces
@@ -29,6 +29,7 @@ module Chambermaid
29
29
 
30
30
  def unload!
31
31
  @env.unload!
32
+ Chambermaid.logger.info("unloaded #{@env.size} params from ENV")
32
33
  end
33
34
 
34
35
  private
@@ -37,6 +38,7 @@ module Chambermaid
37
38
  def load_env!
38
39
  @env.replace(@store.params)
39
40
  @overload ? @env.overload! : @env.load!
41
+ Chambermaid.logger.info("loaded #{@env.size} params into ENV from `#{@path}`")
40
42
  end
41
43
  end
42
44
  end
@@ -40,14 +40,20 @@ module Chambermaid
40
40
  end
41
41
 
42
42
  def fetch_ssm_params!
43
+ Chambermaid.logger.debug("fetching AWS SSM parameters from `#{@path}`")
43
44
  @param_list = []
44
45
  response = nil
45
46
  loop do
46
47
  response = fetch_ssm_param_batch!(response&.next_token)
47
48
  @param_list.concat(response.parameters)
48
49
 
49
- break unless response.next_token
50
+ if response.next_token
51
+ Chambermaid.logger.debug("response.next_token found, continuing fetch")
52
+ else
53
+ break
54
+ end
50
55
  end
56
+ Chambermaid.logger.debug("fetched #{@param_list.size} parameters from `#{@path}`")
51
57
  end
52
58
 
53
59
  def fetch_ssm_param_batch!(next_token = nil)
@@ -0,0 +1,8 @@
1
+ module Chambermaid
2
+ class Railtie < Rails::Railtie
3
+ config.before_configuration do
4
+ Chambermaid.logger = Rails.logger
5
+ Chambermaid.load!
6
+ end
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module Chambermaid
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
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.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Zimmerman
@@ -76,6 +76,7 @@ files:
76
76
  - lib/chambermaid/environment.rb
77
77
  - lib/chambermaid/namespace.rb
78
78
  - lib/chambermaid/parameter_store.rb
79
+ - lib/chambermaid/railtie.rb
79
80
  - lib/chambermaid/version.rb
80
81
  homepage: https://github.com/mileszim/chambermaid
81
82
  licenses: