class HelmWrapper::Tasks::Destroy

Public Class Methods

new(binary:, chart:, options:) { |self| ... } click to toggle source
# File lib/helm-wrapper/tasks/destroy.rb, line 25
def initialize(binary:, chart:, options:)
  @binary  = binary
  @chart   = chart
  @options = options

  yield self if block_given?

  destroy_task
end

Public Instance Methods

destroy_task() click to toggle source
# File lib/helm-wrapper/tasks/destroy.rb, line 37
def destroy_task
  desc "Removes a chart release with Helm for a given configuration."
  task :destroy, [:config] => :binary do |t, args|
    options = @options.merge({"name" => args[:config]})

    logger.info("Processing configuration for Helm destroy...")

    config = HelmWrapper::Shared::Config.new(chart: @chart, options: options)
    runner = HelmWrapper::Shared::Runner.new(binary: @binary, chart: @chart, config: config)

    logger.info("Running Helm delete for release: #{config.release}, namespace: #{config.namespace}...")

    begin
      runner.init_auths
      runner.delete
    ensure
      runner.clean(repos: false)
    end
  end
end