From 36a46c84de29e127dee95ebd5caa992ac39046b6 Mon Sep 17 00:00:00 2001 From: Bobosila Victor Date: Sat, 25 Sep 2021 13:15:58 +0300 Subject: (MODULES-11197) Rubocop fixes --- lib/puppet/type/host.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/puppet/type/host.rb') diff --git a/lib/puppet/type/host.rb b/lib/puppet/type/host.rb index 03059b9..0510180 100644 --- a/lib/puppet/type/host.rb +++ b/lib/puppet/type/host.rb @@ -46,8 +46,8 @@ 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 @@ -80,7 +80,7 @@ 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 -- cgit v1.2.3 From 725d4693895c6ec060b16428a918d4cecb85ae2f Mon Sep 17 00:00:00 2001 From: Gabriel Nagy Date: Fri, 1 Oct 2021 14:43:35 +0300 Subject: (MODULES-8183) REFERENCE.md ToC fixes --- REFERENCE.md | 38 +++++++++++++++++++++++--------------- lib/puppet/type/host.rb | 7 ++++--- 2 files changed, 27 insertions(+), 18 deletions(-) (limited to 'lib/puppet/type/host.rb') diff --git a/REFERENCE.md b/REFERENCE.md index 613a4df..4f5a401 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -1,44 +1,44 @@ # Reference + ## Table of Contents -**Resource types** +### Resource types -* [`host`](#host): Installs and manages host entries. For most systems, these entries will just be in `/etc/hosts`, but some systems (notably OS X) will have d +* [`host`](#host): Installs and manages host entries. ## Resource types -### host +### `host` -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. +For most systems, these entries will just be in `/etc/hosts`, but some +systems (notably OS X) will have different solutions. #### Properties The following properties are available in the `host` type. -##### `ensure` +##### `comment` -Valid values: present, absent +A comment that will be attached to the line with a # character. -The basic property that the resource should be in. +##### `ensure` -Default value: present +Valid values: `present`, `absent` -##### `ip` +The basic property that the resource should be in. -The host's IP address, IPv4 or IPv6. +Default value: `present` ##### `host_aliases` Any aliases the host might have. Multiple values must be specified as an array. -##### `comment` +##### `ip` -A comment that will be attached to the line with a # character. +The host's IP address, IPv4 or IPv6. ##### `target` @@ -49,9 +49,17 @@ those providers that write to disk. On most systems this defaults to `/etc/hosts The following parameters are available in the `host` type. -##### `name` +* [`name`](#name) +* [`provider`](#provider) + +##### `name` namevar The host name. +##### `provider` + +The specific backend to use for this `host` resource. You will seldom need to specify this --- Puppet will usually +discover the appropriate provider for your platform. + diff --git a/lib/puppet/type/host.rb b/lib/puppet/type/host.rb index 0510180..0e7a21c 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 -- cgit v1.2.3 From ed14bbd069d08be4aeb11e3bd723a1d401990ed0 Mon Sep 17 00:00:00 2001 From: Gabriel Nagy Date: Fri, 1 Oct 2021 14:50:02 +0300 Subject: (MODULES-11197) Reenable some cops --- .rubocop.yml | 24 +++++++----------------- .sync.yml | 18 ------------------ lib/puppet/type/host.rb | 4 ++-- 3 files changed, 9 insertions(+), 37 deletions(-) (limited to 'lib/puppet/type/host.rb') diff --git a/.rubocop.yml b/.rubocop.yml index de02624..3a8c20a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -72,24 +72,8 @@ Style/TrailingCommaInArrayLiteral: Style/SymbolArray: Description: Using percent style obscures symbolic intent of array's contents. EnforcedStyle: brackets -Style/SignalException: - Enabled: false -Style/DoubleNegation: - Enabled: false -Style/MultipleComparison: - Enabled: false -Style/NumericPredicate: - Enabled: false Layout/HeredocIndentation: Enabled: false -Metrics/BlockNesting: - Enabled: false -Naming/AccessorMethodName: - Enabled: false -Naming/PredicateName: - Enabled: false -RSpec/VariableName: - Enabled: false RSpec/MessageSpies: EnforcedStyle: receive Style/Documentation: @@ -121,7 +105,7 @@ Performance/SortReverse: Performance/Squeeze: Enabled: true Performance/StringInclude: - Enabled: false + Enabled: true Performance/Sum: Enabled: true Style/CollectionMethods: @@ -258,6 +242,8 @@ Metrics/AbcSize: Enabled: false Metrics/BlockLength: Enabled: false +Metrics/BlockNesting: + Enabled: false Metrics/ClassLength: Enabled: false Metrics/CyclomaticComplexity: @@ -272,6 +258,8 @@ Metrics/PerceivedComplexity: Enabled: false Migration/DepartmentName: Enabled: false +Naming/AccessorMethodName: + Enabled: false Naming/BlockParameterName: Enabled: false Naming/HeredocDelimiterCase: @@ -444,6 +432,8 @@ Style/MultilineWhenThen: Enabled: false Style/NegatedUnless: Enabled: false +Style/NumericPredicate: + Enabled: false Style/OptionalBooleanParameter: Enabled: false Style/OrAssignment: diff --git a/.sync.yml b/.sync.yml index ee6e834..7df0056 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,27 +1,9 @@ .rubocop.yml: default_configs: - Style/SignalException: - Enabled: false - Style/DoubleNegation: - Enabled: false - Style/MultipleComparison: - Enabled: false - Style/NumericPredicate: - Enabled: false - Style/SignalException: - Enabled: false Layout/HeredocIndentation: Enabled: false Layout/LineLength: Enabled: false - Metrics/BlockNesting: - Enabled: false - Naming/AccessorMethodName: - Enabled: false - Naming/PredicateName: - Enabled: false - RSpec/VariableName: - Enabled: false Gemfile: optional: ":development": diff --git a/lib/puppet/type/host.rb b/lib/puppet/type/host.rb index 0e7a21c..7dd7de8 100644 --- a/lib/puppet/type/host.rb +++ b/lib/puppet/type/host.rb @@ -55,7 +55,7 @@ Puppet::Type.newtype(:host) do 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 @@ -85,7 +85,7 @@ Puppet::Type.newtype(:host) do 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 -- cgit v1.2.3