Class: PactBroker::Client::CLI::Broker
- Inherits:
-
CustomThor
- Object
- Thor
- CustomThor
- PactBroker::Client::CLI::Broker
- Defined in:
- lib/pact_broker/client/cli/broker.rb
Instance Method Summary collapse
- #can_i_deploy(*ignored_but_necessary) ⇒ Object
- #create_or_update_pacticipant(*required_but_ignored) ⇒ Object
- #create_or_update_webhook(webhook_url) ⇒ Object
- #create_version_tag ⇒ Object
- #create_webhook(webhook_url) ⇒ Object
- #describe_version ⇒ Object
- #generate_uuid ⇒ Object
- #list_latest_pact_versions(*required_but_ignored) ⇒ Object
- #publish(*pact_files) ⇒ Object
- #test_webhook ⇒ Object
- #version ⇒ Object
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) = { output: .output, retry_while_unknown: .retry_while_unknown, retry_interval: .retry_interval } result = CanIDeploy.call(.broker_base_url, selectors, {to_tag: .to, limit: .limit}, , ) $stdout.puts result. exit(1) unless result.success end |
#create_or_update_pacticipant(*required_but_ignored) ⇒ Object
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 .name.strip.size == 0 require 'pact_broker/client/pacticipants/create' result = PactBroker::Client::Pacticipants2::Create.call({ name: .name, repository_url: .repository_url }, .broker_base_url, ) $stdout.puts result. 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_tag ⇒ Object
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( .broker_base_url, .pacticipant, .version, , .auto_create_version, ) rescue PactBroker::Client::Error => e raise VersionCreationError.new(e.) 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_version ⇒ Object
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 = !.latest.nil? || (.latest.nil? && .version.nil?) params = { pacticipant: .pacticipant, version: .version, latest: latest, tag: .latest != "latest" ? .latest : nil } opts = { output: .output } result = PactBroker::Client::Versions::Describe.call(params, opts, .broker_base_url, ) $stdout.puts result. exit(1) unless result.success end |
#generate_uuid ⇒ Object
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(.broker_base_url, .output, ) $stdout.puts result. 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.}" end |
#test_webhook ⇒ Object
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(, ) $stdout.puts result. end |
#version ⇒ Object
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 |