Class: Varager::Model::Env
- Inherits:
-
Object
- Object
- Varager::Model::Env
- Defined in:
- lib/varager/models/env.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_var(key, value) ⇒ Object
- #add_vars(dict) ⇒ Object
- #conf_json ⇒ Object
- #conf_k8s(indent = 10) ⇒ Object
-
#conf_shell(with_export = false) ⇒ Object
def save! Varager.add_env(self.to_json) end.
- #conf_yaml ⇒ Object
Class Method Details
.json_root ⇒ Object
42 43 44 |
# File 'lib/varager/models/env.rb', line 42 def self.json_root @json_root = "environment" end |
Instance Method Details
#add_var(key, value) ⇒ Object
34 35 36 |
# File 'lib/varager/models/env.rb', line 34 def add_var(key, value) Varager.add_vars(params: {id: self.name}, body: {config: {key => value}}.to_json) end |
#add_vars(dict) ⇒ Object
38 39 40 |
# File 'lib/varager/models/env.rb', line 38 def add_vars(dict) Varager.add_vars(params: {id: self.name}, body: {config: dict}.to_json) end |
#conf_json ⇒ Object
30 31 32 |
# File 'lib/varager/models/env.rb', line 30 def conf_json config.to_json end |
#conf_k8s(indent = 10) ⇒ Object
25 26 27 28 |
# File 'lib/varager/models/env.rb', line 25 def conf_k8s(indent=10) space = "#{" " * indent}" config.each {|k,v| puts "#{space}- name: #{k}\n#{space} value:'#{v}'"} end |
#conf_shell(with_export = false) ⇒ Object
def save!
Varager.add_env(self.to_json)
end
17 18 19 |
# File 'lib/varager/models/env.rb', line 17 def conf_shell(with_export=false) config.each {|k,v| puts "#{with_export ? 'export ' : ''}#{k}='#{v}'"} end |
#conf_yaml ⇒ Object
21 22 23 |
# File 'lib/varager/models/env.rb', line 21 def conf_yaml config.each {|k,v| puts "#{k}: '#{v}'"} end |