chambermaid 0.3.0 → 0.5.4

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: ed3bfd126164a3fd94e16ccdf453af29f9091f9139074bb80b922fd237db3453
4
- data.tar.gz: d609e14f50b7b085a38dfbcc4379920015d2b184e11fa0dbf2c26e294a238990
3
+ metadata.gz: f6d34e355553e694cc493b9fbae6200d0d508d4ada00f4e5f6b934a0582996a2
4
+ data.tar.gz: a02864caeeeddf4237aa412a2d8b53ffb626f301e7cd1d037287ae75d37d7c83
5
5
  SHA512:
6
- metadata.gz: 567267cf7ea6992aa545ad5e745eb6f6c5653366526bfee94873894a31d8c235bd2ebc1ed3c54d79fc362b46093a0fa004c4e79ee77dbfcfd9b371cc36439875
7
- data.tar.gz: d65da6cc45e6fbfc6c53e09a3de5a55a89a9d707385944c8868db6a50de6b7b83d30b235ff2084e50dff27daab9a1d668b2d4c1bb4789640031425b1b33f0918
6
+ metadata.gz: 2777ce46568aeebb40defa53d0a3acaf64b8e5812ffc7b4381b19bf2318255990be65d28d8cd628664bdb4fc15e5c87bdaec924b3a01329e9acbb3567f0cd14b
7
+ data.tar.gz: b8e8ed1343b17c9d7db2c05f9569fff8eae5b958e9744f8561e315369727d3692baea182815e52072c03f6591d4d8260cc819c62c5df8795551722f06dad3549
@@ -0,0 +1,16 @@
1
+ name: commitlint
2
+ on:
3
+ - pull_request
4
+
5
+ jobs:
6
+ lint:
7
+ runs-on: ubuntu-latest
8
+ env:
9
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ with:
13
+ fetch-depth: 0
14
+ - uses: wagoid/commitlint-github-action@v1
15
+ with:
16
+ failOnWarnings: true
@@ -0,0 +1,46 @@
1
+ name: release
2
+ on:
3
+ push:
4
+ branches:
5
+ - master
6
+
7
+ jobs:
8
+ create-release:
9
+ runs-on: ubuntu-latest
10
+ env:
11
+ GITHUB_TOKEN: ${{ secrets.GHUB_PAT }}
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ with:
15
+ fetch-depth: 0
16
+ - uses: ridedott/release-me-action@master
17
+ id: get-version-number
18
+ with:
19
+ dry-run: true
20
+ - uses: actions/setup-ruby@v1
21
+ with:
22
+ ruby-version: "2.6"
23
+ - run: gem install bundler -v 2.1.2
24
+ - name: Set version.rb and Gemfile.lock
25
+ run: |
26
+ printf "module Chambermaid\n VERSION = \"$NEW_VERSION\"\nend" > lib/chambermaid/version.rb
27
+ bundle install
28
+ env:
29
+ NEW_VERSION: ${{ steps.get-version-number.outputs.version }}
30
+ - run: bundle exec rake build
31
+ - uses: ridedott/release-me-action@master
32
+ with:
33
+ commit-assets: |
34
+ ./lib/chambermaid/version.rb
35
+ ./Gemfile.lock
36
+ release-assets: |
37
+ ./pkg/*.gem
38
+ - name: publish to rubygems
39
+ run: |
40
+ mkdir -p ~/.gem
41
+ printf -- "---\n:rubygems_api_key: $GEM_HOST_API_KEY" > ~/.gem/credentials
42
+ chmod 0600 ~/.gem/credentials
43
+ gem push pkg/chambermaid-$NEW_VERSION.gem
44
+ env:
45
+ GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
46
+ NEW_VERSION: ${{ steps.get-version-number.outputs.version }}
@@ -0,0 +1,23 @@
1
+ ## [0.5.3](https://github.com/mileszim/chambermaid/compare/v0.5.2...v0.5.3) (2020-08-03)
2
+
3
+ ### Bug Fixes
4
+
5
+ - **release:** use bash end of args with printf ([fbc0ae2](https://github.com/mileszim/chambermaid/commit/fbc0ae28961c40f984e6685e5feb33799934f510))
6
+
7
+ ## [0.5.2](https://github.com/mileszim/chambermaid/compare/v0.5.1...v0.5.2) (2020-08-03)
8
+
9
+ ### Bug Fixes
10
+
11
+ - **release:** set rubygem api key into ~/.gem/credentials ([7faef58](https://github.com/mileszim/chambermaid/commit/7faef587631284c3bb89c22572b8bce9c31172d0))
12
+
13
+ ## [0.5.1](https://github.com/mileszim/chambermaid/compare/v0.5.0...v0.5.1) (2020-08-03)
14
+
15
+ ### Bug Fixes
16
+
17
+ - **release:** publish to rubygems on successful release ([e019c7d](https://github.com/mileszim/chambermaid/commit/e019c7df3f43c251a5542374cc9c869fc4b00d92))
18
+
19
+ # [0.5.0](https://github.com/mileszim/chambermaid/compare/v0.4.1...v0.5.0) (2020-08-03)
20
+
21
+ ### Features
22
+
23
+ - add commitlint and release workflow (#2) ([1159e69](https://github.com/mileszim/chambermaid/commit/1159e69e95701e4763fdbe08430d579c2a2a8440)), closes [#2](https://github.com/mileszim/chambermaid/issues/2)
data/Gemfile CHANGED
@@ -2,6 +2,3 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in chambermaid.gemspec
4
4
  gemspec
5
-
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chambermaid (0.3.0)
4
+ chambermaid (0.5.4)
5
5
  aws-sdk-ssm (~> 1.85)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  aws-eventstream (1.1.0)
11
- aws-partitions (1.348.0)
11
+ aws-partitions (1.349.0)
12
12
  aws-sdk-core (3.104.3)
13
13
  aws-eventstream (~> 1, >= 1.0.2)
14
14
  aws-partitions (~> 1, >= 1.239.0)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Chambermaid
1
+ # Chambermaid [![Gem Version](https://badge.fury.io/rb/chambermaid.svg)](https://badge.fury.io/rb/chambermaid) [![Build Status](https://travis-ci.com/mileszim/chambermaid.svg?branch=master)](https://travis-ci.com/mileszim/chambermaid)
2
2
 
3
3
  Companion RubyGem for [chamber](https://github.com/segmentio/chamber).
4
4
 
@@ -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.
@@ -28,4 +28,6 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  # Gems
30
30
  spec.add_dependency("aws-sdk-ssm", "~> 1.85")
31
+ spec.add_development_dependency("rspec", "~> 3.0")
32
+ spec.add_development_dependency("rake", "~> 12.0")
31
33
  end
@@ -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.after_initialize 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.0"
3
- end
2
+ VERSION = "0.5.4"
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chambermaid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Zimmerman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-02 00:00:00.000000000 Z
11
+ date: 2020-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-ssm
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.85'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.0'
27
55
  description:
28
56
  email:
29
57
  - miles@asktrim.com
@@ -31,9 +59,12 @@ executables: []
31
59
  extensions: []
32
60
  extra_rdoc_files: []
33
61
  files:
62
+ - ".github/workflows/commitlint.yml"
63
+ - ".github/workflows/release.yml"
34
64
  - ".gitignore"
35
65
  - ".rspec"
36
66
  - ".travis.yml"
67
+ - CHANGELOG.md
37
68
  - CODE_OF_CONDUCT.md
38
69
  - Gemfile
39
70
  - Gemfile.lock
@@ -48,6 +79,7 @@ files:
48
79
  - lib/chambermaid/environment.rb
49
80
  - lib/chambermaid/namespace.rb
50
81
  - lib/chambermaid/parameter_store.rb
82
+ - lib/chambermaid/railtie.rb
51
83
  - lib/chambermaid/version.rb
52
84
  homepage: https://github.com/mileszim/chambermaid
53
85
  licenses:
@@ -71,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
103
  - !ruby/object:Gem::Version
72
104
  version: '0'
73
105
  requirements: []
74
- rubygems_version: 3.1.2
106
+ rubygems_version: 3.0.3
75
107
  signing_key:
76
108
  specification_version: 4
77
109
  summary: Companion Ruby Gem for chamber cli