Class: HelmWrapper::Tasks::Push

Inherits:
Rake::TaskLib
  • Object
show all
Includes:
Shared::Logging
Defined in:
lib/helm-wrapper/tasks/push.rb

Instance Method Summary collapse

Methods included from Shared::Logging

configure_logger_for, logger_for

Constructor Details

#initialize(binary:, chart:, destination:) {|_self| ... } ⇒ Push

Returns a new instance of Push.

Yields:

  • (_self)

Yield Parameters:



25
26
27
28
29
30
31
32
33
# File 'lib/helm-wrapper/tasks/push.rb', line 25

def initialize(binary:, chart:, destination:)
  @binary      = binary
  @chart       = chart
  @destination = destination

  yield self if block_given?

  push_task
end

Instance Method Details

#push_taskObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/helm-wrapper/tasks/push.rb', line 37

def push_task
  desc "Pushes a Helm chart to an OCI Helm repository."
  task :push, [:clean] => :binary do |t, args|
    clean = args[:clean].kind_of?(String) ? args[:clean].downcase == "true" : true

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

    logger.info("Running Helm push for path: #{@chart.path}...")

    begin
      runner.init_repos
      runner.package
      runner.push(destination: @destination)
    ensure
      runner.clean(repos: clean)
    end
  end
end