Class: PactBroker::Client::CLI::Broker

Inherits:
CustomThor
  • Object
show all
Defined in:
lib/pact_broker/client/cli/broker.rb

Instance Method Summary collapse

Instance Method Details

#can_i_deploy(*ignored_but_necessary) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/pact_broker/client/cli/broker.rb', line 32

def can_i_deploy(*ignored_but_necessary)
  require 'pact_broker/client/cli/version_selector_options_parser'
  require 'pact_broker/client/can_i_deploy'

  validate_credentials
  selectors = VersionSelectorOptionsParser.call(ARGV)
  validate_can_i_deploy_selectors(selectors)
  can_i_deploy_options = { output: options.output, retry_while_unknown: options.retry_while_unknown, retry_interval: options.retry_interval }
  result = CanIDeploy.call(options.broker_base_url, selectors, {to_tag: options.to, limit: options.limit}, can_i_deploy_options, pact_broker_client_options)
  $stdout.puts result.message
  exit(1) unless result.success
end

#create_or_update_pacticipant(*required_but_ignored) ⇒ Object

Raises:

  • (::Thor::RequiredArgumentMissingError)


162
163
164
165
166
167
168
# File 'lib/pact_broker/client/cli/broker.rb', line 162

def create_or_update_pacticipant(*required_but_ignored)
  raise ::Thor::RequiredArgumentMissingError, "Pacticipant name cannot be blank" if options.name.strip.size == 0
  require 'pact_broker/client/pacticipants/create'
  result = PactBroker::Client::Pacticipants2::Create.call({ name: options.name, repository_url: options.repository_url }, options.broker_base_url, pact_broker_client_options)
  $stdout.puts result.message
  exit(1) unless result.success
end

#create_or_update_webhook(webhook_url) ⇒ Object



136
137
138
# File 'lib/pact_broker/client/cli/broker.rb', line 136

def create_or_update_webhook webhook_url
  run_webhook_commands webhook_url
end

#create_version_tagObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/pact_broker/client/cli/broker.rb', line 78

def create_version_tag
  require 'pact_broker/client/create_tag'

  validate_credentials
  PactBroker::Client::CreateTag.call(
    options.broker_base_url,
    options.pacticipant,
    options.version,
    tags,
    options.auto_create_version,
    pact_broker_client_options)
rescue PactBroker::Client::Error => e
  raise VersionCreationError.new(e.message)
end

#create_webhook(webhook_url) ⇒ Object



127
128
129
# File 'lib/pact_broker/client/cli/broker.rb', line 127

def create_webhook webhook_url
  run_webhook_commands webhook_url
end

#describe_versionObject



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/pact_broker/client/cli/broker.rb', line 104

def describe_version
  require 'pact_broker/client/versions/describe'

  validate_credentials
  latest = !options.latest.nil? || (options.latest.nil? && options.version.nil?)
  params = {
    pacticipant: options.pacticipant,
    version: options.version,
    latest: latest,
    tag: options.latest != "latest" ? options.latest : nil
  }
  opts = {
    output: options.output
  }
  result = PactBroker::Client::Versions::Describe.call(params, opts, options.broker_base_url, pact_broker_client_options)
  $stdout.puts result.message
  exit(1) unless result.success
end

#generate_uuidObject



151
152
153
154
155
# File 'lib/pact_broker/client/cli/broker.rb', line 151

def generate_uuid
  require 'securerandom'

  puts SecureRandom.uuid
end

#list_latest_pact_versions(*required_but_ignored) ⇒ Object



173
174
175
176
177
178
# File 'lib/pact_broker/client/cli/broker.rb', line 173

def list_latest_pact_versions(*required_but_ignored)
  require 'pact_broker/client/pacts/list_latest_versions'
  result = PactBroker::Client::Pacts::ListLatestVersions.call(options.broker_base_url, options.output, pact_broker_client_options)
  $stdout.puts result.message
  exit(1) unless result.success
end

#publish(*pact_files) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/pact_broker/client/cli/broker.rb', line 56

def publish(*pact_files)
  require 'pact_broker/client/error'
  validate_credentials
  validate_pact_files(pact_files)
  success = publish_pacts(pact_files)
  raise PactPublicationError, "One or more pacts failed to be published" unless success
rescue PactBroker::Client::Error => e
  raise PactPublicationError, "#{e.class} - #{e.message}"
end

#test_webhookObject



143
144
145
146
147
# File 'lib/pact_broker/client/cli/broker.rb', line 143

def test_webhook
  require 'pact_broker/client/webhooks/test'
  result = PactBroker::Client::Webhooks::Test.call(options, pact_broker_client_options)
  $stdout.puts result.message
end

#versionObject



182
183
184
185
186
# File 'lib/pact_broker/client/cli/broker.rb', line 182

def version
  require 'pact_broker/client/version'

  $stdout.puts PactBroker::Client::VERSION
end