stack_master-gpg_parameter_resolver 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +12 -0
- data/LICENSE.txt +19 -0
- data/README.md +37 -0
- data/lib/stack_master/gpg_parameter_resolver.rb +3 -0
- data/lib/stack_master/gpg_parameter_resolver/version.rb +5 -0
- data/lib/stack_master/parameter_resolvers/secret.rb +51 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4fc4db57d3a112d968723bf5428f05f35ef3acbc696aad4ab3c9fd0ed9ed6a99
|
4
|
+
data.tar.gz: 838b08e44cff48597a5d16b18fc6ac5731ae142de3bfd716f874e7ebf1505cba
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 07f30ed16fccaa665dc1f12d769a1542bad0a5e34d88fa3695ab515069508bb1c2f222f85d18e025bfe0487b731afba04c9d7c91763bdda8142c7f37a3991477
|
7
|
+
data.tar.gz: 16bc5f43aea1d7efeb6a15a1b26f18f21b30ff3a10a4f583a5c78c5a1064bf9eb7dc26769b79ab6622dc7fdb4662e1688a9f2e9e175fe555cf8e4545f103514d
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
6
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
### Added
|
11
|
+
|
12
|
+
- Functionality extracted from the StackMaster gem.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2015-2019 Envato PTY LTD
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all 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/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# StackMaster::GpgParameterResolver
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/envato/stack_master-gpg_parameter_resolver.svg?branch=master)](https://travis-ci.org/envato/stack_master-gpg_parameter_resolver)
|
4
|
+
|
5
|
+
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/stack_master/gpg_parameter_resolver`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
|
+
|
7
|
+
TODO: Delete this and the text above, and describe your gem
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'stack_master-gpg_parameter_resolver'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install stack_master-gpg_parameter_resolver
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
TODO: Write usage instructions here
|
28
|
+
|
29
|
+
## Development
|
30
|
+
|
31
|
+
After checking out the repo, run `script/setup` to install dependencies. You can also run `script/console` for an interactive prompt that will allow you to experiment.
|
32
|
+
|
33
|
+
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).
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/envato/stack_master-gpg_parameter_resolver.
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'dotgpg'
|
2
|
+
|
3
|
+
module StackMaster
|
4
|
+
StackDefinition.class_eval do
|
5
|
+
attr_accessor :secret_file
|
6
|
+
end
|
7
|
+
|
8
|
+
module ParameterResolvers
|
9
|
+
class Secret < Resolver
|
10
|
+
SecretNotFound = Class.new(StandardError)
|
11
|
+
|
12
|
+
array_resolver
|
13
|
+
|
14
|
+
def initialize(config, stack_definition)
|
15
|
+
@config = config
|
16
|
+
@stack_definition = stack_definition
|
17
|
+
end
|
18
|
+
|
19
|
+
def resolve(value)
|
20
|
+
secret_key = value
|
21
|
+
raise ArgumentError, "No secret_file defined for stack definition #{@stack_definition.stack_name} in #{@stack_definition.region}" unless !@stack_definition.secret_file.nil?
|
22
|
+
raise ArgumentError, "Could not find secret file at #{secret_file_path}" unless File.exist?(secret_file_path)
|
23
|
+
secrets_hash.fetch(secret_key) do
|
24
|
+
raise SecretNotFound, "Unable to find key #{secret_key} in file #{secret_file_path}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def secrets_hash
|
31
|
+
@secrets_hash ||= YAML.load(decrypt_with_dotgpg)
|
32
|
+
end
|
33
|
+
|
34
|
+
def decrypt_with_dotgpg
|
35
|
+
Dotgpg.interactive = true
|
36
|
+
dir = Dotgpg::Dir.closest(secret_file_path)
|
37
|
+
stream = StringIO.new
|
38
|
+
dir.decrypt(secret_path_relative_to_base, stream)
|
39
|
+
stream.string
|
40
|
+
end
|
41
|
+
|
42
|
+
def secret_path_relative_to_base
|
43
|
+
@secret_path_relative_to_base ||= File.join('secrets', @stack_definition.secret_file)
|
44
|
+
end
|
45
|
+
|
46
|
+
def secret_file_path
|
47
|
+
@secret_file_path ||= File.join(@config.base_dir, secret_path_relative_to_base)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stack_master-gpg_parameter_resolver
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Steve Hodgkiss
|
8
|
+
- Glen Stampoultzis
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2019-07-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: stack_master
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: dotgpg
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bundler
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '2.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '2.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '10.0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '10.0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '3.8'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '3.8'
|
84
|
+
description:
|
85
|
+
email:
|
86
|
+
- steve@hodgkiss.me
|
87
|
+
- gstamp@gmail.com
|
88
|
+
executables: []
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- CHANGELOG.md
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- lib/stack_master/gpg_parameter_resolver.rb
|
96
|
+
- lib/stack_master/gpg_parameter_resolver/version.rb
|
97
|
+
- lib/stack_master/parameter_resolvers/secret.rb
|
98
|
+
homepage: https://github.com/envato/stack_master-gpg_parameter_resolver
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
metadata:
|
102
|
+
homepage_uri: https://github.com/envato/stack_master-gpg_parameter_resolver
|
103
|
+
source_code_uri: https://github.com/envato/stack_master-gpg_parameter_resolver
|
104
|
+
changelog_uri: https://github.com/envato/stack_master-gpg_parameter_resolver/blob/v0.1.0/CHANGELOG.md
|
105
|
+
bug_tracker_uri: https://github.com/envato/stack_master-gpg_parameter_resolver/issues
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubygems_version: 3.0.4
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: Allow parameters to be stored in encrypted secret files, protected with GPG
|
125
|
+
keys.
|
126
|
+
test_files: []
|