Skip to content

Commit

Permalink
Merge pull request #116 from jcbollinger/mapentry_fix
Browse files Browse the repository at this point in the history
Made the Autofs::Mapentry type more permissive
  • Loading branch information
dhollinger authored Apr 2, 2018
2 parents 87be9dc + 9aa15f4 commit 490888b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 3 deletions.
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/]

0 comments on commit 490888b

Please sign in to comment.