aws-ssm-env 0.1.1 → 0.1.2

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: 42b51ae8562dfef400fdc2a244ac04ee333d76e836b80b1cd722ca3027bde2d4
4
- data.tar.gz: 351176835c06d118460bb5455a34cfdd3198771b161aca9c1d8e66aac0eb0368
3
+ metadata.gz: 7f70eabbd5d506e704fe7c7c3d22d60a998207596df66c22c205da2951d9eb92
4
+ data.tar.gz: 722a3d367daf0d4d4175e535dd16df23942aa2dede494950386ec2ea5e93ac70
5
5
  SHA512:
6
- metadata.gz: 27a30b575fd1b1b1ca6b951df0bff61f61b549f59f8568039007d352ae61b65f5c204b88e43ef23f95cf9caff66d5437ac2fad8d3091a964b499747afc6b1615
7
- data.tar.gz: 7cab36b73fa5adeb5c2532695239777aa97be74128668b34ec8a48a57833f7b53dd19e7e68bd5518087fa1d4f9795685876d5f5a1170f6f15c915d3d84e8f74f
6
+ metadata.gz: 3dfa1d43c25d1dbf99a51f25c8e8042deb09d472e81ab3c8b32d2ac9210dadc99606a1d170a7d5d68332a5dc0c415307e509c39e5614a3a99aa6103b5c809184
7
+ data.tar.gz: 6ec4f594ba7e945b4831efa7b768d9c7a5939cd2e40c3a696e29064a758a232fb6d15e2cba7e94e590fd12a0decaf6abe95bd6137fc57fa74958154c16e67e9e
@@ -1,7 +1,12 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.1.2 (2020-12-02)
4
+
5
+ - Add ruby 2.7 to Travis CI test matrix #7
6
+ - Fix for early abort when next_token is not null #8
7
+ - drop ruby 2.4 support, and fix warnings #11
8
+
3
9
  ## 0.1.1 (2018-01-16)
4
10
 
5
11
  - Translate README.
6
12
  - Added ruby 2.5 tests.
7
-
data/README.md CHANGED
@@ -16,7 +16,7 @@ The naming of environment variables is optional and can be customized.
16
16
 
17
17
  ## Installation
18
18
 
19
- This gem has been tested with ruby version 2.2 to 2.5.
19
+ This gem has been tested with ruby version 2.5 to 2.7.
20
20
 
21
21
  ```
22
22
  gem install aws-ssm-env
@@ -13,7 +13,7 @@ AWS EC2 Parameter Storeから取得したパラメータを環境変数として
13
13
 
14
14
  ## Installation
15
15
 
16
- このgemはRuby2.2から2.5まででテストされています。
16
+ このgemはRuby2.5から2.7まででテストされています。
17
17
 
18
18
  ```
19
19
  gem install aws-ssm-env
@@ -149,12 +149,12 @@ module AwsSsmEnv
149
149
  #
150
150
  # @see AwsSsmEnv::Loader#load
151
151
  def load(**args)
152
- AwsSsmEnv::Loader.load(args)
152
+ AwsSsmEnv::Loader.load(**args)
153
153
  end
154
154
 
155
155
  # `overwrite`オプションを付与した AwsSsmEnv::Loader#load の委譲メソッド。
156
156
  # @see AwsSsmEnv::Loader#load
157
157
  def load!(**args)
158
- AwsSsmEnv::Loader.load(args.merge(overwrite: true))
158
+ AwsSsmEnv::Loader.load(**args.merge(overwrite: true))
159
159
  end
160
160
  end
@@ -23,8 +23,8 @@ module AwsSsmEnv
23
23
  #
24
24
  # @see http://docs.aws.amazon.com/sdk-for-ruby/v3/api/index.html
25
25
  def initialize(**args)
26
- @client = create_ssm_client(args)
27
- @with_decryption = with_decryption?(args)
26
+ @client = create_ssm_client(**args)
27
+ @with_decryption = with_decryption?(**args)
28
28
  end
