Sha256: bc85155f23c81542adeb5b31ca89b85f0c2e6fcf9255d249a2d6bd581f2adfdc

Contents?: true

Size: 1.07 KB

Versions: 7

Compression:

Stored size: 1.07 KB

Contents

module ThreeScaleToolbox
  module Tasks
    class CopyServiceSettingsTask
      include CopyTask
      PARAMS_FILTER = %w[system_name id links]

      def call
        svc_obj = update_service source_service_settings
        if (errors = svc_obj['errors'])
          raise ThreeScaleToolbox::Error, "Service has not been saved. Errors: #{errors}" \
        end

        puts "updated service settings for service id #{source.id}..."
      end

      private

      def source_service_settings
        source.attrs.reject { |k, _| PARAMS_FILTER.include? k }
      end

      def update_service(service_attrs)
        svc_obj = target.update service_attrs

        # Source and target remotes might not allow same set of deployment options
        # Invalid deployment option check
        # use default deployment_option
        if (errors = svc_obj['errors']) &&
           ThreeScaleToolbox::Helper.service_invalid_deployment_option?(errors)
          service_attrs.delete('deployment_option')
          svc_obj = target.update service_attrs
        end

        svc_obj
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
3scale_toolbox-0.15.0 lib/3scale_toolbox/tasks/copy_service_settings_task.rb
3scale_toolbox-0.14.0 lib/3scale_toolbox/tasks/copy_service_settings_task.rb
3scale_toolbox-0.13.0 lib/3scale_toolbox/tasks/copy_service_settings_task.rb
3scale_toolbox-0.12.4 lib/3scale_toolbox/tasks/copy_service_settings_task.rb
3scale_toolbox-0.12.3 lib/3scale_toolbox/tasks/copy_service_settings_task.rb
3scale_toolbox-0.12.2 lib/3scale_toolbox/tasks/copy_service_settings_task.rb
3scale_toolbox-0.11.0 lib/3scale_toolbox/tasks/copy_service_settings_task.rb