Sha256: 49ef8f94c65ac6babeb7add0274179f31762b38b90c98cd76c8390cb75935af4

Contents?: true

Size: 813 Bytes

Versions: 11

Compression:

Stored size: 813 Bytes

Contents

# frozen_string_literal: true

require 'uri'

# Specify the base URL for PuppetDB. This will generally look like https://puppetdb.yourdomain.com:8081
# @param parser [OptionParser object] The OptionParser argument
# @param options [Hash] Options hash being constructed; this is modified in this method.
OctocatalogDiff::Cli::Options::Option.newoption(:puppetdb_url) do
  has_weight 310

  def parse(parser, options)
    parser.on('--puppetdb-url URL', 'PuppetDB base URL') do |url|
      # Test the format of the incoming URL. Only HTTPS should really be used, but we will
      # support HTTP begrudgingly as well.
      obj = URI.parse(url)
      raise ArgumentError, 'PuppetDB URL must be http or https' unless obj.is_a?(URI::HTTPS) || obj.is_a?(URI::HTTP)
      options[:puppetdb_url] = url
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
octocatalog-diff-1.5.0 lib/octocatalog-diff/cli/options/puppetdb_url.rb
octocatalog-diff-1.4.1 lib/octocatalog-diff/cli/options/puppetdb_url.rb
octocatalog-diff-1.4.0 lib/octocatalog-diff/cli/options/puppetdb_url.rb
octocatalog-diff-1.3.0 lib/octocatalog-diff/cli/options/puppetdb_url.rb
octocatalog-diff-1.2.0 lib/octocatalog-diff/cli/options/puppetdb_url.rb
octocatalog-diff-1.1.0 lib/octocatalog-diff/cli/options/puppetdb_url.rb
octocatalog-diff-1.0.4 lib/octocatalog-diff/cli/options/puppetdb_url.rb
octocatalog-diff-1.0.3 lib/octocatalog-diff/cli/options/puppetdb_url.rb
octocatalog-diff-1.0.2 lib/octocatalog-diff/cli/options/puppetdb_url.rb
octocatalog-diff-1.0.1 lib/octocatalog-diff/cli/options/puppetdb_url.rb
octocatalog-diff-1.0.0 lib/octocatalog-diff/cli/options/puppetdb_url.rb