Skip to content

Commit

Permalink
feat(cli): add generate-uuid command for use when using create-or-upd…
Browse files Browse the repository at this point in the history
…ate-webhook
  • Loading branch information
bethesque committed Feb 13, 2020
1 parent 32f6c4c commit 52824fb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/pact_broker/client/cli/broker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ def create_or_update_webhook webhook_url
run_webhook_commands webhook_url
end

ignored_potential_options_from_environment_variables
desc 'generate-uuid', 'Generate a UUID for use when calling create-or-update-webhook'
def generate_uuid
require 'securerandom'
puts SecureRandom.uuid
end

desc 'version', "Show the pact_broker-client gem version"
def version
$stdout.puts PactBroker::Client::VERSION
Expand Down
10 changes: 10 additions & 0 deletions lib/pact_broker/client/cli/custom_thor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ def self.turn_muliple_tag_options_into_array argv
new_argv.flatten
end

# If you try and generate a uuid, and the PACT_BROKER_... env vars are set, it will cause
# generate_uuid to be called with parameters that it doesn't declare, and hence, throw an error.
# This is a dirty hack that stops that happening!
def self.ignored_potential_options_from_environment_variables
method_option :broker_base_url, hide: true
method_option :broker_username, hide: true
method_option :broker_password, hide: true
method_option :broker_token, hide: true
end

def self.shared_options_for_webhook_commands
method_option :request, banner: "METHOD", aliases: "-X", desc: "HTTP method", required: true
method_option :header, aliases: "-H", type: :array, desc: "Header"
Expand Down

0 comments on commit 52824fb

Please sign in to comment.