Class: KubeSecretsEncode::Command
- Inherits:
-
Object
- Object
- KubeSecretsEncode::Command
- Includes:
- Executable
- Defined in:
- lib/kube_secrets_encode.rb
Instance Method Summary collapse
-
#call(file) ⇒ Object
Say hello.
- #decode=(bool) ⇒ Object
- #decode? ⇒ Boolean
-
#help? ⇒ Boolean
(also: #h?)
Show this message.
- #yes=(bool) ⇒ Object
- #yes? ⇒ Boolean
Instance Method Details
#call(file) ⇒ Object
Say hello.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/kube_secrets_encode.rb', line 33 def call(file) documents = [] YAML.load_stream(File.open(file)) do |document| if document["kind"] == "Secret" if document["data"] document["data"].each do |k,v| if decode? document["data"][k] = Base64.strict_decode64(v) else document["data"][k] = Base64.strict_encode64(v) end end end end documents << document end yaml = documents.map{|d| d.to_yaml}.join puts yaml if yes? File.open(file, 'w') { |file| file.write(yaml) } end end |
#decode=(bool) ⇒ Object
18 19 20 |
# File 'lib/kube_secrets_encode.rb', line 18 def decode=(bool) @decode = bool end |
#decode? ⇒ Boolean
21 22 23 |
# File 'lib/kube_secrets_encode.rb', line 21 def decode? @decode end |
#help? ⇒ Boolean Also known as: h?
Show this message.
26 27 28 29 |
# File 'lib/kube_secrets_encode.rb', line 26 def help? cli.show_help exit end |
#yes=(bool) ⇒ Object
11 12 13 |
# File 'lib/kube_secrets_encode.rb', line 11 def yes=(bool) @yes = bool end |
#yes? ⇒ Boolean
15 16 17 |
# File 'lib/kube_secrets_encode.rb', line 15 def yes? @yes end |