-
Notifications
You must be signed in to change notification settings - Fork 130
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
Fixes #22479 - Handle remote directory with undefined parent #410
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
--- | ||
.travis.yml: | ||
beaker_sets: | ||
- docker/centos-7 | ||
- docker/debian-9 | ||
env: | ||
global: | ||
- PARALLEL_TEST_PROCESSORS=8 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Downloads a file from a URL to a local file given by the title | ||
define foreman_proxy::remote_file( | ||
$remote_location, | ||
$mode='0644', | ||
) { | ||
$parent = dirname($title) | ||
File <| title == $parent |> | ||
-> exec { "mkdir -p ${parent}": | ||
path => ['/bin', '/usr/bin'], | ||
creates => $parent, | ||
} | ||
-> file { $title: | ||
source => $remote_location, | ||
mode => $mode, | ||
replace => false, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'remote_file works' do | ||
let(:pp) do | ||
<<-MANIFEST | ||
foreman_proxy::remote_file { '/var/tmp/test': | ||
remote_location => 'https://codeload.github.com/theforeman/puppet-foreman/tar.gz/9.0.0', | ||
} | ||
MANIFEST | ||
end | ||
|
||
it_behaves_like 'a idempotent resource' | ||
|
||
describe file('/var/tmp/test') do | ||
its(:md5sum) { should eq '5ef89571e3775b4bc17e4f5a55d1c146' } | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,11 +18,12 @@ | |
tftproot = '/var/lib/tftpboot' | ||
end | ||
|
||
it { should contain_foreman_proxy__plugin('discovery') } | ||
it { should contain_foreman_proxy__feature('Discovery') } | ||
|
||
describe 'without paramaters' do | ||
it { should_not contain_foreman__remote_file("#{tftproot}/boot/fdi-image-latest.tar") } | ||
it { should compile.with_all_deps } | ||
it { should contain_foreman_proxy__plugin('discovery') } | ||
it { should contain_foreman_proxy__feature('Discovery') } | ||
it { should_not contain_foreman_proxy__remote_file("#{tftproot}/boot/fdi-image-latest.tar") } | ||
it { should_not contain_exec('untar fdi-image-latest.tar') } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. kind of meta, but I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right. I copied the spec from puppet-foreman and didn't replace it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correction: these was an existing file. I at least wanted to keep it consistent within this file. |
||
end | ||
|
||
describe 'with install_images => true' do | ||
|
@@ -32,8 +33,12 @@ | |
} | ||
end | ||
|
||
it { should compile.with_all_deps } | ||
it { should contain_foreman_proxy__plugin('discovery') } | ||
it { should contain_foreman_proxy__feature('Discovery') } | ||
|
||
it 'should download and install tarball' do | ||
should contain_foreman__remote_file("#{tftproot}/boot/fdi-image-latest.tar"). | ||
should contain_foreman_proxy__remote_file("#{tftproot}/boot/fdi-image-latest.tar"). | ||
with_remote_location('http://downloads.theforeman.org/discovery/releases/latest/fdi-image-latest.tar') | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'spec_helper' | ||
|
||
describe 'foreman_proxy::remote_file' do | ||
let(:title) { '/tmp/a' } | ||
|
||
let(:params) do | ||
{ | ||
remote_location: 'https://example.com/tmp/a', | ||
mode: '0664' | ||
} | ||
end | ||
|
||
context 'default scenario' do | ||
it { is_expected.to contain_exec('mkdir -p /tmp') } | ||
|
||
it do | ||
is_expected.to contain_file('/tmp/a') | ||
.with_source('https://example.com/tmp/a') | ||
.with_mode('0664') | ||
.that_requires('Exec[mkdir -p /tmp]') | ||
end | ||
end | ||
|
||
context 'with parent file defined' do | ||
let :pre_condition do | ||
"file { '/tmp': }" | ||
end | ||
|
||
it { is_expected.to contain_exec('mkdir -p /tmp').that_requires('File[/tmp]') } | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, forgot about that 👍