Module: Dapp::Kube::Dapp::Command::SecretGenerate
- Included in:
- Dapp
- Defined in:
- lib/dapp/kube/dapp/command/secret_generate.rb
Instance Method Summary collapse
- #kube_secret ⇒ Object
- #kube_secret_file(file_path) ⇒ Object
- #kube_secret_generate(file_path) ⇒ Object
Instance Method Details
#kube_secret ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dapp/kube/dapp/command/secret_generate.rb', line 16 def kube_secret data = begin if $stdin.tty? print 'Enter secret: ' $stdin.noecho(&:gets).tap { print "\n" } else $stdin.read end end unless (data = data.to_s.chomp).empty? puts secret.generate(data) end end |
#kube_secret_file(file_path) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/dapp/kube/dapp/command/secret_generate.rb', line 31 def kube_secret_file(file_path) raise Error::Command, code: :file_not_exist, data: { path: File.(file_path) } unless File.exist?(file_path) encrypted_data = secret.generate(IO.binread(file_path)) if (output_file_path = [:output_file_path]).nil? puts encrypted_data else FileUtils.mkpath File.dirname(output_file_path) IO.binwrite(output_file_path, "#{encrypted_data}\n") end end |
#kube_secret_generate(file_path) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/dapp/kube/dapp/command/secret_generate.rb', line 6 def kube_secret_generate(file_path) secret_key_should_exist! if file_path.nil? kube_secret else kube_secret_file(file_path) end end |