Sha256: 604e8e105b45a53095aeabda703812502f2440ed6be67aaa4334a35e2f2f41c1

Contents?: true

Size: 702 Bytes

Versions: 4

Compression:

Stored size: 702 Bytes

Contents

require 'krane'
require 'kubectl-rb'

module Kuby
  module Kubernetes
    class DeployTask
      attr_reader :deploy_task

      def initialize(**kwargs)
        @deploy_task ||= ::Krane::DeployTask.new(**kwargs)
      end

      def run!(**kwargs)
        new_path = "#{File.dirname(KubectlRb.executable)}:#{ENV['PATH']}"

        with_env('PATH' => new_path) do
          deploy_task.run!(**kwargs)
        end
      end

      def logger
        deploy_task.instance_variable_get(:@logger)
      end

      private

      def with_env(new_env)
        old_env = ENV.to_h
        ENV.replace(old_env.merge(new_env))
        yield
      ensure
        ENV.replace(old_env)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kuby-core-0.10.1 lib/kuby/kubernetes/deploy_task.rb
kuby-core-0.10.0 lib/kuby/kubernetes/deploy_task.rb
kuby-core-0.9.1 lib/kuby/kubernetes/deploy_task.rb
kuby-core-0.9.0 lib/kuby/kubernetes/deploy_task.rb