Class: ThreeScaleToolbox::Commands::ProductCommand::ImportSubcommand

Inherits:
Cri::CommandRunner
  • Object
show all
Includes:
ThreeScaleToolbox::Command, ResourceReader
Defined in:
lib/3scale_toolbox/commands/product_command/import_command.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ResourceReader

#load_resource, #read_content, #read_file, #read_stdin, #read_url

Methods included from ThreeScaleToolbox::Command

#config, #config_file, #exit_with_message, #fetch_required_option, included, #remotes, #threescale_client, #verbose, #verify_ssl

Class Method Details

.commandObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/3scale_toolbox/commands/product_command/import_command.rb', line 8

def self.command
  Cri::Command.define do
    name        'import'
    usage       'import [opts] <remote>'
    summary     'Import product from serialized format'
    description 'This command deserializes one product and associated backends'

    option      :f, :file, 'Read from file instead of stdin', argument: :required
    ThreeScaleToolbox::CLI.output_flag(self)
    param       :remote

    runner ImportSubcommand
  end
end

Instance Method Details

#runObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/3scale_toolbox/commands/product_command/import_command.rb', line 23

def run
  validate_artifacts_resource!

  product_list.each do |product|
    context = {
        target_remote: remote,
        source_remote: crd_remote,
        source_service_ref: product.system_name,
        delete_mapping_rules: true,
        logger: Logger.new(File::NULL)
    }

    Commands::ProductCommand::CopySubcommand.workflow(context)

    report[product.system_name] = context.fetch(:report)
  end

  printer.print_collection report
end