kcu 0.1.0 → 0.2.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/CHANGELOG.md +5 -0
- data/lib/kcu.rb +6 -0
- data/lib/kcu/actions/get_secret_action.rb +17 -0
- data/lib/kcu/actions/set_secret_action.rb +19 -0
- data/lib/kcu/client.rb +16 -0
- data/lib/kcu/services/secrets/encode_entry_value.rb +15 -0
- data/lib/kcu/services/secrets/get_entry_value.rb +15 -0
- data/lib/kcu/services/secrets/set_entry_value.rb +35 -0
- data/lib/kcu/version.rb +1 -1
- metadata +6 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2ce1f8358a691f2bb4fe73a2d74fe7e9af6775ba
|
|
4
|
+
data.tar.gz: 1e02aa503e1da760686a663153e8de70a9c7b612
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b99940b59e086dd9c45a0e1348d24dc830db891113200d813af6246e1dcb4b3d7425885952163d8896d33f0562be239709623cb66837c7d70558637ba1d9c364
|
|
7
|
+
data.tar.gz: e4a4085bef52aef30252a84aea42a57cad5dd8c6426b28e1825b964ba0c400668a480bf6a96040a28020432fe219fa85ff2bd85fa43133a6db85f4e9a63a0b67
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.2.0] -2017-11-26
|
|
8
|
+
### Added
|
|
9
|
+
- Get a single secret's decoded value
|
|
10
|
+
- Set a single secret's value, given a non-encoded value (yes, we properly encode for you!)
|
|
11
|
+
|
|
7
12
|
## [0.1.0] - 2017-11-26
|
|
8
13
|
### Added
|
|
9
14
|
- List secrets of a resource
|
data/lib/kcu.rb
CHANGED
|
@@ -13,7 +13,13 @@ require "kcu/summary"
|
|
|
13
13
|
require "kcu/services/get_resource_namespace_and_name"
|
|
14
14
|
require "kcu/services/secrets/get_json"
|
|
15
15
|
require "kcu/services/secrets/decode_data"
|
|
16
|
+
require "kcu/services/secrets/get_entry_value"
|
|
17
|
+
require "kcu/services/secrets/encode_entry_value"
|
|
18
|
+
require "kcu/services/secrets/set_entry_value"
|
|
19
|
+
require "kcu/services/secrets/get_entry_value"
|
|
16
20
|
require "kcu/actions/list_secret_action"
|
|
21
|
+
require "kcu/actions/get_secret_action"
|
|
22
|
+
require "kcu/actions/set_secret_action"
|
|
17
23
|
require "kcu/client"
|
|
18
24
|
|
|
19
25
|
Kcu.new.run if $0 == __FILE__
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Kcu
|
|
2
|
+
class GetSecretAction
|
|
3
|
+
|
|
4
|
+
extend LightService::Organizer
|
|
5
|
+
|
|
6
|
+
def self.call(resource, entry_name)
|
|
7
|
+
ctx = with(resource: resource, entry_name: entry_name).reduce(
|
|
8
|
+
GetResourceNamespaceAndName,
|
|
9
|
+
Secrets::GetJson,
|
|
10
|
+
Secrets::DecodeData,
|
|
11
|
+
Secrets::GetEntryValue,
|
|
12
|
+
)
|
|
13
|
+
ap ctx.entry_value
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Kcu
|
|
2
|
+
class SetSecretAction
|
|
3
|
+
|
|
4
|
+
extend LightService::Organizer
|
|
5
|
+
|
|
6
|
+
def self.call(resource, entry_name, entry_value)
|
|
7
|
+
ctx = with({
|
|
8
|
+
resource: resource,
|
|
9
|
+
entry_name: entry_name,
|
|
10
|
+
entry_value: entry_value,
|
|
11
|
+
}).reduce(
|
|
12
|
+
GetResourceNamespaceAndName,
|
|
13
|
+
Secrets::EncodeEntryValue,
|
|
14
|
+
Secrets::SetEntryValue,
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/kcu/client.rb
CHANGED
|
@@ -18,6 +18,22 @@ module Kcu
|
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
command :"secret get" do |c|
|
|
22
|
+
c.syntax = "secret get namespace/secret_name entry_name"
|
|
23
|
+
c.description = "Return decoded value of specified secret"
|
|
24
|
+
c.action do |args, options|
|
|
25
|
+
GetSecretAction.(*args)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
command :"secret set" do |c|
|
|
30
|
+
c.syntax = "secret set namespace/secret_name entry_name value"
|
|
31
|
+
c.description = "Set an entry in a secret by giving a non-base64 encoded value"
|
|
32
|
+
c.action do |args, options|
|
|
33
|
+
SetSecretAction.(*args)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
21
37
|
run!
|
|
22
38
|
end
|
|
23
39
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Kcu
|
|
2
|
+
module Secrets
|
|
3
|
+
class EncodeEntryValue
|
|
4
|
+
|
|
5
|
+
extend LightService::Action
|
|
6
|
+
expects :entry_value
|
|
7
|
+
promises :encoded_entry_value
|
|
8
|
+
|
|
9
|
+
executed do |c|
|
|
10
|
+
c.encoded_entry_value = Base64.strict_encode64(c.entry_value)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Kcu
|
|
2
|
+
module Secrets
|
|
3
|
+
class GetEntryValue
|
|
4
|
+
|
|
5
|
+
extend LightService::Action
|
|
6
|
+
expects :decoded_secret_json, :entry_name
|
|
7
|
+
promises :entry_value
|
|
8
|
+
|
|
9
|
+
executed do |c|
|
|
10
|
+
c.entry_value = c.decoded_secret_json["data"][c.entry_name]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module Kcu
|
|
2
|
+
module Secrets
|
|
3
|
+
class SetEntryValue
|
|
4
|
+
|
|
5
|
+
extend LightService::Action
|
|
6
|
+
expects(
|
|
7
|
+
:resource_namespace,
|
|
8
|
+
:resource_name,
|
|
9
|
+
:entry_name,
|
|
10
|
+
:encoded_entry_value,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
executed do |c|
|
|
14
|
+
patch_json = {
|
|
15
|
+
data: {
|
|
16
|
+
c.entry_name => c.encoded_entry_value,
|
|
17
|
+
},
|
|
18
|
+
}.to_json
|
|
19
|
+
shell_command = [
|
|
20
|
+
"kubectl",
|
|
21
|
+
"patch",
|
|
22
|
+
"secret",
|
|
23
|
+
c.resource_name,
|
|
24
|
+
"--namespace=#{c.resource_namespace}",
|
|
25
|
+
["--patch", "'#{patch_json}'"].join("="),
|
|
26
|
+
].join(" ")
|
|
27
|
+
|
|
28
|
+
stdout_str, stderr_str, status = Open3.capture3(shell_command)
|
|
29
|
+
|
|
30
|
+
puts stdout_str
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
data/lib/kcu/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kcu
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ramon Tayag
|
|
@@ -117,11 +117,16 @@ files:
|
|
|
117
117
|
- bin/setup
|
|
118
118
|
- kcu.gemspec
|
|
119
119
|
- lib/kcu.rb
|
|
120
|
+
- lib/kcu/actions/get_secret_action.rb
|
|
120
121
|
- lib/kcu/actions/list_secret_action.rb
|
|
122
|
+
- lib/kcu/actions/set_secret_action.rb
|
|
121
123
|
- lib/kcu/client.rb
|
|
122
124
|
- lib/kcu/services/get_resource_namespace_and_name.rb
|
|
123
125
|
- lib/kcu/services/secrets/decode_data.rb
|
|
126
|
+
- lib/kcu/services/secrets/encode_entry_value.rb
|
|
127
|
+
- lib/kcu/services/secrets/get_entry_value.rb
|
|
124
128
|
- lib/kcu/services/secrets/get_json.rb
|
|
129
|
+
- lib/kcu/services/secrets/set_entry_value.rb
|
|
125
130
|
- lib/kcu/summary.rb
|
|
126
131
|
- lib/kcu/version.rb
|
|
127
132
|
homepage: https://github.com/bloom-solutions/kcu
|