Class: KubeDeployTools::Kdt
Constant Summary collapse
- DESCRIPTIONS =
{ 'deploy' => 'Releases all Kubernetes resources in a deploy artifact with |kubectl apply|', 'push' => 'Tags and pushes images to defined image registries', 'generate' => 'Generates artifacts based on templates in kubernetes/ and your deploy.yaml.', 'publish' => 'Publishes generated artifacts to your artifact store.', 'upgrade' => 'Upgrades a KDT 1.x deploy.yml to a KDT 2.x deploy.yaml', }
Instance Method Summary collapse
- #bins_names ⇒ Object
- #display_bins ⇒ Object
- #execute! ⇒ Object
-
#initialize(path, args) ⇒ Kdt
constructor
A new instance of Kdt.
- #valid_bin?(bin) ⇒ Boolean
Constructor Details
#initialize(path, args) ⇒ Kdt
Returns a new instance of Kdt.
14 15 16 17 18 19 |
# File 'lib/kube_deploy_tools/kdt.rb', line 14 def initialize(path, args) KubeDeployTools::Logger.logger = KubeDeployTools::FormattedLogger.build @path = path @args = args end |
Instance Method Details
#bins_names ⇒ Object
21 22 23 |
# File 'lib/kube_deploy_tools/kdt.rb', line 21 def bins_names @bins ||= Dir["#{@path}/*"].map { |x| File.basename(x) } - ['kdt'] end |
#display_bins ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/kube_deploy_tools/kdt.rb', line 25 def display_bins # Print full runtime version version = Gem.loaded_specs["kube_deploy_tools"].version puts "kube_deploy_tools #{version}" bins_names.each do |bin| spaces_count = 25 - bin.size puts "-> #{bin}#{' ' * spaces_count}| #{DESCRIPTIONS[bin]}" end end |
#execute! ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/kube_deploy_tools/kdt.rb', line 36 def execute! bin = @args.first raise "command '#{bin}' is not a valid command" unless valid_bin?(bin) bin_with_path = "#{@path}/#{bin}" bin_args = @args[1..-1] # calling exec with multiple args will prevent shell expansion # https://ruby-doc.org/core/Kernel.html#method-i-exec exec bin_with_path, *bin_args end |
#valid_bin?(bin) ⇒ Boolean
48 49 50 |
# File 'lib/kube_deploy_tools/kdt.rb', line 48 def valid_bin?(bin) bins_names.include?(bin) end |