class PactBroker::Client::CreateTag

Attributes

auto_create_version[R]
pact_broker_base_url[R]
pact_broker_client_options[R]
pacticipant_name[R]
tags[R]
version[R]

Public Class Methods

call(pact_broker_base_url, pacticipant_name, version, tags, auto_create_version, pact_broker_client_options={}) click to toggle source
# File lib/pact_broker/client/create_tag.rb, line 9
def self.call(pact_broker_base_url, pacticipant_name, version, tags, auto_create_version, pact_broker_client_options={})
  new(pact_broker_base_url, pacticipant_name, version, tags, auto_create_version, pact_broker_client_options).call
end
new(pact_broker_base_url, pacticipant_name, version, tags, auto_create_version, pact_broker_client_options) click to toggle source
# File lib/pact_broker/client/create_tag.rb, line 13
def initialize(pact_broker_base_url, pacticipant_name, version, tags, auto_create_version, pact_broker_client_options)
  @pact_broker_base_url = pact_broker_base_url
  @pacticipant_name = pacticipant_name
  @version = version
  @tags = tags
  @auto_create_version = auto_create_version
  @pact_broker_client_options = pact_broker_client_options
end

Public Instance Methods

call() click to toggle source
# File lib/pact_broker/client/create_tag.rb, line 22
def call
  ensure_version_exists if !auto_create_version
  tags.each do | tag |
    $stdout.puts "Tagging #{pacticipant_name} version #{version} as #{tag}"
    Retry.while_error do
      pact_broker_client.pacticipants.versions.tag pacticipant: pacticipant_name, version: version, tag: tag
    end
  end
end

Private Instance Methods

ensure_version_exists() click to toggle source
# File lib/pact_broker/client/create_tag.rb, line 40
def ensure_version_exists
  if pact_broker_client.pacticipants.versions.find(pacticipant: pacticipant_name, version: version).nil?
    raise PactBroker::Client::Error.new("Could not create tag. Version #{version} of #{pacticipant_name} does not exist.")
  end
end
pact_broker_client() click to toggle source
# File lib/pact_broker/client/create_tag.rb, line 36
def pact_broker_client
  @pact_broker_client ||= PactBroker::Client::PactBrokerClient.new(base_url: pact_broker_base_url, client_options: pact_broker_client_options)
end