Class: Command::ApplyTemplate
- Defined in:
- lib/command/apply_template.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- NAME =
"apply-template"- USAGE =
"apply-template TEMPLATE [TEMPLATE] ... [TEMPLATE]"- REQUIRES_ARGS =
true- OPTIONS =
[ app_option(required: true), location_option, skip_confirm_option ].freeze
- DESCRIPTION =
"Applies application-specific configs from templates"- LONG_DESCRIPTION =
"- Applies application-specific configs from templates (e.g., for every review-app)\n- Publishes (creates or updates) those at Control Plane infrastructure\n- Picks templates from the `.controlplane/templates` directory\n- Templates are ordinary Control Plane templates but with variable preprocessing\n\n**Preprocessed template variables:**\n\n```\nAPP_GVC - basically GVC or app name\nAPP_LOCATION - default location\nAPP_ORG - organization\nAPP_IMAGE - will use latest app image\n```\n"- EXAMPLES =
"```sh\n# Applies single template.\ncpl apply-template redis -a $APP_NAME\n\n# Applies several templates (practically creating full app).\ncpl apply-template gvc postgres redis rails -a $APP_NAME\n```\n"
Constants inherited from Base
Base::ACCEPTS_EXTRA_OPTIONS, Base::DEFAULT_ARGS, Base::HIDE, Base::NO_IMAGE_AVAILABLE, Base::WITH_INFO_HEADER
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#call ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity.
Methods inherited from Base
all_commands, all_options, all_options_by_key_name, app_option, #args_join, clean_on_failure_option, commit_option, common_options, #cp, domain_option, #ensure_workload_deleted, #extract_image_commit, image_option, #initialize, #latest_image, #latest_image_from, #latest_image_next, location_option, org_option, #perform, #progress, skip_confirm_option, #step, #step_error, #step_finish, terminal_size_option, trace_option, upstream_token_option, use_local_token_option, verbose_option, version_option, #wait_for_replica, #wait_for_workload, wait_option, workload_option
Methods included from Helpers
#random_four_digits, #strip_str_and_validate
Constructor Details
This class inherits a constructor from Command::Base
Instance Method Details
#call ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/command/apply_template.rb', line 39 def call # rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity ensure_templates! @created_items = [] @failed_templates = [] @skipped_templates = [] @asked_for_confirmation = false pending_templates = templates.select do |template| if template == "gvc" confirm_app(template) else confirm_workload(template) end end progress.puts if @asked_for_confirmation pending_templates.each do |template, filename| step("Applying template '#{template}'", abort_on_error: false) do items = apply_template(filename) if items items.each do |item| report_success(item) end else report_failure(template) end $CHILD_STATUS.success? end end print_created_items print_failed_templates print_skipped_templates end |