Sha256: bb24ad312c5f38f7500473029fff67a76a9755d4eea74bac4f2515b97da6c2ba

Contents?: true

Size: 1.18 KB

Versions: 14

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Command
  class DeployImage < Base
    NAME = "deploy-image"
    OPTIONS = [
      app_option(required: true)
    ].freeze
    DESCRIPTION = "Deploys the latest image to app workloads"
    LONG_DESCRIPTION = <<~DESC
      - Deploys the latest image to app workloads
    DESC

    def call # rubocop:disable Metrics/MethodLength
      deployed_endpoints = {}

      image = latest_image

      config[:app_workloads].each do |workload|
        workload_data = cp.fetch_workload!(workload)
        workload_data.dig("spec", "containers").each do |container|
          next unless container["image"].match?(%r{^/org/#{config.org}/image/#{config.app}:})

          container_name = container["name"]
          step("Deploying image '#{image}' for workload '#{container_name}'") do
            cp.workload_set_image_ref(workload, container: container_name, image: image)
            deployed_endpoints[container_name] = workload_data.dig("status", "endpoint")
          end
        end
      end

      progress.puts("\nDeployed endpoints:")
      deployed_endpoints.each do |workload, endpoint|
        progress.puts("  - #{workload}: #{endpoint}")
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
cpl-1.3.0 lib/command/deploy_image.rb
cpl-1.2.0 lib/command/deploy_image.rb
cpl-1.1.2 lib/command/deploy_image.rb
cpl-1.1.2.rc.0 lib/command/deploy_image.rb
cpl-1.1.1 lib/command/deploy_image.rb
cpl-1.1.0 lib/command/deploy_image.rb
cpl-1.0.4 lib/command/deploy_image.rb
cpl-1.0.3 lib/command/deploy_image.rb
cpl-1.0.2 lib/command/deploy_image.rb
cpl-1.0.1 lib/command/deploy_image.rb
cpl-1.0.0 lib/command/deploy_image.rb
cpl-0.7.0 lib/command/deploy_image.rb
cpl-0.6.0 lib/command/deploy_image.rb
cpl-0.5.1 lib/command/deploy_image.rb