29
29
 
30
30
  # Iteratorパターンを実装したメソッド。AwsSsmEnv#load から呼び出される。
@@ -36,9 +36,6 @@ module AwsSsmEnv
36
36
  loop do
37
37
  response = fetch(next_token)
38
38
  next_token = response.next_token
39
- if response.parameters.empty?
40
- break
41
- end
42
39
  response.parameters.each do |p|
43
40
  yield(p)
44
41
  end
@@ -16,7 +16,7 @@ module AwsSsmEnv
16
16
  # @option args [Integet] :fetch_size <optional> 一度のAPI実行で取得するパラメータ数。最大50。デフォルトは50。
17
17
  def initialize(**args)
18
18
  super
19
- @base_params = base_params(args)
19
+ @base_params = base_params(**args)
20
20
  end
21
21
 
22
22
  protected
@@ -19,11 +19,11 @@ module AwsSsmEnv
19
19
  fetch_type = args[:fetch]
20
20
  case fetch_type
21
21
  when nil
22
- default_fetcher(args)
22
+ default_fetcher(**args)
23
23
  when PATH_FETCHER
24
- create_path_fetcher(args)
24
+ create_path_fetcher(**args)
25
25
  when BEGINS_WITH_FETCHER
26
- create_begins_with_fetcher(args)
26
+ create_begins_with_fetcher(**args)
27
27
  else
28
28
  unless fetcher_instance?(fetch_type)
29
29
  raise ArgumentError, 'Possible values for :fetch are either :path, :begins_with, ' \
@@ -37,20 +37,20 @@ module AwsSsmEnv
37
37
 
38
38
  def default_fetcher(**args)
39
39
  if args.key?(:begins_with)
40
- create_begins_with_fetcher(args)
40
+ create_begins_with_fetcher(**args)
41
41
  else
42
- create_path_fetcher(args)
42
+ create_path_fetcher(**args)
43
43
  end
44
44
  end
45
45
 
46
46
  def create_path_fetcher(**args)
47
47
  require 'aws-ssm-env/fetchers/path'
48
- AwsSsmEnv::PathFetcher.new(args)
48
+ AwsSsmEnv::PathFetcher.new(**args)
49
49
  end
50
50
 
51
51
  def create_begins_with_fetcher(**args)
52
52
  require 'aws-ssm-env/fetchers/begins_with'
53
- AwsSsmEnv::BeginsWithFetcher.new(args)
53
+ AwsSsmEnv::BeginsWithFetcher.new(**args)
54
54
  end
55
55
 
56
56
  def fetcher_instance?(object)
@@ -18,7 +18,7 @@ module AwsSsmEnv
18
18
  # @option args [Integer] :fetch_size <optional> 一度のAPI実行で取得するパラメータ数。最大10。デフォルトは10。
19
19
  def initialize(**args)
20
20
  super
21
- @base_params = base_params(args)
21
+ @base_params = base_params(**args)
22
22
  end
23
23
 
24
24
  protected
@@ -10,11 +10,11 @@ module AwsSsmEnv
10
10
  class Loader
11
11
  # メイン処理。引数の詳細は AwsSsmEnv#load を参照。
12
12
  def self.load(**args)
13
- new(args).load
13
+ new(**args).load
14
14
  end
15
15
 
16
16
  def initialize(**args)
17
- parse_options(args)
17
+ parse_options(**args)
18
18
  if @logger
19
19
  @logger.debug("#{self.class.name} overwrite: #{@overwrite}")
20
20
  @logger.debug("#{self.class.name} fetcher: #{@fetcher}")
@@ -34,9 +34,9 @@ module AwsSsmEnv
34
34
 
35
35
  def parse_options(**options)
36
36
  @logger = options[:logger]
