Skip to content

Commit 2848711

Browse files
committed
Make docker::machine::url configurable
As docker machine is now in maintanence mode [1] there are forks of it where people might want to download the binary from. [1]: docker/machine#4537
1 parent f41f16c commit 2848711

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

manifests/machine.pp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@
2020
# [*proxy*]
2121
# Proxy to use for downloading Docker Machine.
2222
#
23+
# [*url*]
24+
# The URL from which the docker machine binary should be fetched
25+
# Defaults to a auto determined value based on version, kernel and OS.
2326
class docker::machine(
24-
Optional[Pattern[/^present$|^absent$/]] $ensure = 'present',
25-
Optional[String] $version = $docker::params::machine_version,
26-
Optional[String] $install_path = $docker::params::machine_install_path,
27-
Optional[String] $proxy = undef
27+
Optional[Pattern[/^present$|^absent$/]] $ensure = 'present',
28+
Optional[String] $version = $docker::params::machine_version,
29+
Optional[String] $install_path = $docker::params::machine_install_path,
30+
Optional[String] $proxy = undef,
31+
Optional[Variant[Stdlib::HTTPUrl, Stdlib::HTTPSUrl]] $url = undef,
2832
) inherits docker::params {
2933

3034
if $proxy != undef {
@@ -43,7 +47,10 @@
4347
$docker_machine_location_versioned = "${install_path}/docker-machine-${version}${file_extension}"
4448

4549
if $ensure == 'present' {
46-
$docker_machine_url = "https://github.com/docker/machine/releases/download/v${version}/docker-machine-${::kernel}-x86_64${file_extension}"
50+
$docker_machine_url = $url ? {
51+
undef => "https://github.com/docker/machine/releases/download/v${version}/docker-machine-${::kernel}-x86_64${file_extension}",
52+
default => $url,
53+
}
4754

4855
if $proxy != undef {
4956
$proxy_opt = "--proxy ${proxy}"

spec/classes/machine_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,20 @@
113113
)
114114
}
115115
end
116+
117+
context 'with docker_machine_url is provided' do
118+
let(:params) do
119+
{
120+
version: '0.16.2',
121+
url: 'https://gitlab-docker-machine-downloads.s3.amazonaws.com/v0.16.2-gitlab.3/docker-machine',
122+
}
123+
end
124+
125+
it { is_expected.to compile }
126+
it {
127+
is_expected.to contain_exec('Install Docker Machine 0.16.2').with_command(
128+
'curl -s -S -L https://gitlab-docker-machine-downloads.s3.amazonaws.com/v0.16.2-gitlab.3/docker-machine -o /usr/local/bin/docker-machine-0.16.2',
129+
)
130+
}
131+
end
116132
end

0 commit comments

Comments
 (0)