rake_vault 0.1.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +150 -0
- data/LICENSE.txt +21 -0
- data/README.md +71 -0
- data/Rakefile +144 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/rake_vault/task_sets/vault.rb +196 -0
- data/lib/rake_vault/task_sets.rb +3 -0
- data/lib/rake_vault/version.rb +5 -0
- data/lib/rake_vault.rb +10 -0
- data/rake_vault.gemspec +59 -0
- metadata +295 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 145bca98670a8811e886f08dce2006b85b00e50b002b989faa99fc775db0e1a0
|
4
|
+
data.tar.gz: 57e340cb7d5fe6f2d42aed04595730a34a194241cde698c7bdfbd2d0cf7b978d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 626b39007662ebcb484f111e01a4b2c477005ee9975cd12e32c6a4319316adbfbcbe6b99b5f13d5100a0be71e9c02481e60900d3fa08b8279560957dbd0a5b5d
|
7
|
+
data.tar.gz: b389afe1cdef7825e3d70c68a6d880fbc900c3a4bb1a707eb9859fe807745a45bf32120ee017a391d31c8699d8f914b06fca309aee10d286ea04c4e54e0564e2
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at maintainers@infrablocks.io. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rake_vault (0.1.0.pre.1)
|
5
|
+
colored2 (~> 3.1)
|
6
|
+
rake_dependencies (~> 3.1)
|
7
|
+
rake_factory (~> 0.23)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activesupport (7.0.3)
|
13
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
+
i18n (>= 1.6, < 2)
|
15
|
+
minitest (>= 5.1)
|
16
|
+
tzinfo (~> 2.0)
|
17
|
+
addressable (2.8.0)
|
18
|
+
public_suffix (>= 2.0.2, < 5.0)
|
19
|
+
ast (2.4.2)
|
20
|
+
colored2 (3.1.2)
|
21
|
+
concurrent-ruby (1.1.10)
|
22
|
+
diff-lcs (1.5.0)
|
23
|
+
docile (1.4.0)
|
24
|
+
excon (0.92.3)
|
25
|
+
faraday (2.3.0)
|
26
|
+
faraday-net_http (~> 2.0)
|
27
|
+
ruby2_keywords (>= 0.0.4)
|
28
|
+
faraday-net_http (2.0.3)
|
29
|
+
gem-release (2.2.2)
|
30
|
+
hamster (3.0.0)
|
31
|
+
concurrent-ruby (~> 1.0)
|
32
|
+
i18n (1.10.0)
|
33
|
+
concurrent-ruby (~> 1.0)
|
34
|
+
json (2.6.2)
|
35
|
+
lino (3.0.0)
|
36
|
+
hamster (~> 3.0)
|
37
|
+
open4 (~> 1.3)
|
38
|
+
memfs (1.0.0)
|
39
|
+
minitar (0.9)
|
40
|
+
minitest (5.16.2)
|
41
|
+
octokit (4.25.1)
|
42
|
+
faraday (>= 1, < 3)
|
43
|
+
sawyer (~> 0.9)
|
44
|
+
open4 (1.3.4)
|
45
|
+
parallel (1.22.1)
|
46
|
+
parser (3.1.2.0)
|
47
|
+
ast (~> 2.4.1)
|
48
|
+
public_suffix (4.0.7)
|
49
|
+
rainbow (3.1.1)
|
50
|
+
rake (13.0.6)
|
51
|
+
rake_circle_ci (0.9.0)
|
52
|
+
colored2 (~> 3.1)
|
53
|
+
excon (~> 0.72)
|
54
|
+
rake_factory (~> 0.23)
|
55
|
+
sshkey (~> 2.0)
|
56
|
+
rake_dependencies (3.1.0)
|
57
|
+
hamster (~> 3.0)
|
58
|
+
minitar (~> 0.9)
|
59
|
+
rake_factory (~> 0.23)
|
60
|
+
rubyzip (>= 1.3)
|
61
|
+
rake_factory (0.29.0)
|
62
|
+
activesupport (>= 4)
|
63
|
+
rake (~> 13.0)
|
64
|
+
rake_github (0.9.0)
|
65
|
+
colored2 (~> 3.1)
|
66
|
+
octokit (~> 4.16)
|
67
|
+
rake_factory (~> 0.23)
|
68
|
+
sshkey (~> 2.0)
|
69
|
+
rake_gpg (0.16.0)
|
70
|
+
rake_factory (>= 0.23, < 1)
|
71
|
+
ruby_gpg2 (>= 0.6, < 1)
|
72
|
+
rake_ssh (0.6.0)
|
73
|
+
colored2 (~> 3.1)
|
74
|
+
rake_factory (~> 0.23)
|
75
|
+
sshkey (~> 2.0)
|
76
|
+
regexp_parser (2.5.0)
|
77
|
+
rexml (3.2.5)
|
78
|
+
rspec (3.11.0)
|
79
|
+
rspec-core (~> 3.11.0)
|
80
|
+
rspec-expectations (~> 3.11.0)
|
81
|
+
rspec-mocks (~> 3.11.0)
|
82
|
+
rspec-core (3.11.0)
|
83
|
+
rspec-support (~> 3.11.0)
|
84
|
+
rspec-expectations (3.11.0)
|
85
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
86
|
+
rspec-support (~> 3.11.0)
|
87
|
+
rspec-mocks (3.11.1)
|
88
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
89
|
+
rspec-support (~> 3.11.0)
|
90
|
+
rspec-support (3.11.0)
|
91
|
+
rubocop (1.31.1)
|
92
|
+
json (~> 2.3)
|
93
|
+
parallel (~> 1.10)
|
94
|
+
parser (>= 3.1.0.0)
|
95
|
+
rainbow (>= 2.2.2, < 4.0)
|
96
|
+
regexp_parser (>= 1.8, < 3.0)
|
97
|
+
rexml (>= 3.2.5, < 4.0)
|
98
|
+
rubocop-ast (>= 1.18.0, < 2.0)
|
99
|
+
ruby-progressbar (~> 1.7)
|
100
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
101
|
+
rubocop-ast (1.18.0)
|
102
|
+
parser (>= 3.1.1.0)
|
103
|
+
rubocop-rake (0.6.0)
|
104
|
+
rubocop (~> 1.0)
|
105
|
+
rubocop-rspec (2.12.1)
|
106
|
+
rubocop (~> 1.31)
|
107
|
+
ruby-progressbar (1.11.0)
|
108
|
+
ruby2_keywords (0.0.5)
|
109
|
+
ruby_gpg2 (0.8.0)
|
110
|
+
lino (>= 1.5)
|
111
|
+
rubyzip (2.3.2)
|
112
|
+
sawyer (0.9.2)
|
113
|
+
addressable (>= 2.3.5)
|
114
|
+
faraday (>= 0.17.3, < 3)
|
115
|
+
simplecov (0.21.2)
|
116
|
+
docile (~> 1.1)
|
117
|
+
simplecov-html (~> 0.11)
|
118
|
+
simplecov_json_formatter (~> 0.1)
|
119
|
+
simplecov-html (0.12.3)
|
120
|
+
simplecov_json_formatter (0.1.4)
|
121
|
+
sshkey (2.0.0)
|
122
|
+
tzinfo (2.0.4)
|
123
|
+
concurrent-ruby (~> 1.0)
|
124
|
+
unicode-display_width (2.2.0)
|
125
|
+
|
126
|
+
PLATFORMS
|
127
|
+
arm64-darwin-21
|
128
|
+
ruby
|
129
|
+
x86_64-darwin-19
|
130
|
+
x86_64-linux
|
131
|
+
|
132
|
+
DEPENDENCIES
|
133
|
+
activesupport
|
134
|
+
bundler
|
135
|
+
gem-release
|
136
|
+
memfs
|
137
|
+
rake
|
138
|
+
rake_circle_ci
|
139
|
+
rake_github
|
140
|
+
rake_gpg
|
141
|
+
rake_ssh
|
142
|
+
rake_vault!
|
143
|
+
rspec
|
144
|
+
rubocop
|
145
|
+
rubocop-rake
|
146
|
+
rubocop-rspec
|
147
|
+
simplecov
|
148
|
+
|
149
|
+
BUNDLED WITH
|
150
|
+
2.3.17
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 InfraBlocks Maintainers
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# RakeVault
|
2
|
+
|
3
|
+
Rake tasks for interacting with Hashicorp Vault.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rake_vault'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install rake_vault
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write docs.
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
28
|
+
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
29
|
+
prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To
|
32
|
+
release a new version, update the version number in `version.rb`, and then run
|
33
|
+
`bundle exec rake release`, which will create a git tag for the version, push
|
34
|
+
git commits and tags, and push the `.gem` file to
|
35
|
+
[rubygems.org](https://rubygems.org).
|
36
|
+
|
37
|
+
### Managing CircleCI keys
|
38
|
+
|
39
|
+
To encrypt a GPG key for use by CircleCI:
|
40
|
+
|
41
|
+
```bash
|
42
|
+
openssl aes-256-cbc \
|
43
|
+
-e \
|
44
|
+
-md sha1 \
|
45
|
+
-in ./config/secrets/ci/gpg.private \
|
46
|
+
-out ./.circleci/gpg.private.enc \
|
47
|
+
-k "<passphrase>"
|
48
|
+
```
|
49
|
+
|
50
|
+
To check decryption is working correctly:
|
51
|
+
|
52
|
+
```bash
|
53
|
+
openssl aes-256-cbc \
|
54
|
+
-d \
|
55
|
+
-md sha1 \
|
56
|
+
-in ./.circleci/gpg.private.enc \
|
57
|
+
-k "<passphrase>"
|
58
|
+
```
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
Bug reports and pull requests are welcome on GitHub at
|
63
|
+
https://github.com/infrablocks/rake_vault. This project is intended to be a
|
64
|
+
safe, welcoming space for collaboration, and contributors are expected to
|
65
|
+
adhere to the [Contributor Covenant](http://contributor-covenant.org) code of
|
66
|
+
conduct.
|
67
|
+
|
68
|
+
## License
|
69
|
+
|
70
|
+
The gem is available as open source under the terms of the
|
71
|
+
[MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'rake_circle_ci'
|
5
|
+
require 'rake_github'
|
6
|
+
require 'rake_ssh'
|
7
|
+
require 'rake_gpg'
|
8
|
+
require 'securerandom'
|
9
|
+
require 'rspec/core/rake_task'
|
10
|
+
require 'rubocop/rake_task'
|
11
|
+
|
12
|
+
task default: %i[
|
13
|
+
library:fix
|
14
|
+
test:unit
|
15
|
+
]
|
16
|
+
|
17
|
+
namespace :encryption do
|
18
|
+
namespace :directory do
|
19
|
+
desc 'Ensure CI secrets directory exists.'
|
20
|
+
task :ensure do
|
21
|
+
FileUtils.mkdir_p('config/secrets/ci')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
namespace :passphrase do
|
26
|
+
desc 'Generate encryption passphrase used by CI.'
|
27
|
+
task generate: ['directory:ensure'] do
|
28
|
+
File.write('config/secrets/ci/encryption.passphrase',
|
29
|
+
SecureRandom.base64(36))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
namespace :keys do
|
35
|
+
namespace :deploy do
|
36
|
+
RakeSSH.define_key_tasks(
|
37
|
+
path: 'config/secrets/ci/',
|
38
|
+
comment: 'maintainers@infrablocks.io'
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
namespace :gpg do
|
43
|
+
RakeGPG.define_generate_key_task(
|
44
|
+
output_directory: 'config/secrets/ci',
|
45
|
+
name_prefix: 'gpg',
|
46
|
+
owner_name: 'InfraBlocks Maintainers',
|
47
|
+
owner_email: 'maintainers@infrablocks.io',
|
48
|
+
owner_comment: 'rake_vault CI Key'
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
namespace :secrets do
|
54
|
+
desc 'Regenerate all generatable secrets.'
|
55
|
+
task regenerate: %w[
|
56
|
+
encryption:passphrase:generate
|
57
|
+
keys:deploy:generate
|
58
|
+
keys:gpg:generate
|
59
|
+
]
|
60
|
+
end
|
61
|
+
|
62
|
+
RuboCop::RakeTask.new
|
63
|
+
|
64
|
+
namespace :library do
|
65
|
+
desc 'Run all checks of the library'
|
66
|
+
task check: [:rubocop]
|
67
|
+
|
68
|
+
desc 'Attempt to automatically fix issues with the library'
|
69
|
+
task fix: [:'rubocop:autocorrect']
|
70
|
+
end
|
71
|
+
|
72
|
+
namespace :test do
|
73
|
+
RSpec::Core::RakeTask.new(:unit)
|
74
|
+
end
|
75
|
+
|
76
|
+
RakeCircleCI.define_project_tasks(
|
77
|
+
namespace: :circle_ci,
|
78
|
+
project_slug: 'github/infrablocks/rake_vault'
|
79
|
+
) do |t|
|
80
|
+
circle_ci_config =
|
81
|
+
YAML.load_file('config/secrets/circle_ci/config.yaml')
|
82
|
+
|
83
|
+
t.api_token = circle_ci_config['circle_ci_api_token']
|
84
|
+
t.environment_variables = {
|
85
|
+
ENCRYPTION_PASSPHRASE:
|
86
|
+
File.read('config/secrets/ci/encryption.passphrase')
|
87
|
+
.chomp
|
88
|
+
}
|
89
|
+
t.checkout_keys = []
|
90
|
+
t.ssh_keys = [
|
91
|
+
{
|
92
|
+
hostname: 'github.com',
|
93
|
+
private_key: File.read('config/secrets/ci/ssh.private')
|
94
|
+
}
|
95
|
+
]
|
96
|
+
end
|
97
|
+
|
98
|
+
RakeGithub.define_repository_tasks(
|
99
|
+
namespace: :github,
|
100
|
+
repository: 'infrablocks/rake_vault'
|
101
|
+
) do |t, args|
|
102
|
+
github_config =
|
103
|
+
YAML.load_file('config/secrets/github/config.yaml')
|
104
|
+
|
105
|
+
t.access_token = github_config['github_personal_access_token']
|
106
|
+
t.deploy_keys = [
|
107
|
+
{
|
108
|
+
title: 'CircleCI',
|
109
|
+
public_key: File.read('config/secrets/ci/ssh.public')
|
110
|
+
}
|
111
|
+
]
|
112
|
+
t.branch_name = args.branch_name
|
113
|
+
t.commit_message = args.commit_message
|
114
|
+
end
|
115
|
+
|
116
|
+
namespace :pipeline do
|
117
|
+
desc 'Prepare CircleCI Pipeline'
|
118
|
+
task prepare: %i[
|
119
|
+
circle_ci:project:follow
|
120
|
+
circle_ci:env_vars:ensure
|
121
|
+
circle_ci:checkout_keys:ensure
|
122
|
+
circle_ci:ssh_keys:ensure
|
123
|
+
github:deploy_keys:ensure
|
124
|
+
]
|
125
|
+
end
|
126
|
+
|
127
|
+
namespace :version do
|
128
|
+
desc 'Bump version for specified type (pre, major, minor, patch)'
|
129
|
+
task :bump, [:type] do |_, args|
|
130
|
+
bump_version_for(args.type)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
desc 'Release gem'
|
135
|
+
task :release do
|
136
|
+
sh 'gem release --tag --push'
|
137
|
+
end
|
138
|
+
|
139
|
+
def bump_version_for(version_type)
|
140
|
+
sh "gem bump --version #{version_type} " \
|
141
|
+
'&& bundle install ' \
|
142
|
+
'&& export LAST_MESSAGE="$(git log -1 --pretty=%B)" ' \
|
143
|
+
'&& git commit -a --amend -m "${LAST_MESSAGE} [ci skip]"'
|
144
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'rake_vault'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
require 'rake_dependencies'
|
5
|
+
|
6
|
+
module RakeVault
|
7
|
+
module TaskSets
|
8
|
+
# rubocop:disable Metrics/ClassLength
|
9
|
+
|
10
|
+
class Vault
|
11
|
+
def self.define(...)
|
12
|
+
new(...).define_on(Rake.application)
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :delegate
|
16
|
+
|
17
|
+
def initialize(*args, &configuration_block)
|
18
|
+
@opts = args[0]
|
19
|
+
@delegate =
|
20
|
+
RakeDependencies::TaskSets::All.new(
|
21
|
+
task_set_opts, &configuration_block
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def define_on(application)
|
26
|
+
@delegate.define_on(application)
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
def binary
|
31
|
+
@binary ||= File.join(path, binary_directory, binary_name)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# rubocop:disable Metrics/MethodLength
|
37
|
+
|
38
|
+
def task_set_opts
|
39
|
+
{
|
40
|
+
namespace: namespace,
|
41
|
+
dependency: dependency,
|
42
|
+
version: version,
|
43
|
+
path: path,
|
44
|
+
type: type,
|
45
|
+
|
46
|
+
platform_os_names: platform_os_names,
|
47
|
+
platform_cpu_names: platform_cpu_names,
|
48
|
+
|
49
|
+
uri_template: uri_template,
|
50
|
+
file_name_template: file_name_template,
|
51
|
+
|
52
|
+
binary_directory: binary_directory,
|
53
|
+
|
54
|
+
needs_fetch: needs_fetch
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
# rubocop:enable Metrics/MethodLength
|
59
|
+
|
60
|
+
def logger
|
61
|
+
@logger ||= @opts[:logger] || Logger.new($stderr)
|
62
|
+
end
|
63
|
+
|
64
|
+
def namespace
|
65
|
+
@namespace ||= @opts[:namespace] || :vault
|
66
|
+
end
|
67
|
+
|
68
|
+
def dependency
|
69
|
+
@dependency ||= 'vault'
|
70
|
+
end
|
71
|
+
|
72
|
+
def version
|
73
|
+
@version ||= @opts[:version] || '1.10.4'
|
74
|
+
end
|
75
|
+
|
76
|
+
def path
|
77
|
+
@path ||= @opts[:path] ||
|
78
|
+
File.join(Dir.pwd, 'vendor', 'vault')
|
79
|
+
end
|
80
|
+
|
81
|
+
def binary_directory
|
82
|
+
@binary_directory ||= 'bin'
|
83
|
+
end
|
84
|
+
|
85
|
+
def binary_name
|
86
|
+
@binary_name ||= 'vault'
|
87
|
+
end
|
88
|
+
|
89
|
+
def type
|
90
|
+
@type ||= :zip
|
91
|
+
end
|
92
|
+
|
93
|
+
def platform_os_names
|
94
|
+
@platform_os_names ||= {
|
95
|
+
darwin: 'darwin',
|
96
|
+
linux: 'linux',
|
97
|
+
mswin32: 'windows',
|
98
|
+
mswin64: 'windows'
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
# rubocop:disable Naming/VariableNumber
|
103
|
+
def platform_cpu_names
|
104
|
+
@platform_cpu_names ||= {
|
105
|
+
x86_64: 'amd64',
|
106
|
+
x86: '386',
|
107
|
+
x64: 'amd64',
|
108
|
+
arm64: 'arm64'
|
109
|
+
}
|
110
|
+
end
|
111
|
+
# rubocop:enable Naming/VariableNumber
|
112
|
+
|
113
|
+
def uri_template
|
114
|
+
@uri_template ||=
|
115
|
+
'https://releases.hashicorp.com/vault/<%= @version %>/' \
|
116
|
+
'vault_<%= @version %>_' \
|
117
|
+
'<%= @platform_os_name %>_<%= @platform_cpu_name %><%= @ext %>'
|
118
|
+
end
|
119
|
+
|
120
|
+
def file_name_template
|
121
|
+
@file_name_template ||=
|
122
|
+
'vault_<%= @version %>_' \
|
123
|
+
'<%= @platform_os_name %>_<%= @platform_cpu_name %><%= @ext %>'
|
124
|
+
end
|
125
|
+
|
126
|
+
def needs_fetch
|
127
|
+
@needs_fetch ||= ->(_) { return !exists_with_correct_version?(binary) }
|
128
|
+
end
|
129
|
+
|
130
|
+
def exists_with_correct_version?(binary)
|
131
|
+
log_binary_location(binary)
|
132
|
+
|
133
|
+
exist?(binary) && correct_version?(binary)
|
134
|
+
end
|
135
|
+
|
136
|
+
def exist?(binary)
|
137
|
+
File.exist?(binary)
|
138
|
+
end
|
139
|
+
|
140
|
+
def correct_version?(binary)
|
141
|
+
result = StringIO.new
|
142
|
+
command = version_command(binary)
|
143
|
+
|
144
|
+
log_version_lookup(command)
|
145
|
+
|
146
|
+
command.execute(stdout: result)
|
147
|
+
|
148
|
+
log_version_information(result)
|
149
|
+
log_check_outcome(result)
|
150
|
+
|
151
|
+
contains_version_number?(result)
|
152
|
+
end
|
153
|
+
|
154
|
+
def version_command(binary)
|
155
|
+
Lino::CommandLineBuilder
|
156
|
+
.for_command(binary)
|
157
|
+
.with_flag('-version')
|
158
|
+
.build
|
159
|
+
end
|
160
|
+
|
161
|
+
def log_binary_location(binary)
|
162
|
+
logger.info("Vault binary should be at: #{binary}")
|
163
|
+
end
|
164
|
+
|
165
|
+
def log_version_lookup(command)
|
166
|
+
logger.info(
|
167
|
+
'Fetching vault version information using command: ' \
|
168
|
+
"#{command}"
|
169
|
+
)
|
170
|
+
end
|
171
|
+
|
172
|
+
def log_version_information(result)
|
173
|
+
logger.info(
|
174
|
+
"Vault version information is: \n#{result}"
|
175
|
+
)
|
176
|
+
end
|
177
|
+
|
178
|
+
def log_check_outcome(result)
|
179
|
+
logger.debug(
|
180
|
+
"Version: '#{version}' is in version line: " \
|
181
|
+
"'#{version_line(result)}'?: #{contains_version_number?(result)}"
|
182
|
+
)
|
183
|
+
end
|
184
|
+
|
185
|
+
def version_line(result)
|
186
|
+
result.string.lines.first
|
187
|
+
end
|
188
|
+
|
189
|
+
def contains_version_number?(result)
|
190
|
+
version_line(result) =~ /#{version}/
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
# rubocop:enable Metrics/ClassLength
|
195
|
+
end
|
196
|
+
end
|
data/lib/rake_vault.rb
ADDED
data/rake_vault.gemspec
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'rake_vault/version'
|
6
|
+
|
7
|
+
files = %w[
|
8
|
+
bin
|
9
|
+
lib
|
10
|
+
CODE_OF_CONDUCT.md
|
11
|
+
rake_vault.gemspec
|
12
|
+
Gemfile
|
13
|
+
LICENSE.txt
|
14
|
+
Rakefile
|
15
|
+
README.md
|
16
|
+
]
|
17
|
+
|
18
|
+
Gem::Specification.new do |spec|
|
19
|
+
spec.name = 'rake_vault'
|
20
|
+
spec.version = RakeVault::VERSION
|
21
|
+
spec.authors = ['InfraBlocks Maintainers']
|
22
|
+
spec.email = ['maintainers@infrablocks.io']
|
23
|
+
|
24
|
+
spec.summary = 'Rake tasks for interacting with Hashicorp Vault.'
|
25
|
+
spec.description =
|
26
|
+
'Allows logging into and interacting with Hashicorp Vault.'
|
27
|
+
spec.homepage = 'https://github.com/infrablocks/rake_vault'
|
28
|
+
spec.license = 'MIT'
|
29
|
+
|
30
|
+
spec.files = `git ls-files -z`.split("\x0").select do |f|
|
31
|
+
f.match(/^(#{files.map { |g| Regexp.escape(g) }.join('|')})/)
|
32
|
+
end
|
33
|
+
spec.bindir = 'exe'
|
34
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
35
|
+
spec.require_paths = ['lib']
|
36
|
+
|
37
|
+
spec.required_ruby_version = '>= 2.7'
|
38
|
+
|
39
|
+
spec.add_dependency 'colored2', '~> 3.1'
|
40
|
+
spec.add_dependency 'rake_dependencies', '~> 3.1'
|
41
|
+
spec.add_dependency 'rake_factory', '~> 0.23'
|
42
|
+
|
43
|
+
spec.add_development_dependency 'activesupport'
|
44
|
+
spec.add_development_dependency 'bundler'
|
45
|
+
spec.add_development_dependency 'gem-release'
|
46
|
+
spec.add_development_dependency 'memfs'
|
47
|
+
spec.add_development_dependency 'rake'
|
48
|
+
spec.add_development_dependency 'rake_circle_ci'
|
49
|
+
spec.add_development_dependency 'rake_github'
|
50
|
+
spec.add_development_dependency 'rake_gpg'
|
51
|
+
spec.add_development_dependency 'rake_ssh'
|
52
|
+
spec.add_development_dependency 'rspec'
|
53
|
+
spec.add_development_dependency 'rubocop'
|
54
|
+
spec.add_development_dependency 'rubocop-rake'
|
55
|
+
spec.add_development_dependency 'rubocop-rspec'
|
56
|
+
spec.add_development_dependency 'simplecov'
|
57
|
+
|
58
|
+
spec.metadata['rubygems_mfa_required'] = 'false'
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,295 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rake_vault
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.pre.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- InfraBlocks Maintainers
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-07-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colored2
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake_dependencies
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake_factory
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.23'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.23'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
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: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
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: gem-release
|
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'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: memfs
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rake_circle_ci
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rake_github
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rake_gpg
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rake_ssh
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: rspec
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: rubocop
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: rubocop-rake
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: rubocop-rspec
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: simplecov
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - ">="
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '0'
|
244
|
+
type: :development
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - ">="
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0'
|
251
|
+
description: Allows logging into and interacting with Hashicorp Vault.
|
252
|
+
email:
|
253
|
+
- maintainers@infrablocks.io
|
254
|
+
executables: []
|
255
|
+
extensions: []
|
256
|
+
extra_rdoc_files: []
|
257
|
+
files:
|
258
|
+
- CODE_OF_CONDUCT.md
|
259
|
+
- Gemfile
|
260
|
+
- Gemfile.lock
|
261
|
+
- LICENSE.txt
|
262
|
+
- README.md
|
263
|
+
- Rakefile
|
264
|
+
- bin/console
|
265
|
+
- bin/setup
|
266
|
+
- lib/rake_vault.rb
|
267
|
+
- lib/rake_vault/task_sets.rb
|
268
|
+
- lib/rake_vault/task_sets/vault.rb
|
269
|
+
- lib/rake_vault/version.rb
|
270
|
+
- rake_vault.gemspec
|
271
|
+
homepage: https://github.com/infrablocks/rake_vault
|
272
|
+
licenses:
|
273
|
+
- MIT
|
274
|
+
metadata:
|
275
|
+
rubygems_mfa_required: 'false'
|
276
|
+
post_install_message:
|
277
|
+
rdoc_options: []
|
278
|
+
require_paths:
|
279
|
+
- lib
|
280
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
281
|
+
requirements:
|
282
|
+
- - ">="
|
283
|
+
- !ruby/object:Gem::Version
|
284
|
+
version: '2.7'
|
285
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
286
|
+
requirements:
|
287
|
+
- - ">"
|
288
|
+
- !ruby/object:Gem::Version
|
289
|
+
version: 1.3.1
|
290
|
+
requirements: []
|
291
|
+
rubygems_version: 3.1.6
|
292
|
+
signing_key:
|
293
|
+
specification_version: 4
|
294
|
+
summary: Rake tasks for interacting with Hashicorp Vault.
|
295
|
+
test_files: []
|