Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to override docker-compose download location #482

Merged
merged 8 commits into from
Jul 15, 2019
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
22 changes: 20 additions & 2 deletions manifests/compose.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,24 @@
# [*proxy*]
# Proxy to use for downloading Docker Compose.
#
# [*base_url*]
# The base url for installation
# This allows use of a mirror that follows the same layout as the
# official repository
#
# [*raw_url*]
# Override the raw URL for installation
# The default is to build a URL from baseurl. If rawurl is set, the caller is
# responsible for ensuring the URL points to the correct version and
# architecture.

class docker::compose(
Optional[Pattern[/^present$|^absent$/]] $ensure = 'present',
Optional[String] $version = $docker::params::compose_version,
Optional[String] $install_path = $docker::params::compose_install_path,
Optional[String] $proxy = undef
Optional[String] $proxy = undef,
Optional[String] $base_url = $docker::params::compose_base_url,
Optional[String] $raw_url = undef
) inherits docker::params {

if $proxy != undef {
Expand All @@ -43,7 +56,12 @@
$docker_compose_location_versioned = "${install_path}/docker-compose-${version}${file_extension}"

if $ensure == 'present' {
$docker_compose_url = "https://github.com/docker/compose/releases/download/${version}/docker-compose-${::kernel}-x86_64${file_extension}"

if $raw_url != undef {
$docker_compose_url = $raw_url
} else {
$docker_compose_url = "${base_url}/${version}/docker-compose-${::kernel}-x86_64${file_extension}"
}

if $proxy != undef {
$proxy_opt = "--proxy ${proxy}"
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
$dns = undef
$dns_search = undef
$proxy = undef
$compose_base_url = 'https://github.com/docker/compose/releases/download'
$no_proxy = undef
$execdriver = undef
$storage_driver = undef
Expand Down
28 changes: 28 additions & 0 deletions spec/classes/compose_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,32 @@
)
}
end

context 'when base_url is provided' do
let(:params) do
{ base_url: 'http://example.org',
version: '1.7.0' }
end

it { is_expected.to compile }
it {
is_expected.to contain_exec('Install Docker Compose 1.7.0').with_command(
'curl -s -S -L http://example.org/1.7.0/docker-compose-Linux-x86_64 -o /usr/local/bin/docker-compose-1.7.0',
)
}
end

context 'when raw_url is provided' do
let(:params) do
{ raw_url: 'http://example.org',
version: '1.7.0' }
end

it { is_expected.to compile }
it {
is_expected.to contain_exec('Install Docker Compose 1.7.0').with_command(
'curl -s -S -L http://example.org -o /usr/local/bin/docker-compose-1.7.0',
)
}
end
end