Sha256: 769a08beb6889c8435dbd5e9b4bd8d302192fc68dcb07d3c3c6a9e52bb049727

Contents?: true

Size: 1.89 KB

Versions: 2

Compression:

Stored size: 1.89 KB

Contents

# frozen_string_literal: true

module Krane
  module CLI
    class GlobalDeployCommand
      DEFAULT_DEPLOY_TIMEOUT = '300s'
      OPTIONS = {
        "filenames" => { type: :array, banner: 'config/deploy/production config/deploy/my-extra-resource.yml',
                         aliases: :f, required: true,
                         desc: "Directories and files that contains the configuration to apply" },
        "global-timeout" => { type: :string, banner: "duration", default: DEFAULT_DEPLOY_TIMEOUT,
                              desc: "Max duration to monitor workloads correctly deployed" },
        "verify-result" => { type: :boolean, default: true,
                             desc: "Verify workloads correctly deployed" },
        "selector" => { type: :string, banner: "'label=value'", required: true,
                        desc: "Select workloads owned by selector(s)" },
        "prune" => { type: :boolean, desc: "Enable deletion of resources that match"\
                     " the provided selector and do not appear in the provided templates",
                     default: true },
      }

      def self.from_options(context, options)
        require 'krane/global_deploy_task'
        require 'krane/options_helper'
        require 'krane/label_selector'
        require 'krane/duration_parser'

        selector = ::Krane::LabelSelector.parse(options[:selector])

        ::Krane::OptionsHelper.with_processed_template_paths(options[:filenames],
          require_explicit_path: true) do |paths|
          deploy = ::Krane::GlobalDeployTask.new(
            context: context,
            filenames: paths,
            global_timeout: ::Krane::DurationParser.new(options["global-timeout"]).parse!.to_i,
            selector: selector,
          )

          deploy.run!(
            verify_result: options["verify-result"],
            prune: options[:prune],
          )
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kubernetes-deploy-0.31.1 lib/krane/cli/global_deploy_command.rb
kubernetes-deploy-0.31.0 lib/krane/cli/global_deploy_command.rb