Module: Dapp::Kube::Dapp::Command::SecretExtract
- Included in:
- Dapp
- Defined in:
- lib/dapp/kube/dapp/command/secret_extract.rb
Instance Method Summary collapse
- #kube_extract_secret ⇒ Object
- #kube_extract_secret_file(file_path) ⇒ Object
- #kube_extract_secret_values(file_path) ⇒ Object
- #kube_secret_extract(file_path) ⇒ Object
Instance Method Details
#kube_extract_secret ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/dapp/kube/dapp/command/secret_extract.rb', line 31 def kube_extract_secret data = begin if $stdin.tty? print 'Enter secret: ' $stdin.gets else $stdin.read end.to_s.chomp end if data.empty? exit 0 else secret.extract(data) end end |
#kube_extract_secret_file(file_path) ⇒ Object
52 53 54 |
# File 'lib/dapp/kube/dapp/command/secret_extract.rb', line 52 def kube_extract_secret_file(file_path) secret.extract(IO.binread(file_path).chomp("\n")) end |
#kube_extract_secret_values(file_path) ⇒ Object
48 49 50 |
# File 'lib/dapp/kube/dapp/command/secret_extract.rb', line 48 def kube_extract_secret_values(file_path) kube_helm_decode_json(secret, yaml_load_file(file_path)).to_yaml end |
#kube_secret_extract(file_path) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dapp/kube/dapp/command/secret_extract.rb', line 6 def kube_secret_extract(file_path) secret_key_should_exist! data = begin if file_path kube_secret_file_validate!(file_path) if [:values] kube_extract_secret_values(file_path) else kube_extract_secret_file(file_path) end else kube_extract_secret end end if (output_file_path = [:output_file_path]) FileUtils.mkpath File.dirname(output_file_path) IO.binwrite(output_file_path, data) else puts data end end |