Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
language: ruby
install: true
script: "script/cibuild"
dist: precise

before_install:
- gem install bundler -v 1.15.4

matrix:
include:
# Build with latest ruby
- rvm: 2.4.1
- rvm: 2.4
env: RUBOCOP_TEST="true" RSPEC_TEST="true"
# Build with older ruby versions
- rvm: 2.3.4
- rvm: 2.3.2
env: RUBOCOP_TEST="false" RSPEC_TEST="true"
- rvm: 2.2
- rvm: 2.2.3
env: RUBOCOP_TEST="false" RSPEC_TEST="true"
- rvm: 2.1
env: RUBOCOP_TEST="false" RSPEC_TEST="true"
Expand Down
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.0
1.4.1
7 changes: 7 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
</tr>
</thead><tbody>
<tr valign=top>
<td>1.4.1</td>
<td>2017-10-02</td>
<td>
<li><a href="https://github.com/github/octocatalog-diff/pull/149">#149</a>: (Internal) Set ports on PuppetDB URLs without altering constants</li>
</td>
</tr>
<tr valign=top>
<td>1.4.0</td>
<td>2017-08-03</td>
<td>
Expand Down
18 changes: 9 additions & 9 deletions lib/octocatalog-diff/puppetdb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@

require 'uri'

# Redefine constants to match PuppetDB defaults.
# This code avoids warnings about redefining constants.
URI::HTTP.send(:remove_const, :DEFAULT_PORT) if URI::HTTP.const_defined?(:DEFAULT_PORT)
URI::HTTP.const_set(:DEFAULT_PORT, 8080)
URI::HTTPS.send(:remove_const, :DEFAULT_PORT) if URI::HTTPS.const_defined?(:DEFAULT_PORT)
URI::HTTPS.const_set(:DEFAULT_PORT, 8081)

module OctocatalogDiff
# A standard way to connect to PuppetDB from the various scripts in this repository.
class PuppetDB
DEFAULT_HTTPS_PORT = 8081
DEFAULT_HTTP_PORT = 8080

# Allow connections to be read (used in tests for now)
attr_reader :connections

Expand Down Expand Up @@ -54,7 +50,7 @@ def initialize(options = {})
urls.map { |url| parse_url(url) }
elsif options.key?(:puppetdb_host)
is_ssl = options.fetch(:puppetdb_ssl, true)
default_port = is_ssl ? URI::HTTPS::DEFAULT_PORT : URI::HTTP::DEFAULT_PORT
default_port = is_ssl ? DEFAULT_HTTPS_PORT : DEFAULT_HTTP_PORT
port = options.fetch(:puppetdb_port, default_port).to_i
[{ ssl: is_ssl, host: options[:puppetdb_host], port: port }]
elsif ENV['PUPPETDB_URL'] && !ENV['PUPPETDB_URL'].empty?
Expand All @@ -64,7 +60,7 @@ def initialize(options = {})
# This will get the env var and see if it equals 'true'; the result
# of this == comparison is the true/false boolean we need.
is_ssl = ENV.fetch('PUPPETDB_SSL', 'true') == 'true'
default_port = is_ssl ? URI::HTTPS::DEFAULT_PORT : URI::HTTP::DEFAULT_PORT
default_port = is_ssl ? DEFAULT_HTTPS_PORT : DEFAULT_HTTP_PORT
port = ENV.fetch('PUPPETDB_PORT', default_port).to_i
[{ ssl: is_ssl, host: ENV['PUPPETDB_HOST'], port: port }]
else
Expand Down Expand Up @@ -152,6 +148,10 @@ def _get(path)
# @return [Hash] { ssl: true/false, host: <String>, port: <Integer> }
def parse_url(url)
uri = URI(url)
if URI.split(url)[3].nil?
uri.port = uri.scheme == 'https' ? DEFAULT_HTTPS_PORT : DEFAULT_HTTP_PORT
end

raise ArgumentError, "URL #{url} has invalid scheme" unless uri.scheme =~ /^https?$/
{ ssl: uri.scheme == 'https', host: uri.host, port: uri.port }
rescue URI::InvalidURIError => exc
Expand Down
3 changes: 2 additions & 1 deletion octocatalog-diff.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_relative 'lib/octocatalog-diff/version'
require 'json'

