kube_secrets_encode 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 235d7f3f431369e1550f7acf608bbac11cca6a8c
4
- data.tar.gz: 8d26082699cd3151556fed32bd24898556cc954a
3
+ metadata.gz: 3bf9303014d0e0fe0e8b839d512960cb3a2242fe
4
+ data.tar.gz: 0bc6aacce3cbe1589e547662d71d60ae16b97e78
5
5
  SHA512:
6
- metadata.gz: 8a6ce006a7a16138b703d50f680a6f3d8cc2e4e777bc3b7ff0f02157e5b62756205816e9a6c6679b52213318f843071223a2d565354e51c4c1e06c0eb9967ef4
7
- data.tar.gz: 9d8f1bcde8826675b2b9681bb2081d0ffe8940a2b355d797f12d3123b4682666e88085a29ebb39dc053773f67457cc853edbe012f6b220a65bbfecbce2ea32c6
6
+ metadata.gz: 5b07237ebb2705f0f281dd1af986e8b4398a0d7be4b88ab96254d81894e6d84101b8e72071aa9a4dcbfcc8e5a29636492e8902cc7e9767b9fc37844d04e81cb6
7
+ data.tar.gz: f6ad28812d0c9bbd4d9d261397089f9bd225167ffc44ab1f0bcfcc4c7bf55078bb3ac4060e3033292b8f0c2915d344186693bd932bc0f537bd3bc0fc7d36c738
data/README.md CHANGED
@@ -13,7 +13,7 @@ gem install kube_secrets_encode
13
13
  The command line to run is as follows
14
14
 
15
15
  ```
16
- kube_secrets filename
16
+ kube_secrets --file=filename
17
17
  ```
18
18
 
19
19
  This will encode the secrets in the file specified and render the result to screen.
@@ -25,7 +25,7 @@ This will encode the secrets in the file specified and render the result to scre
25
25
  This will perform the reverse of encode
26
26
 
27
27
  ```
28
- kube_secrets filename --decode
28
+ kube_secrets --file=filename --decode
29
29
  ```
30
30
 
31
31
 
@@ -1,4 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- require "bundler/setup"
3
2
  require 'kube_secrets_encode'
4
3
  KubeSecretsEncode::Command.run
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Stewart McKee"]
10
10
  spec.email = ["stewart@theizone.co.uk"]
11
11
 
12
- spec.summary = "Simple tool for encoding and decoding kubernetes secrets"
13
- spec.description = "Simple tool for encoding and decoding kubernetes secrets"
12
+ spec.summary = "kube_secrets enables you to encode and decode the base64 encoding of secrets in place within your config files making it easier to modify them."
13
+ spec.description = "kube_secrets enables you to encode and decode the base64 encoding of secrets in place within your config files making it easier to modify them."
14
14
  spec.homepage = "https://github.com/stewartmckee/kube_secrets_encode"
15
15
  spec.license = "MIT"
16
16
 
@@ -8,13 +8,22 @@ module KubeSecretsEncode
8
8
  class Command
9
9
  include Executable
10
10
 
11
+ # filename of file being encoded or decoded
12
+ def file=(filename)
13
+ @file = filename
14
+ end
15
+ def file
16
+ @file
17
+ end
18
+
19
+ # enables write after decode or encode
11
20
  def yes=(bool)
12
21
  @yes = bool
13
22
  end
14
-
15
23
  def yes?
16
24
  @yes
17
25
  end
26
+ # switch from default encode to decode mode
18
27
  def decode=(bool)
19
28
  @decode = bool
20
29
  end
@@ -29,29 +38,38 @@ module KubeSecretsEncode
29
38
  end
30
39
  alias :h? :help?
31
40
 
32
- # Say hello.
33
- def call(file)
41
+ def self.usage_name
42
+ "kube_secrets"
43
+ end
44
+
45
+ # kube_secrets enables you to encode and decode the base64 encoding of secrets in place within your config files making it easier to modify them.
46
+ def call()
34
47
  documents = []
35
- YAML.load_stream(File.open(file)) do |document|
36
- if document["kind"] == "Secret"
37
- if document["data"]
38
- document["data"].each do |k,v|
39
- if decode?
40
- document["data"][k] = Base64.strict_decode64(v)
41
- else
42
- document["data"][k] = Base64.strict_encode64(v)
48
+ if file && File.exists?(file)
49
+ YAML.load_stream(File.open(file)) do |document|
50
+ if document["kind"] == "Secret"
51
+ if document["data"]
52
+ document["data"].each do |k,v|
53
+ if decode?
54
+ document["data"][k] = Base64.strict_decode64(v)
55
+ else
56
+ document["data"][k] = Base64.strict_encode64(v)
57
+ end
43
58
  end
44
59
  end
45
60
  end
61
+ documents << document
46
62
  end
47
- documents << document
48
- end
49
- yaml = documents.map{|d| d.to_yaml}.join
63
+ yaml = documents.map{|d| d.to_yaml}.join
50
64
 
51
- puts yaml
52
- if yes?
53
- File.open(file, 'w') { |file| file.write(yaml) }
65
+ puts yaml
66
+ if yes?
67
+ File.open(file, 'w') { |file| file.write(yaml) }
68
+ end
69
+ else
70
+ cli.show_help
54
71
  end
72
+ exit
55
73
  end
56
74
  end
57
75
  end
@@ -1,3 +1,3 @@
1
1
  module KubeSecretsEncode
2
- VERSION = "0.1.1"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kube_secrets_encode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stewart McKee
@@ -80,7 +80,8 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.0'
83
- description: Simple tool for encoding and decoding kubernetes secrets
83
+ description: kube_secrets enables you to encode and decode the base64 encoding of
84
+ secrets in place within your config files making it easier to modify them.
84
85
  email:
85
86
  - stewart@theizone.co.uk
86
87
  executables:
@@ -127,5 +128,6 @@ rubyforge_project:
127
128
  rubygems_version: 2.6.12
128
129
  signing_key:
129
130
  specification_version: 4
130
- summary: Simple tool for encoding and decoding kubernetes secrets
131
+ summary: kube_secrets enables you to encode and decode the base64 encoding of secrets
132
+ in place within your config files making it easier to modify them.
131
133
  test_files: []