37
- @fetcher = AwsSsmEnv::FetcherFactory.create_fetcher(options)
38
- @naming_strategy = AwsSsmEnv::NamingStrategyFactory.create_naming_strategy(options)
39
- @overwrite = overwrite?(options)
37
+ @fetcher = AwsSsmEnv::FetcherFactory.create_fetcher(**options)
38
+ @naming_strategy = AwsSsmEnv::NamingStrategyFactory.create_naming_strategy(**options)
39
+ @overwrite = overwrite?(**options)
40
40
  if @overwrite
41
41
  @applier = :apply!
42
42
  else
@@ -18,13 +18,13 @@ module AwsSsmEnv
18
18
  def create_naming_strategy(**args)
19
19
  naming_strategy = args[:naming]
20
20
  if naming_strategy.nil?
21
- return default_strategy(args)
21
+ return default_strategy(**args)
22
22
  end
23
23
  case naming_strategy
24
24
  when BASENAME_STRATEGY
25
- create_basename_strategy(args)
25
+ create_basename_strategy(**args)
26
26
  when SNAKE_CASE_STRATEGY
27
- create_snakecase_strategy(args)
27
+ create_snakecase_strategy(**args)
28
28
  else
29
29
  unknown_naming_strategy(naming_strategy)
30
30
  end
@@ -33,17 +33,17 @@ module AwsSsmEnv
33
33
  private
34
34
 
35
35
  def default_strategy(**args)
36
- create_basename_strategy(args)
36
+ create_basename_strategy(**args)
37
37
  end
38
38
 
39
39
  def create_basename_strategy(**args)
40
40
  require 'aws-ssm-env/naming_strategies/basename'
41
- AwsSsmEnv::BasenameNamingStrategy.new(args)
41
+ AwsSsmEnv::BasenameNamingStrategy.new(**args)
42
42
  end
43
43
 
44
44
  def create_snakecase_strategy(**args)
45
45
  require 'aws-ssm-env/naming_strategies/snakecase'
46
- AwsSsmEnv::SnakeCaseNamingStrategy.new(args)
46
+ AwsSsmEnv::SnakeCaseNamingStrategy.new(**args)
47
47
  end
48
48
 
49
49
  def unknown_naming_strategy(naming_strategy)
@@ -18,8 +18,8 @@ module AwsSsmEnv
18
18
  # アンダースコアに変換する区切り文字。デフォルトはスラッシュ('/')。 TODO: AwsSsmEnv#loadとREADMEに反映
19
19
  def initialize(**args)
20
20
  @logger = args[:logger]
21
- @delimiter = detect_delimiter(args)
22
- removed_prefix = detect_prefix(args).sub(%r{/\z}, '')
21
+ @delimiter = detect_delimiter(**args)
22
+ removed_prefix = detect_prefix(**args).sub(%r{/\z}, '')
23
23
  @removed_prefix = /\A#{Regexp.escape(removed_prefix)}/
24
24
  @logger.debug("#{self.class.name} removed_prefix is #{@removed_prefix}") if @logger
25
25
  end
@@ -1,3 +1,3 @@
1
1
  module AwsSsmEnv
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe AwsSsmEnv::Fetcher do
4
- let(:fetcher) { described_class.new(args) }
4
+ let(:fetcher) { described_class.new(**args) }
5
5
  let(:args) { {} }
6
6
  let(:client) { fetcher.send(:client) }
