Class: Command::CopyImageFromUpstream

Inherits:
Base
  • Object
show all
Defined in:
lib/command/copy_image_from_upstream.rb

Constant Summary collapse

NAME =
"copy-image-from-upstream"
OPTIONS =
[
  app_option(required: true),
  upstream_token_option(required: true),
  image_option
].freeze
DESCRIPTION =
"Copies an image (by default the latest) from a source org to the current org"
LONG_DESCRIPTION =
"- Copies an image (by default the latest) from a source org to the current org\n- The source org must be specified through `upstream` in the `.controlplane/controlplane.yml` file\n- Additionally, the token for the source org must be provided through `--upstream-token` or `-t`\n- A `cpln` profile will be temporarily created to pull the image from the source org\n"
EXAMPLES =
"```sh\n# Copies the latest image from the source org to the current org.\ncpl copy-image-from-upstream -a $APP_NAME --upstream-token $UPSTREAM_TOKEN\n\n# Copies a specific image from the source org to the current org.\ncpl copy-image-from-upstream -a $APP_NAME --upstream-token $UPSTREAM_TOKEN --image appimage:123\n```\n"

Constants inherited from Base

Base::DEFAULT_ARGS, Base::HIDE, Base::NO_IMAGE_AVAILABLE, Base::REQUIRES_ARGS, Base::USAGE

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from Base

all_commands, all_options, all_options_by_key_name, app_option, #args_join, commit_option, #cp, #ensure_workload_deleted, image_option, #initialize, #latest_image, #latest_image_from, #latest_image_next, org_option, #perform, #progress, skip_confirm_option, #step, #step_error, #step_finish, terminal_size_option, upstream_token_option, use_local_token_option, version_option, #wait_for_replica, #wait_for_workload, wait_option, workload_option

Constructor Details

This class inherits a constructor from Command::Base

Instance Method Details

#callObject

rubocop:disable Metrics/MethodLength



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/command/copy_image_from_upstream.rb', line 28

def call # rubocop:disable Metrics/MethodLength
  ensure_docker_running!

  @upstream = config[:upstream]
  @upstream_org = config.apps[@upstream.to_sym][:cpln_org]
  ensure_upstream_org!

  create_upstream_profile
  fetch_upstream_image_url
  fetch_app_image_url
  pull_image_from_upstream
  push_image_to_app
ensure
  delete_upstream_profile
end