module KubernetesHelper
require 'byebug' rescue nil
Constants
- FOLDER_NAME
- VERSION
Public Class Methods
copy_templates(mode_or_file)
click to toggle source
@param mode_or_file (basic, advanced, String) mode name or any specific template name
# File lib/kubernetes_helper.rb, line 43 def self.copy_templates(mode_or_file) FileUtils.mkdir(settings_path) unless Dir.exist?(settings_path) template_path = templates_path(mode_or_file) return FileUtils.cp(template_path, settings_path(mode_or_file)) if File.exist?(template_path) files = %w[README.md secrets.yml settings.rb] files += %w[deployment.yml cd.sh ingress.yml service.yml] if mode_or_file == 'advanced' files.each do |name| path = settings_path(name) FileUtils.cp(templates_path(name), path) unless File.exist?(path) end end
load_settings()
click to toggle source
@param env_name (String) @return [Hash]
# File lib/kubernetes_helper.rb, line 17 def self.load_settings config_file = File.join(settings_path, 'settings.rb') load config_file settings end
run_cmd(cmd, title = nil)
click to toggle source
# File lib/kubernetes_helper.rb, line 32 def self.run_cmd(cmd, title = nil) res = Kernel.system cmd Kernel.abort("::::::::CD: failed running command: #{title || cmd} ==> #{caller}") if res != true end
settings(settings = nil)
click to toggle source
# File lib/kubernetes_helper.rb, line 10 def self.settings(settings = nil) @settings = settings if settings @settings end
settings_path(file_name = nil, use_template: false)
click to toggle source
# File lib/kubernetes_helper.rb, line 23 def self.settings_path(file_name = nil, use_template: false) path = File.join(Dir.pwd, FOLDER_NAME) if file_name app_path = File.join(path, file_name) path = use_template && !File.exist?(app_path) ? templates_path(file_name) : app_path end path end
templates_path(file_name = nil)
click to toggle source
# File lib/kubernetes_helper.rb, line 37 def self.templates_path(file_name = nil) path = File.join(File.expand_path(__dir__), 'templates') file_name ? File.join(path, file_name) : path end