Sha256: 5afd24888bded8d7c291bda333f014e579ba2723cf9860b059ed6cf151eee542

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require 'avrolution/rake/base_task'

module Avrolution
  module Rake
    class AddCompatibilityBreakTask < BaseTask

      def initialize(*)
        super
        @name ||= :add_compatibility_break
        @task_desc ||= 'Add an Avro schema compatibility break. Parameters: name, fingerprint, ' \
          'with_compatibility, after_compatibility'
      end

      private

      def perform
        compatibility_break_args = ENV.to_h.slice(
          'name', 'fingerprint', 'with_compatibility', 'after_compatibility'
        ).symbolize_keys

        missing_args = [:name, :fingerprint].select do |arg|
          compatibility_break_args[arg].blank?
        end

        if missing_args.any?
          puts missing_args.map { |arg| "#{arg} can't be blank" }.join(', ')
          puts 'Usage: rake avro:add_compatibility_break name=<name> fingerprint=<fingerprint> ' \
            '[with_compatibility=<default:NONE>] [after_compatibility=<compatibility>]'
          exit(1)
        end

        Avrolution::CompatibilityBreaksFile.add(**compatibility_break_args)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
avrolution-0.7.0 lib/avrolution/rake/add_compatibility_break_task.rb