vault 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +46 -3
- data/CHANGELOG.md +6 -0
- data/lib/vault/api/sys.rb +1 -0
- data/lib/vault/api/sys/namespace.rb +0 -2
- data/lib/vault/api/sys/quota.rb +107 -0
- data/lib/vault/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 267c85a379172af5c24fd3c3d4e14b9f07991e058f64933b3c56cc07036b053e
|
|
4
|
+
data.tar.gz: 847ead8ea9965e449dfbf11e3447b240e5c016fbe90e177f1ba6adca0615ee18
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 744df9d7282b0f873f008667fbd9c5bd943eea362535cdf872598c5eb5cb9fa36bb91d182a2b3ad0a2877294c16e345d371b33998a83645ba4e6880b13980e0e
|
|
7
|
+
data.tar.gz: 64ac03ddf3a2c5609e2224548353be0d9e640bfba1ec0ec0e215f541f2802db830238373a5b38fb15f77675d75717847468b8e5c2a1331cf609e87ca497e812a
|
data/.circleci/config.yml
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
version: 2.1
|
|
2
2
|
|
|
3
|
+
orbs:
|
|
4
|
+
gem: zfhui/ruby-gem@0.2.1
|
|
5
|
+
|
|
3
6
|
references:
|
|
4
7
|
images:
|
|
5
8
|
ubuntu: &UBUNTU_IMAGE ubuntu-1604:201903-01
|
|
@@ -15,6 +18,12 @@ jobs:
|
|
|
15
18
|
type: string
|
|
16
19
|
steps:
|
|
17
20
|
- checkout
|
|
21
|
+
# Restore bundle cache
|
|
22
|
+
- restore_cache:
|
|
23
|
+
keys:
|
|
24
|
+
- v1-dependencies-bundler-<< parameters.ruby-version >>-{{ checksum "vault.gemspec" }}
|
|
25
|
+
# fallback to using the latest cache if no exact match is found
|
|
26
|
+
- v1-dependencies-bundler-
|
|
18
27
|
- run:
|
|
19
28
|
name: Install vault
|
|
20
29
|
command: |
|
|
@@ -23,20 +32,54 @@ jobs:
|
|
|
23
32
|
mkdir -p ~/bin
|
|
24
33
|
mv vault ~/bin
|
|
25
34
|
export PATH="~/bin:$PATH"
|
|
35
|
+
- run:
|
|
36
|
+
name: Set ruby version
|
|
37
|
+
command: |
|
|
38
|
+
rvm install << parameters.ruby-version >>
|
|
39
|
+
echo . $(rvm << parameters.ruby-version >> do rvm env --path) >> $BASH_ENV
|
|
26
40
|
- run:
|
|
27
41
|
name: Run tests
|
|
28
42
|
command: |
|
|
29
43
|
export VAULT_VERSION=<< parameters.vault-version >>
|
|
30
|
-
|
|
44
|
+
ruby --version
|
|
45
|
+
gem install bundler
|
|
46
|
+
bundle -v
|
|
31
47
|
bundle install --jobs=3 --retry=3 --path=vendor/bundle
|
|
32
48
|
bundle exec rake
|
|
49
|
+
# Store bundle cache
|
|
50
|
+
- save_cache:
|
|
51
|
+
key: v1-dependencies-bundler-<< parameters.ruby-version >>-{{ checksum "vault.gemspec" }}
|
|
52
|
+
paths:
|
|
53
|
+
- vendor/bundle
|
|
54
|
+
|
|
55
|
+
build-release:
|
|
56
|
+
working_directory: ~/repo
|
|
57
|
+
executor: gem/default
|
|
58
|
+
steps:
|
|
59
|
+
- gem/build:
|
|
60
|
+
gem-name: vault
|
|
61
|
+
- gem/release:
|
|
62
|
+
gem-name: vault
|
|
63
|
+
gem-credentials-env-name: $RUBYGEMS_API_KEY
|
|
33
64
|
|
|
34
65
|
workflows:
|
|
35
66
|
run-tests:
|
|
36
67
|
jobs:
|
|
37
68
|
- test:
|
|
69
|
+
filters:
|
|
70
|
+
tags:
|
|
71
|
+
only: /^v[0-9]+\.[0-9]+\.[0-9]+.*/
|
|
38
72
|
matrix:
|
|
39
73
|
parameters:
|
|
40
|
-
ruby-version: ["2.
|
|
41
|
-
vault-version: ["1.0.
|
|
74
|
+
ruby-version: ["2.7.1", "2.6", "2.5"]
|
|
75
|
+
vault-version: ["1.5.0", "1.4.2", "1.4.1", "1.4.0", "1.3.6"]
|
|
42
76
|
name: test-ruby-<< matrix.ruby-version >>-vault-<< matrix.vault-version >>
|
|
77
|
+
- build-release:
|
|
78
|
+
requires:
|
|
79
|
+
- test
|
|
80
|
+
context: vault-gem-release
|
|
81
|
+
filters:
|
|
82
|
+
tags:
|
|
83
|
+
only: /^v[0-9]+\.[0-9]+\.[0-9]+.*/
|
|
84
|
+
branches:
|
|
85
|
+
ignore: /.*/
|
data/CHANGELOG.md
CHANGED
data/lib/vault/api/sys.rb
CHANGED
|
@@ -18,8 +18,6 @@ module Vault
|
|
|
18
18
|
# Vault.sys.namespaces #=> { :foo => #<struct Vault::Namespace id="xxxx1", path="foo/" }
|
|
19
19
|
#
|
|
20
20
|
# @return [Hash<Symbol, Namespace>]
|
|
21
|
-
#
|
|
22
|
-
# NOTE: Due to a bug in Vault Enterprise, to be fixed soon, this method CAN return a pure JSON string if a scoping namespace is provided.
|
|
23
21
|
def namespaces(scoped=nil)
|
|
24
22
|
path = ["v1", scoped, "sys", "namespaces"].compact
|
|
25
23
|
json = client.list(path.join("/"))
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
module Vault
|
|
2
|
+
class Quota < Response
|
|
3
|
+
# @!attribute [r] name
|
|
4
|
+
# Name of the quota rule.
|
|
5
|
+
# @return [String]
|
|
6
|
+
field :name
|
|
7
|
+
|
|
8
|
+
# @!attribute [r] path
|
|
9
|
+
# Namespace/Path combination the quota applies to.
|
|
10
|
+
# @return [String]
|
|
11
|
+
field :path
|
|
12
|
+
|
|
13
|
+
# @!attribute [r] type
|
|
14
|
+
# Type of the quota rule, must be one of "lease-count" or "rate-limit"
|
|
15
|
+
# @return [String]
|
|
16
|
+
field :type
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
class RateLimitQuota < Quota
|
|
20
|
+
# @!attribute [r] rate
|
|
21
|
+
# The rate at which allowed requests are refilled per second by the quota
|
|
22
|
+
# rule.
|
|
23
|
+
# @return [Float]
|
|
24
|
+
field :rate
|
|
25
|
+
|
|
26
|
+
# @!attribute [r] burst
|
|
27
|
+
# The maximum number of requests at any given second allowed by the quota
|
|
28
|
+
# rule.
|
|
29
|
+
# @return [Int]
|
|
30
|
+
field :burst
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class LeaseCountQuota < Quota
|
|
34
|
+
# @!attribute [r] counter
|
|
35
|
+
# Number of currently active leases for the quota.
|
|
36
|
+
# @return [Int]
|
|
37
|
+
field :counter
|
|
38
|
+
|
|
39
|
+
# @!attribute [r] max_leases
|
|
40
|
+
# The maximum number of allowed leases for this quota.
|
|
41
|
+
# @return [Int]
|
|
42
|
+
field :max_leases
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
class Sys
|
|
46
|
+
def quotas(type)
|
|
47
|
+
path = generate_path(type)
|
|
48
|
+
json = client.list(path)
|
|
49
|
+
if data = json.dig(:data, :key_info)
|
|
50
|
+
data.map do |item|
|
|
51
|
+
type_class(type).decode(item)
|
|
52
|
+
end
|
|
53
|
+
else
|
|
54
|
+
json
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def create_quota(type, name, opts={})
|
|
59
|
+
path = generate_path(type, name)
|
|
60
|
+
client.post(path, JSON.fast_generate(opts))
|
|
61
|
+
return true
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def delete_quota(type, name)
|
|
65
|
+
path = generate_path(type, name)
|
|
66
|
+
client.delete(path)
|
|
67
|
+
return true
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def get_quota(type, name)
|
|
71
|
+
path = generate_path(type, name)
|
|
72
|
+
response = client.get(path)
|
|
73
|
+
if data = response[:data]
|
|
74
|
+
type_class(type).decode(data)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def get_quota_config
|
|
79
|
+
client.get("v1/sys/quotas/config")
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def update_quota_config(opts={})
|
|
83
|
+
client.post("v1/sys/quotas/config", JSON.fast_generate(opts))
|
|
84
|
+
return true
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
private
|
|
88
|
+
|
|
89
|
+
def generate_path(type, name=nil)
|
|
90
|
+
verify_type(type)
|
|
91
|
+
path = ["v1", "sys", "quotas", type, name].compact
|
|
92
|
+
path.join("/")
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def verify_type(type)
|
|
96
|
+
return if ["rate-limit", "lease-count"].include?(type)
|
|
97
|
+
raise ArgumentError, "type must be one of \"rate-limit\" or \"lease-count\""
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def type_class(type)
|
|
101
|
+
case type
|
|
102
|
+
when "lease-count" then LeaseCountQuota
|
|
103
|
+
when "rate-limit" then RateLimitQuota
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
data/lib/vault/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vault
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.15.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Seth Vargo
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-05
|
|
11
|
+
date: 2020-08-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: aws-sigv4
|
|
@@ -143,6 +143,7 @@ files:
|
|
|
143
143
|
- lib/vault/api/sys/mount.rb
|
|
144
144
|
- lib/vault/api/sys/namespace.rb
|
|
145
145
|
- lib/vault/api/sys/policy.rb
|
|
146
|
+
- lib/vault/api/sys/quota.rb
|
|
146
147
|
- lib/vault/api/sys/seal.rb
|
|
147
148
|
- lib/vault/api/transform.rb
|
|
148
149
|
- lib/vault/api/transform/alphabet.rb
|