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

Made the Autofs::Mapentry type more permissive #116

Merged
merged 2 commits into from
Apr 2, 2018
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
49 changes: 49 additions & 0 deletions spec/defines/mount_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,55 @@
end
end

context 'with map format option' do
let(:title) { '/data' }
let(:params) do
{
mapfile: 'file,sun:/etc/auto.data',
mapfile_manage: false
}
end

it do
is_expected.to compile
is_expected.to contain_concat(master_map_file)
is_expected.to contain_concat__fragment('autofs::fragment preamble /data file,sun:/etc/auto.data').
with_target(master_map_file).
with_content(%r{\A\s*/data\s+file,sun:/etc/auto.data\s*$})
end
end

context 'with map type and no leading slash' do
# this example is drawn directly from the Linux auto.master(5) manual page
let(:title) { '/mnt' }
let(:params) do
{
mapfile: 'yp:mnt.map',
mapfile_manage: false
}
end

it do
is_expected.to compile
is_expected.to contain_concat(master_map_file)
is_expected.to contain_concat__fragment('autofs::fragment preamble /mnt yp:mnt.map').
with_target(master_map_file).
with_content(%r{\A\s*/mnt\s+yp:mnt.map\s*$})
end
end

context 'with relative map file' do
# This one expects compilation to fail
let(:title) { '/data' }
let(:params) do
{
mapfile: 'etc/auto.data'
}
end

it { is_expected.to compile.and_raise_error(%r{.*}) }
end

context 'with ensure set to absent' do
let(:title) { '/data' }
let(:params) do
Expand Down
9 changes: 6 additions & 3 deletions types/mapentry.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# This type matches a map type and path.
# This type matches a map specfication with map type and optional format,
# or the built-in -hosts map.
# @example program:/etc/auto.smb
# @example file:/etc/auto.file
# @example hosts:-hosts
# @example file,sun:/etc/auto.file
# @example yp:mnt.map
# @example -hosts

type Autofs::Mapentry = Pattern[/^[a-z]+:\/([^\/\0]+(\/)?)+$|^-hosts$/]
type Autofs::Mapentry = Pattern[/\A([a-z]+(,[a-z]+)?:\S+|-hosts)\z/]