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_version_tag ⇒ Object
- #create_webhook(webhook_url) ⇒ Object
- #describe_version ⇒ Object
- #publish(*pact_files) ⇒ Object
- #version ⇒ Object
Instance Method Details
#can_i_deploy(*ignored_but_necessary) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/pact_broker/client/cli/broker.rb', line 36 def can_i_deploy(*ignored_but_necessary) 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}, , ) $stdout.puts result. exit(1) unless result.success end |
#create_version_tag ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/pact_broker/client/cli/broker.rb', line 74 def create_version_tag PactBroker::Client::CreateTag.call( .broker_base_url, .pacticipant, .version, , ) end |
#create_webhook(webhook_url) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/pact_broker/client/cli/broker.rb', line 126 def create_webhook webhook_url require 'pact_broker/client/webhooks/create' if !(.contract_content_changed || .provider_verification_published) raise PactBroker::Client::Error.new("You must select at least one of --contract-content-changed or --provider-verification-published") end username = .user ? .user.split(":", 2).first : nil password = .user ? .user.split(":", 2).last : nil headers = (.header || []).each_with_object({}) { | header, headers | headers[header.split(":", 2).first.strip] = header.split(":", 2).last.strip } body = .data if body && body.start_with?("@") filepath = body[1..-1] begin body = File.read(filepath) rescue StandardError => e raise PactBroker::Client::Error.new("Couldn't read data from file \"#{filepath}\" due to #{e.class} #{e.}") end end events = [] events << 'contract_content_changed' if .contract_content_changed events << 'provider_verification_published' if .provider_verification_published params = { http_method: .request, url: webhook_url, headers: headers, username: username, password: password, body: body, consumer: .consumer, provider: .provider, events: events } begin result = PactBroker::Client::Webhooks::Create.call(params, .broker_base_url, ) $stdout.puts result. exit(1) unless result.success rescue PactBroker::Client::Error => e raise WebhookCreationError, "#{e.class} - #{e.}" end end |
#describe_version ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/pact_broker/client/cli/broker.rb', line 94 def describe_version 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 |
#publish(*pact_files) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/pact_broker/client/cli/broker.rb', line 55 def publish(*pact_files) 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 |
#version ⇒ Object
174 175 176 |
# File 'lib/pact_broker/client/cli/broker.rb', line 174 def version $stdout.puts PactBroker::Client::VERSION end |