Module: Kubes::Compiler::Shared::Helpers::SecretHelper
- Included in:
- Kubes::Compiler::Shared::Helpers
- Defined in:
- lib/kubes/compiler/shared/helpers/secret_helper.rb
Instance Method Summary collapse
- #decode64(v) ⇒ Object
- #encode64(v) ⇒ Object (also: #base64)
-
#generic_secret_data(plugin_secret_method, name, options = {}) ⇒ Object
Meant to be used by plugins.
- #parse_env_like_line(line) ⇒ Object
Instance Method Details
#decode64(v) ⇒ Object
33 34 35 |
# File 'lib/kubes/compiler/shared/helpers/secret_helper.rb', line 33 def decode64(v) Base64.strict_decode64(v) end |
#encode64(v) ⇒ Object Also known as: base64
28 29 30 |
# File 'lib/kubes/compiler/shared/helpers/secret_helper.rb', line 28 def encode64(v) Base64.strict_encode64(v.to_s).strip end |
#generic_secret_data(plugin_secret_method, name, options = {}) ⇒ Object
Meant to be used by plugins. IE: google_secret_data and aws_secret_data
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/kubes/compiler/shared/helpers/secret_helper.rb', line 5 def generic_secret_data(plugin_secret_method, name, ={}) indent = [:indent] || 2 base64 = [:base64].nil? ? true : [:base64] text = send(plugin_secret_method, name, base64: false) path = create_generic_secret_data_temp_file(text) text = RenderMePretty.result(path, context: self) spacing = " " * indent lines = text.split("\n") new_lines = lines.map do |line| key, value = parse_env_like_line(line) value = encode64(value) if base64 "#{spacing}#{key}: #{value}" end new_lines.join("\n") end |
#parse_env_like_line(line) ⇒ Object
22 23 24 25 26 |
# File 'lib/kubes/compiler/shared/helpers/secret_helper.rb', line 22 def parse_env_like_line(line) key, *rest = line.split('=') value = rest.join('=') [key, value] end |