Sha256: fdc57372413ea5558f75f4939bc9182478f58cdcae80116db258734d5298480f

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

module ThreeScaleToolbox
  module Commands
    module ServiceCommand
      module CopyCommand
        class CopyServiceProxyTask
          include Task

          def call
            target.update_proxy target_proxy_attrs
            target.update_oidc source.oidc if source.attrs['backend_version'] == 'oidc'
            puts "updated proxy of #{target.id} to match the original"
          end

          def target_proxy_attrs
            if source.attrs['deployment_option'] == 'hosted'
              # For services with "hosted" deployment config, 
              # "Public Base URL" should not be copied, mainly because public base URL is self-assigned.
              # Two 3scale products (aka services) cannot be served using the same public base URL.
              source_proxy.dup.delete_if { |key, _v| %w[endpoint sandbox_endpoint].include? key }
            else
              source_proxy
            end
          end

          def source_proxy
            @source_proxy ||= source.proxy
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
3scale_toolbox-0.17.1 lib/3scale_toolbox/commands/service_command/copy_command/copy_service_proxy_task.rb
3scale_toolbox-0.17.0 lib/3scale_toolbox/commands/service_command/copy_command/copy_service_proxy_task.rb