smps 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fc43bc547d908e46aee0a1310f5112d2ae1ae468
4
+ data.tar.gz: 2b4138167c656e74d8b333a27e25eb25bdc3a393
5
+ SHA512:
6
+ metadata.gz: 04bebeb5eec0390cbe6217784e045394207693d0325a3b5092587fdce20146ecb719c1021f659f4295f75b1f821f52b7ef6af62bbb723338088bf98a93ab6dd6
7
+ data.tar.gz: 1ebadb303979261360cacfc032354be00ed6d7b80fb9ef6f8d03e569899bdc01259ce1a63e5734d23b50518daa87a5d2086ab5142e5525b19d1adb718ed982ed
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /vendor/
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
14
+
15
+ *aws-session.yaml
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.2
5
+ before_install: gem install bundler -v 1.15.4
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in smps.gemspec
6
+ gemspec
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Smps
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/smps`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'smps'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install smps
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/smps.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "smps"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/smps-use.rb ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'awssession'
4
+ require 'smps'
5
+
6
+ require 'aws_config'
7
+ require 'pp'
8
+
9
+ profile_name = ARGV[0]
10
+ profile = AWSConfig[profile_name]
11
+ profile['name'] = profile_name
12
+
13
+ awssession = AwsSession.new(profile: profile)
14
+ awssession.start
15
+
16
+ smps = SmPs.new(credentials: awssession.credentials)
17
+ # param = smps.parameter(name: 'abc')
18
+ param_abc = smps.parameter('abc')
19
+ puts param_abc.to_s
20
+ # puts "#{param_abc}"
21
+ param_abc.write!('xyz')
22
+ puts param_abc.to_s
23
+
24
+ param_z = smps.parameter('/Zipkid/test1')
25
+ puts param_z.to_s
@@ -0,0 +1,49 @@
1
+
2
+ class SmPs::Parameter
3
+ def initialize(options)
4
+ @ssm = options[:ssm]
5
+ @name = options[:name]
6
+ parameter
7
+ end
8
+
9
+ def parameter(decrypt = true)
10
+ resp = @ssm.get_parameter(
11
+ name: @name,
12
+ with_decryption: decrypt
13
+ )
14
+ @type = resp.parameter.type
15
+ @value = resp.parameter.value
16
+ @exists = true
17
+ rescue Aws::SSM::Errors::ParameterNotFound
18
+ @exists = false
19
+ end
20
+
21
+ def to_s
22
+ @value
23
+ end
24
+
25
+ def exists?
26
+ @exists
27
+ end
28
+
29
+ def write!(value, type = 'String', description = nil, key_id = nil)
30
+ raise ArgumentError unless %w[String StringList SecureString].include? type
31
+ true if value == @value
32
+ @ssm.put_parameter(
33
+ name: @name, description: description,
34
+ value: value, type: type,
35
+ key_id: key_id, overwrite: @exists,
36
+ # allowed_pattern: "AllowedPattern",
37
+ )
38
+ @value = value
39
+ end
40
+
41
+ def history
42
+ # get_parameter_history
43
+ end
44
+
45
+ def tag
46
+ # add_tags_to_resource
47
+ # remove_tags_from_resource
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ class SmPs
2
+ VERSION = '0.1.0'.freeze
3
+ end
data/lib/smps.rb ADDED
@@ -0,0 +1,33 @@
1
+ require 'smps/version'
2
+ require 'smps/parameter'
3
+ require 'aws-sdk-ssm'
4
+
5
+ class SmPs
6
+ def initialize(options)
7
+ @credentials = options[:credentials]
8
+ @parameters = {}
9
+ end
10
+
11
+ def ssm_client
12
+ @ssm || @ssm = Aws::SSM::Client.new(credentials: @credentials)
13
+ end
14
+
15
+ def parameter(name)
16
+ unless @parameters.key?(name)
17
+ @parameters[name] = SmPs::Parameter.new(ssm: ssm_client, name: name)
18
+ end
19
+ @parameters[name]
20
+ end
21
+
22
+ # def info
23
+ # describe_parameters
24
+ # end
25
+ #
26
+ # def parameter_list
27
+ # get_parameters
28
+ # end
29
+ #
30
+ # def by_path
31
+ # get_parameters_by_path
32
+ # end
33
+ end
data/license.txt ADDED
@@ -0,0 +1,19 @@
1
+ Copyright 2017 VRT.be
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/smps.gemspec ADDED
@@ -0,0 +1,41 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'smps/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'smps'
8
+ spec.version = SmPs::VERSION
9
+ spec.licenses = ['MIT']
10
+ spec.authors = ['Stefan - Zipkid - Goethals']
11
+ spec.email = ['stefan.goethals@vrt.be']
12
+
13
+ spec.summary = 'SMPS - Systems Manager Parameter Store'
14
+ spec.description = 'SMPS - Systems Manager Parameter Store'
15
+ spec.homepage = 'http://github.com/vrtdev/smps'
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
21
+ else
22
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
23
+ 'public gem pushes.'
24
+ end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = 'exe'
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ['lib']
32
+
33
+ spec.add_development_dependency 'bundler', '~> 1.15'
34
+ spec.add_development_dependency 'rake', '~> 10.0'
35
+ spec.add_development_dependency 'rspec', '~> 3.0'
36
+ spec.add_development_dependency 'aws_config'
37
+
38
+ spec.add_runtime_dependency 'aws-sdk-core'
39
+ spec.add_runtime_dependency 'aws-sdk-ssm'
40
+ spec.add_runtime_dependency 'awssession'
41
+ end
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: smps
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stefan - Zipkid - Goethals
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-10-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: aws_config
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: aws-sdk-core
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: aws-sdk-ssm
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: awssession
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: SMPS - Systems Manager Parameter Store
112
+ email:
113
+ - stefan.goethals@vrt.be
114
+ executables:
115
+ - smps-use.rb
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".travis.yml"
122
+ - Gemfile
123
+ - README.md
124
+ - Rakefile
125
+ - bin/console
126
+ - bin/setup
127
+ - exe/smps-use.rb
128
+ - lib/smps.rb
129
+ - lib/smps/parameter.rb
130
+ - lib/smps/version.rb
131
+ - license.txt
132
+ - smps.gemspec
133
+ homepage: http://github.com/vrtdev/smps
134
+ licenses:
135
+ - MIT
136
+ metadata:
137
+ allowed_push_host: https://rubygems.org
138
+ post_install_message:
139
+ rdoc_options: []
140
+ require_paths:
141
+ - lib
142
+ required_ruby_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ requirements: []
153
+ rubyforge_project:
154
+ rubygems_version: 2.6.13
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: SMPS - Systems Manager Parameter Store
158
+ test_files: []