7
7
  let(:ssm_client_args) {
@@ -86,58 +86,55 @@ describe AwsSsmEnv::Fetcher do
86
86
  let(:parameters) { [ Parameter.new('foo', 'foo'), Parameter.new('bar', 'bar') ] }
87
87
  let(:fetcher) {
88
88
  mock_class = Class.new(described_class) do
89
- def initialize(response); @response = response; end
90
- protected def fetch(_); @response; end
89
+ def initialize(responses); @responses = responses; end
90
+ protected def fetch(_); @responses.shift; end
91
91
  end
92
- mock_class.new(dummy_response)
92
+ mock_class.new(responses)
93
93
  }
94
94
 
95
+ def call_count
96
+ called = 0
97
+ fetcher.each do |_|
98
+ called += 1
99
+ end
100
+ called
101
+ end
102
+
95
103
  context 'when fetch returns empty parameters at first' do
96
- let(:dummy_response) { AwsSsmEnv::FetchResult::EMPTY }
104
+ let(:responses) { [AwsSsmEnv::FetchResult::EMPTY] }
97
105
 
98
106
  it 'consumer is not called' do
99
- called = false
100
- fetcher.each do |_|
101
- called = true
102
- end
103
- expect(called).to be_falsey
107
+ expect(call_count).to eq(0)
108
+ end
109
+ end
110
+
111
+ context 'when fetch returns empty params and next_token at first, fetch returns two parameters and empty next_token at second' do
112
+ let(:responses) {
113
+ [ AwsSsmEnv::FetchResult.new([], 'next_token'),
114
+ AwsSsmEnv::FetchResult.new(parameters, nil)]
115
+ }
116
+
117
+ it 'consumer is called twice' do
118
+ expect(call_count).to eq(2)
104
119
  end
105
120
  end
106
121
 
107
122
  context 'when fetch returns two parameters at first and empty next_token' do
108
- let(:dummy_response) { AwsSsmEnv::FetchResult.new(parameters, nil) }
123
+ let(:responses) { [AwsSsmEnv::FetchResult.new(parameters, nil)] }
109
124
 
110
125
  it 'consumer is called twice' do
111
- called = 0
112
- fetcher.each do |_|
113
- called += 1
114
- end
115
- expect(called).to eq(2)
126
+ expect(call_count).to eq(2)
116
127
  end
117
128
  end
118
129
 
119
130
  context 'when fetch returns two parameters and next_token at first, fetch returns two parameters and empty next_token at second' do
120
- let(:fetcher) {
121
- mock_class = Class.new(described_class) do
122
- def initialize(parameters); @parameters = parameters; @count = 0; end
123
- protected def fetch(_)
124
- if @count == 0
125
- @count = 1
126
- AwsSsmEnv::FetchResult.new(@parameters, 'next_token')
127
- else
128
- AwsSsmEnv::FetchResult.new(@parameters, nil)
129
- end
130
- end
131
- end
132
- mock_class.new(parameters)
131
+ let(:responses) {
132
+ [AwsSsmEnv::FetchResult.new(parameters, 'next_token'),
133
+ AwsSsmEnv::FetchResult.new(parameters, nil)]
133
134
  }
134
135
 
135
136
  it 'consumer is called four times' do
136
- called = 0
137
- fetcher.each do |_|
138
- called += 1
139
- end
140
- expect(called).to eq(4)
137
+ expect(call_count).to eq(4)
141
138
  end
142
139
  end
143
140
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'aws-ssm-env/fetchers/begins_with'
3
3
 
4
4
  describe AwsSsmEnv::BeginsWithFetcher do
5
- let(:fetcher) { described_class.new(args) }
5
+ let(:fetcher) { described_class.new(**args) }
6
6
  let(:args) { { begins_with: [ '/foo', '/bar' ] } }
7
7
  let(:base_params) { fetcher.instance_variable_get(:'@base_params') }
8
8
  let(:parameter_filter) { base_params[:parameter_filters][0] }
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe AwsSsmEnv::FetcherFactory do
4
4
  describe '#create_fetcher' do
5
- let(:fetcher) { described_class.create_fetcher(args) }
5
+ let(:fetcher) { described_class.create_fetcher(**args) }
6
6
 
7
7
  context 'when fetch was not set' do
8
8
  context 'when begins_with was not set' do
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'aws-ssm-env/fetchers/path'
3
3
 
4
4
  describe AwsSsmEnv::PathFetcher do
5
- let(:fetcher) { described_class.new(args) }
5
+ let(:fetcher) { described_class.new(**args) }
6
6
  let(:args) { { path: '/path' } }
7
7
  let(:base_params) { fetcher.instance_variable_get(:'@base_params') }
8
8
 
@@ -4,7 +4,7 @@ describe AwsSsmEnv::Loader do
4
4
  let(:args) { { path: '/foo' } }
5
5
 
6
6
  describe '#initialize' do
7
- let(:loader) { described_class.new(args) }
7
+ let(:loader) { described_class.new(**args) }
8
8
 
9
9
  it 'has fetcher and naming_strategy' do
10
10
  expect(loader.instance_variable_get(:@fetcher)).to be_a(AwsSsmEnv::PathFetcher)
@@ -52,7 +52,7 @@ describe AwsSsmEnv::Loader do
52
52
  ENV['foo'] = nil
53
53
  ENV['fizz'] = 'fizz'
54
54
 
55
- loader = described_class.new(args)
55
+ loader = described_class.new(**args)
56
56
  loader.instance_variable_set(:@fetcher,
57
57
  [ Parameter.new('foo', 'bar'), Parameter.new('fizz', 'buzz') ])
58
58
 
@@ -70,7 +70,7 @@ describe AwsSsmEnv::Loader do
70
70
  ENV['foo'] = nil
71
71
  ENV['fizz'] = 'fizz'
72
72
 
73
- loader = described_class.new(args)
73
+ loader = described_class.new(**args)
74
74
  loader.instance_variable_set(:@fetcher,
75
75
  [ Parameter.new('foo', 'bar'), Parameter.new('fizz', 'buzz') ])
76
76
 
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe AwsSsmEnv::NamingStrategyFactory do
4
4
  describe '#create_naming_strategy' do
5
- let(:naming_strategy) { described_class.create_naming_strategy(args) }
5
+ let(:naming_strategy) { described_class.create_naming_strategy(**args) }
6
6
 
7
7
  context 'when naming was not set' do
8
8
  let(:args) { { naming: nil } }
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'aws-ssm-env/naming_strategies/snakecase'
3
3
 
4
4
  describe AwsSsmEnv::SnakeCaseNamingStrategy do
5
- let(:strategy) { described_class.new(args) }
5
+ let(:strategy) { described_class.new(**args) }
6
6
  let(:name) { 'path.to.db/password' }
7
7
  let(:env_name) { strategy.parse_name(Parameter.new(name)) }
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-ssm-env
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryohei Sonoda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-16 00:00:00.000000000 Z
11
+ date: 2020-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-ssm
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 0.16.1
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 0.16.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: simplecov-console
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -147,7 +147,7 @@ licenses:
147
147
  - Apache-2.0
148
148
  metadata:
149
149
  source_code_uri: https://github.com/sonodar/aws-ssm-env-ruby
150
- changelog_uri: https://github.com/sonodar/aws-ssm-env-ruby/tree/master/aws-ssm-env-ruby/CHANGELOG.md
150
+ changelog_uri: https://github.com/sonodar/aws-ssm-env-ruby/tree/master/CHANGELOG.md
151
151
  post_install_message:
152
152
  rdoc_options: []
153
153
  require_paths:
@@ -156,15 +156,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
- version: '2.2'
159
+ version: '2.5'
160
160
  required_rubygems_version: !ruby/object:Gem::Requirement
161
161
  requirements:
162
162
  - - ">="
163
163
  - !ruby/object:Gem::Version
164
164
  version: '0'
165
165
  requirements: []
166
- rubyforge_project:
167
- rubygems_version: 2.7.4
166
+ rubygems_version: 3.0.8
168
167
  signing_key:
169
168
  specification_version: 4
170
169
  summary: Set parameters acquired from AWS EC2 Parameter Store as environment variables.