diff options
author | Bobosila Victor <victor.bobosila@puppet.com> | 2021-10-04 12:18:46 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-04 12:18:46 +0300 |
commit | 26387092660c418d49141c60b9ce38f1ceea4749 (patch) | |
tree | 9a767e04e35b160a1b7b891353339cdfdebd7d75 /lib | |
parent | 2062b96f0859713164d3fae1f99715d48f41294f (diff) | |
parent | ed14bbd069d08be4aeb11e3bd723a1d401990ed0 (diff) | |
download | puppet-hosts_core-26387092660c418d49141c60b9ce38f1ceea4749.tar.gz puppet-hosts_core-26387092660c418d49141c60b9ce38f1ceea4749.tar.bz2 |
Merge pull request #30 from BobosilaVictor/MODULES-11197
(MODULES-11197) Update puppetlabs-host_core to the latest pdk template
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/type/host.rb | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/puppet/type/host.rb b/lib/puppet/type/host.rb index 03059b9..7dd7de8 100644 --- a/lib/puppet/type/host.rb +++ b/lib/puppet/type/host.rb @@ -1,9 +1,10 @@ require 'puppet/property/ordered_list' Puppet::Type.newtype(:host) do - @doc = "Installs and manages host entries. For most systems, these - entries will just be in `/etc/hosts`, but some systems (notably OS X) - will have different solutions." + @doc = "@summary Installs and manages host entries. + + For most systems, these entries will just be in `/etc/hosts`, but some + systems (notably OS X) will have different solutions." ensurable @@ -46,15 +47,15 @@ Puppet::Type.newtype(:host) do validate do |value| # This regex already includes newline check. - raise Puppet::Error, _('Host aliases cannot include whitespace') if value =~ %r{\s} - raise Puppet::Error, _('Host aliases cannot be an empty string. Use an empty array to delete all host_aliases ') if value =~ %r{^\s*$} + raise Puppet::Error, _('Host aliases cannot include whitespace') if %r{\s}.match?(value) + raise Puppet::Error, _('Host aliases cannot be an empty string. Use an empty array to delete all host_aliases ') if %r{^\s*$}.match?(value) end end newproperty(:comment) do desc 'A comment that will be attached to the line with a # character.' validate do |value| - if value =~ %r{\n} || value =~ %r{\r} + if value.include?("\n") || value.include?("\r") raise Puppet::Error, _('Comment cannot include newline') end end @@ -80,11 +81,11 @@ Puppet::Type.newtype(:host) do validate do |value| value.split('.').each do |hostpart| - if hostpart !~ %r{^([\w]+|[\w][\w\-]+[\w])$} + unless %r{^([\w]+|[\w][\w\-]+[\w])$}.match?(hostpart) raise Puppet::Error, _('Invalid host name') end end - if value =~ %r{\n} || value =~ %r{\r} + if value.include?("\n") || value.include?("\r") raise Puppet::Error, _('Hostname cannot include newline') end end |