smps 0.2.3 → 0.3.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
  SHA1:
3
- metadata.gz: a2f8ad8330a08626d592903ea074a2cb44b15042
4
- data.tar.gz: fa6b2a31cc193e5f40b6b1a4623e775840dc788a
3
+ metadata.gz: 04e50be45d76d8a48727fee5d8fb76356c27353b
4
+ data.tar.gz: 894396de27a5b150d03c70e66591bdfc0503a3aa
5
5
  SHA512:
6
- metadata.gz: 3500ed4bc7a97ff325735d049948c7d925d0556c22e562098744c91d4302222a923de0089b979cf9bda0919a38eb7bcda2cdc7c139c5bc7b16c30c5bb6c65f1f
7
- data.tar.gz: 633e72ec38d00420e9b356eb58957c5be8f4632bfc4f4f64a14ffa697aeb9e3ce461d4f721989d9b8945bc21722c8ac10114f4e6ab1c15208bae4993036f7ebf
6
+ metadata.gz: 4db415f4e8ee2f1fccc6dd812324d2511af5d4e282657fc66f27767b858be75dcf53794e956abb90c313f9db391a1dfc67c306afe0a91e44a0424b61b2081bd0
7
+ data.tar.gz: 69136335cbe42f919d13601019d1c1df6bf733ad9f371d5032b682be0bb74729b0d6ba2b727845db0643d9b405dae15ecc0a1d4fde405d5d5e841e1ebb92d791
data/.gitignore CHANGED
@@ -12,4 +12,4 @@
12
12
  # rspec failure tracking
13
13
  .rspec_status
14
14
 
15
- *aws-session.yaml
15
+ *-session.yaml
data/bin/smps-use-ec2.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require 'smps'
4
4
 
5
5
  smps = SmPs.new
6
- param_abc = smps.parameter('abc')
6
+ param_abc = smps.parameter(name: 'abc')
7
7
  puts param_abc.to_s
8
8
 
9
9
  param_abc.write!('xyz')
@@ -12,5 +12,5 @@ puts param_abc.to_s
12
12
  param_abc.write!('Another value.')
13
13
  puts param_abc.to_s
14
14
 
15
- param_z = smps.parameter('/Zipkid/test1')
15
+ param_z = smps.parameter(name: '/Zipkid/test1')
16
16
  puts param_z.to_s
data/bin/smps-use.rb CHANGED
@@ -4,7 +4,7 @@ require 'awssession'
4
4
  require 'smps'
5
5
 
6
6
  require 'aws_config'
7
- require 'pp'
7
+ require 'awesome_print'
8
8
 
9
9
  profile_name = ARGV[0]
10
10
  profile = AWSConfig[profile_name]
@@ -14,12 +14,31 @@ awssession = AwsSession.new(profile: profile)
14
14
  awssession.start
15
15
 
16
16
  smps = SmPs.new(credentials: awssession.credentials)
17
+
18
+ puts '1'
19
+ pl = smps.parameters_by_path(path: '/aem/dev/aem--author/packages')
20
+ puts '2'
21
+ # ap pl
22
+ pl.each do |p|
23
+ puts ' ---- '
24
+ ap p
25
+ puts p.name
26
+ ap p.value
27
+ end
28
+
29
+ # exit
30
+
17
31
  # param = smps.parameter(name: 'abc')
18
- param_abc = smps.parameter('abc')
32
+ param_abc = smps.parameter(name: 'abc')
19
33
  puts param_abc.to_s
20
34
  # puts "#{param_abc}"
35
+
21
36
  param_abc.write!('xyz')
22
37
  puts param_abc.to_s
38
+ # OR
39
+ param_abc.value = 'def'
40
+ param_abc.write!
41
+ puts param_abc.to_s
23
42
 
24
- param_z = smps.parameter('/Zipkid/test1')
43
+ param_z = smps.parameter(name: '/Zipkid/test1')
25
44
  puts param_z.to_s
data/changelog.md CHANGED
@@ -1,7 +1,12 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ Version format based on http://semver.org/
5
+
4
6
  ## [Unreleased]
