Class: Orchparty::Services::Context
- Inherits:
-
Object
- Object
- Orchparty::Services::Context
- Defined in:
- lib/orchparty/kubernetes_application.rb
Instance Attribute Summary collapse
-
#app_config ⇒ Object
Returns the value of attribute app_config.
-
#cluster_name ⇒ Object
Returns the value of attribute cluster_name.
-
#dir_path ⇒ Object
Returns the value of attribute dir_path.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
Instance Method Summary collapse
-
#initialize(cluster_name:, namespace:, file_path:, app_config:) ⇒ Context
constructor
A new instance of Context.
- #install(helm) ⇒ Object
- #print_install(helm) ⇒ Object
- #print_upgrade(helm) ⇒ Object
- #template(file_path, helm, flag: "-f ", fix_file_path: nil) ⇒ Object
- #upgrade(helm) ⇒ Object
Constructor Details
#initialize(cluster_name:, namespace:, file_path:, app_config:) ⇒ Context
Returns a new instance of Context.
20 21 22 23 24 25 |
# File 'lib/orchparty/kubernetes_application.rb', line 20 def initialize(cluster_name: , namespace:, file_path: , app_config:) self.cluster_name = cluster_name self.namespace = namespace self.dir_path = file_path self.app_config = app_config end |
Instance Attribute Details
#app_config ⇒ Object
Returns the value of attribute app_config.
18 19 20 |
# File 'lib/orchparty/kubernetes_application.rb', line 18 def app_config @app_config end |
#cluster_name ⇒ Object
Returns the value of attribute cluster_name.
15 16 17 |
# File 'lib/orchparty/kubernetes_application.rb', line 15 def cluster_name @cluster_name end |
#dir_path ⇒ Object
Returns the value of attribute dir_path.
17 18 19 |
# File 'lib/orchparty/kubernetes_application.rb', line 17 def dir_path @dir_path end |
#namespace ⇒ Object
Returns the value of attribute namespace.
16 17 18 |
# File 'lib/orchparty/kubernetes_application.rb', line 16 def namespace @namespace end |
Instance Method Details
#install(helm) ⇒ Object
62 63 64 |
# File 'lib/orchparty/kubernetes_application.rb', line 62 def install(helm) puts system(install_cmd(helm)) end |
#print_install(helm) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/orchparty/kubernetes_application.rb', line 42 def print_install(helm) puts "---" puts install_cmd(helm, value_path(helm)) puts "---" puts File.read(template(value_path(helm), helm, flag: "")) if value_path(helm) end |
#print_upgrade(helm) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/orchparty/kubernetes_application.rb', line 49 def print_upgrade(helm) puts "---" puts install_cmd(helm, value_path(helm)) puts "---" puts File.read(template(value_path(helm), helm, flag: "")) if value_path(helm) end |
#template(file_path, helm, flag: "-f ", fix_file_path: nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/orchparty/kubernetes_application.rb', line 27 def template(file_path, helm, flag: "-f ", fix_file_path: nil) return "" unless file_path file_path = File.join(self.dir_path, file_path) if(file_path.end_with?(".erb")) helm.application = OpenStruct.new(cluster_name: cluster_name, namespace: namespace) template = Erubis::Eruby.new(File.read(file_path)) yaml = template.result(helm.get_binding) file = Tempfile.new("kube-deploy.yaml") file.write(yaml) file.close file_path = file.path end "#{flag}#{fix_file_path || file_path}" end |
#upgrade(helm) ⇒ Object
57 58 59 |
# File 'lib/orchparty/kubernetes_application.rb', line 57 def upgrade(helm) puts system(upgrade_cmd(helm)) end |