DEFAULT_PUPPET_VERSION = '4.10.0'.freeze
DEFAULT_PUPPET_VERSION = '4.10.8'.freeze

Gem::Specification.new do |s|
s.required_ruby_version = '>= 2.0.0'
Expand Down Expand Up @@ -30,6 +30,7 @@ EOF
s.add_runtime_dependency 'hashdiff', '>= 0.3.0'
s.add_runtime_dependency 'rugged', '>= 0.25.0b2'

s.add_development_dependency 'bundler', '1.15.4'
s.add_development_dependency 'rspec', '~> 3.4.0'
s.add_development_dependency 'rake', '11.2.2'
s.add_development_dependency 'parallel_tests', '2.7.1'
Expand Down
6 changes: 0 additions & 6 deletions script/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ echo 'Starting script/bootstrap'

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"

# FIXME: Remove when CI is switched to Travis
if env | grep ^JANKY_ >/dev/null 2>&1 ; then
export PATH=/usr/share/rbenv/shims:$PATH
export RBENV_VERSION=2.1.2-github
fi

rm -rf "${DIR}/.bundle"
rm -f "${DIR}/.puppet_version"
set -e
Expand Down
8 changes: 7 additions & 1 deletion script/cibuild
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,27 @@
# with one or more Puppet versions, with PUPPET_VERSIONS set to a space-separated list
# of versions to test.

[ -z "$PUPPET_VERSIONS" ] && export PUPPET_VERSIONS='3.8.7 4.10.0 5.0.0'
[ -z "$PUPPET_VERSIONS" ] && export PUPPET_VERSIONS='3.8.7 4.10.8 5.0.0'
[ -z "$RUBOCOP_TEST" ] && export RUBOCOP_TEST='true'
[ -z "$RSPEC_TEST" ] && export RSPEC_TEST='true'

echo 'Starting script/cibuild'

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"
env

# Create a temporary file to capture output of various steps.
export OUTPUT_FILE="$(mktemp)"
function cleanup() {
rm -rf "$OUTPUT_FILE"
rm -f "${DIR}/.ruby-version"
}
trap cleanup EXIT

# Create "$DIR/.ruby-version" from the current ruby version, so it propagates through
# to the clean environment under which Puppet runs.
ruby -e "print RUBY_VERSION" > "${DIR}/.ruby-version"

# Bootstrapping
function bootstrap() {
echo "Bootstrapping..."
Expand Down
Binary file added vendor/cache/bundler-1.15.4.gem
Binary file not shown.
Binary file removed vendor/cache/facter-2.4.6-universal-darwin.gem
Binary file not shown.
Binary file removed vendor/cache/facter-2.4.6.gem
Binary file not shown.
Binary file added vendor/cache/facter-2.5.1-universal-darwin.gem
Binary file not shown.
Binary file added vendor/cache/facter-2.5.1.gem
Binary file not shown.
Binary file removed vendor/cache/gettext-setup-0.25.gem
Binary file not shown.
Binary file added vendor/cache/gettext-setup-0.26.gem
Binary file not shown.
Binary file removed vendor/cache/httparty-0.15.5.gem
Binary file not shown.
Binary file added vendor/cache/httparty-0.15.6.gem
Binary file not shown.
Binary file removed vendor/cache/parallel-1.11.2.gem
Binary file not shown.
Binary file added vendor/cache/parallel-1.12.0.gem
Binary file not shown.
Binary file removed vendor/cache/puppet-4.10.0-universal-darwin.gem
Binary file not shown.
Binary file removed vendor/cache/puppet-4.10.0.gem
Binary file not shown.
Binary file added vendor/cache/puppet-4.10.8-universal-darwin.gem
Binary file not shown.
Binary file added vendor/cache/puppet-4.10.8.gem
Binary file not shown.
Binary file added vendor/cache/rugged-0.26.0.gem
Binary file not shown.
Binary file removed vendor/cache/rugged-0.26.0b5.gem
Binary file not shown.