7
+ ## [0.3.0] - 2017-10-13
8
+ ### Added
9
+ - parameters_by_path method
5
10
 
6
11
  ## [0.2.3] - 2017-10-06
7
12
  ### Changed
data/lib/smps.rb CHANGED
@@ -30,6 +30,31 @@ class SmPs
30
30
  @parameters[name]
31
31
  end
32
32
 
33
+ def parameters_by_path(options)
34
+ path = options.fetch(:path)
35
+ recursive = options[:recursive]
36
+ decrypt = options[:decrypt] || true
37
+ params = ssm_client.get_parameters_by_path(
38
+ path: path,
39
+ recursive: recursive,
40
+ with_decryption: decrypt
41
+ )
42
+ store_parameters params
43
+ end
44
+
45
+ def store_parameters(params)
46
+ return if params.nil?
47
+ list = []
48
+ params.parameters.each do |parameter|
49
+ @parameters[parameter.name] = SmPs::Parameter.new(
50
+ ssm: ssm_client, fetch: false,
51
+ name: parameter.name, value: parameter.value, type: parameter.type
52
+ )
53
+ list << @parameters[parameter.name]
54
+ end
55
+ list
56
+ end
57
+
33
58
  # def info
34
59
  # describe_parameters
35
60
  # end
@@ -2,18 +2,23 @@
2
2
  class SmPs
3
3
  # SmPs Parameter management
4
4
  class Parameter
5
+ attr_accessor :name, :type, :key_id, :decrypt, :description
6
+
5
7
  def initialize(options)
6
8
  @ssm = options[:ssm]
7
9
  @name = options[:name]
10
+ @value = options[:value]
8
11
  @type = options[:type]
9
12
  @key_id = options[:key_id]
10
- parameter
13
+ @decrypt = options[:decrypt]
14
+ fetch = options[:fetch]
15
+ fetch = true if options[:fetch].nil?
16
+ parameter if fetch
11
17
  end
12
18
 
13
- def parameter(decrypt = true)
19
+ def parameter
14
20
  resp = @ssm.get_parameter(
15
- name: @name,
16
- with_decryption: decrypt
21
+ name: @name, with_decryption: @decrypt
17
22
  )
18
23
  @type = resp.parameter.type
19
24
  @value = resp.parameter.value
@@ -26,19 +31,29 @@ class SmPs
26
31
  @value
27
32
  end
28
33
 
34
+ def value
35
+ return @value.split(',') if @type == 'StringList'
36
+ @value
37
+ end
38
+
39
+ def value=(value)
40
+ @changed = true if value != @value
41
+ @value = value
42
+ end
43
+
29
44
  def exists?
30
45
  @exists
31
46
  end
32
47
 
33
- def write!(value, description = nil)
34
- return true if value == @value
48
+ def write!(value = nil)
49
+ @changed = true if value != @value
50
+ @value = value if value
35
51
  @ssm.put_parameter(
36
- name: @name, value: value,
37
- description: description, type: @type,
38
- key_id: @key_id, overwrite: @exists,
52
+ name: @name, value: @value, type: @type,
53
+ description: @description, key_id: @key_id, overwrite: @exists,
39
54
  # allowed_pattern: "AllowedPattern",
40
55
  )
41
- @value = value
56
+ @value
42
57
  end
43
58
 
44
59
  def history
data/lib/smps/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class SmPs
2
- VERSION = '0.2.3'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
data/smps.gemspec CHANGED
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency 'rspec', '~> 3.0'
36
36
  spec.add_development_dependency 'aws_config'
37
37
  spec.add_development_dependency 'awssession'
38
+ spec.add_development_dependency 'awesome_print'
38
39
 
39
40
  spec.add_runtime_dependency 'aws-sdk-core', '~> 3.0'
40
41
  spec.add_runtime_dependency 'aws-sdk-ssm', '~> 1.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan - Zipkid - Goethals
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-09 00:00:00.000000000 Z
11
+ date: 2017-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: awesome_print
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: aws-sdk-core
85
99
  requirement: !ruby/object:Gem::Requirement