Skip to content

Commit

Permalink
Merge pull request #23 from voxpupuli/modulesync
Browse files Browse the repository at this point in the history
modulesync 7.0.0
  • Loading branch information
bastelfreak authored Aug 18, 2023
2 parents 9d74cdd + 95334d2 commit 5a4e5e5
Show file tree
Hide file tree
Showing 11 changed files with 585 additions and 526 deletions.
11 changes: 7 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,21 @@ simple tests against it after applying the module. You can run this
with:

```sh
BEAKER_setfile=debian11-64 bundle exec rake beaker
BEAKER_PUPPET_COLLECTION=puppet7 BEAKER_setfile=debian11-64 bundle exec rake beaker
```

You can replace the string `debian10` with any common operating system.
You can replace the string `debian11` with any common operating system.
The following strings are known to work:

* ubuntu1804
* ubuntu2004
* debian10
* ubuntu2204
* debian11
* centos7
* centos8
* centos9
* almalinux8
* almalinux9
* fedora36

For more information and tips & tricks, see [voxpupuli-acceptance's documentation](https://github.com/voxpupuli/voxpupuli-acceptance#running-tests).

Expand Down
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

modulesync_config_version: '6.0.0'
modulesync_config_version: '7.0.0'
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
inherit_from: .rubocop_todo.yml

# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

Expand Down
63 changes: 63 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-08-17 21:29:37 UTC using RuboCop version 1.50.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowSafeAssignment.
Lint/AssignmentInCondition:
Exclude:
- 'lib/augeasproviders/mounttab/fstab.rb'
- 'lib/augeasproviders/mounttab/vfstab.rb'

# Offense count: 67
# Configuration parameters: CheckForMethodsWithNoSideEffects.
Lint/Void:
Exclude:
- 'spec/unit/puppet/provider/mounttab/fstab_spec.rb'
- 'spec/unit/puppet/provider/mounttab/vfstab_spec.rb'

# Offense count: 4
# Configuration parameters: AssignmentOnly.
RSpec/InstanceVariable:
Exclude:
- 'spec/unit/puppet/provider/mounttab/fstab_spec.rb'
- 'spec/unit/puppet/provider/mounttab/vfstab_spec.rb'

# Offense count: 4
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, conditionals
Style/AndOr:
Exclude:
- 'lib/augeasproviders/mounttab/fstab.rb'
- 'lib/augeasproviders/mounttab/vfstab.rb'
- 'lib/puppet/provider/mounttab/augeas.rb'

# Offense count: 7
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Exclude:
- 'lib/augeasproviders.rb'
- 'lib/augeasproviders/mounttab.rb'
- 'lib/augeasproviders/mounttab/fstab.rb'
- 'lib/augeasproviders/mounttab/vfstab.rb'
- 'lib/puppet/provider/mounttab/augeas.rb'
- 'spec/unit/puppet/provider/mounttab/fstab_spec.rb'
- 'spec/unit/puppet/provider/mounttab/vfstab_spec.rb'

# Offense count: 7
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
Style/StringConcatenation:
Exclude:
- 'lib/augeasproviders/mounttab.rb'
- 'lib/augeasproviders/mounttab/fstab.rb'
- 'lib/augeasproviders/mounttab/vfstab.rb'
- 'lib/puppet/provider/mounttab/augeas.rb'
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
source ENV['GEM_SOURCE'] || 'https://rubygems.org'

group :test do
gem 'voxpupuli-test', '~> 6.0', :require => false
gem 'voxpupuli-test', '~> 7.0', :require => false
gem 'coveralls', :require => false
gem 'simplecov-console', :require => false
gem 'puppet_metadata', '~> 3.0', :require => false
Expand Down
50 changes: 22 additions & 28 deletions lib/augeasproviders/mounttab/fstab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

module AugeasProviders::Mounttab
class Fstab

attr_reader :resource

def self.default_file
Expand All @@ -24,10 +23,11 @@ def self.lens

def self.get_resource(aug, mpath, target)
entry = {
:ensure => :present,
:target => target
ensure: :present,
target: target
}
return nil unless entry[:name] = aug.get("#{mpath}/file")

entry[:device] = aug.get("#{mpath}/spec")
entry[:fstype] = aug.get("#{mpath}/vfstype")

Expand All @@ -46,12 +46,12 @@ def self.get_resource(aug, mpath, target)
end

def self.create(aug, resource)
aug.set("$resource/spec", resource[:device])
aug.set("$resource/file", resource[:name])
aug.set("$resource/vfstype", resource[:fstype])
insoptions(aug, "$resource", resource)
aug.set("$resource/dump", resource[:dump].to_s)
aug.set("$resource/passno", resource[:pass].to_s)
aug.set('$resource/spec', resource[:device])
aug.set('$resource/file', resource[:name])
aug.set('$resource/vfstype', resource[:fstype])
insoptions(aug, '$resource', resource)
aug.set('$resource/dump', resource[:dump].to_s)
aug.set('$resource/passno', resource[:pass].to_s)
end

def self.insoptions(aug, entry, resource)
Expand All @@ -60,20 +60,20 @@ def self.insoptions(aug, entry, resource)
values = resource.original_parameters[:options]

aug.rm("#{entry}/opt")
insafter = "vfstype"
if values and not values.empty?
insafter = 'vfstype'
if values and !values.empty?
[values].flatten.each do |opt|
optk, optv = opt.split("=", 2)
aug.insert("#{entry}/#{insafter}", "opt", false)
optk, optv = opt.split('=', 2)
aug.insert("#{entry}/#{insafter}", 'opt', false)
aug.set("#{entry}/opt[last()]", optk)
aug.set("#{entry}/opt[last()]/value", optv) if optv
insafter = "opt[last()]"
insafter = 'opt[last()]'
end
else
# Strictly this is optional, but only Augeas > 0.10.0 has a lens that
# knows this is the case, so always fill it in.
aug.insert("#{entry}/#{insafter}", "opt", false)
aug.set("#{entry}/opt", "defaults")
aug.insert("#{entry}/#{insafter}", 'opt', false)
aug.set("#{entry}/opt", 'defaults')
end
end

Expand All @@ -84,9 +84,7 @@ def self.dump(aug, resource)
def self.set_dump(aug, resource, value)
# Ensure "defaults" option is always set if dump is being set, as the
# opts field is optional
if aug.match("$target/*[file = '#{resource[:name]}']/opt").empty?
aug.set("$target/*[file = '#{resource[:name]}']/opt", "defaults")
end
aug.set("$target/*[file = '#{resource[:name]}']/opt", 'defaults') if aug.match("$target/*[file = '#{resource[:name]}']/opt").empty?

aug.set("$target/*[file = '#{resource[:name]}']/dump", value.to_s)
end
Expand All @@ -98,24 +96,20 @@ def self.pass(aug, resource)
def self.set_pass(aug, resource, value)
# Ensure "defaults" option is always set if passno is being set, as the
# opts field is optional
if aug.match("$target/*[file = '#{resource[:name]}']/opt").empty?
aug.set("$target/*[file = '#{resource[:name]}']/opt", "defaults")
end
aug.set("$target/*[file = '#{resource[:name]}']/opt", 'defaults') if aug.match("$target/*[file = '#{resource[:name]}']/opt").empty?

# Ensure dump is always set too
if aug.match("$target/*[file = '#{resource[:name]}']/dump").empty?
aug.set("$target/*[file = '#{resource[:name]}']/dump", "0")
end
aug.set("$target/*[file = '#{resource[:name]}']/dump", '0') if aug.match("$target/*[file = '#{resource[:name]}']/dump").empty?

aug.set("$target/*[file = '#{resource[:name]}']/passno", value.to_s)
end

def self.atboot(aug, resource)
def self.atboot(_aug, resource)
resource.should(:atboot)
end

def self.set_atboot(aug, resource, value)
return
def self.set_atboot(_aug, _resource, _value)
nil
end

def self.empty_options
Expand Down
60 changes: 28 additions & 32 deletions lib/augeasproviders/mounttab/vfstab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

module AugeasProviders::Mounttab
class Vfstab

attr_reader :resource

def self.default_file
Expand All @@ -24,14 +23,15 @@ def self.lens

def self.get_resource(aug, mpath, target)
entry = {
:ensure => :present,
:target => target
ensure: :present,
target: target
}
return nil unless entry[:name] = aug.get("#{mpath}/file")

entry[:device] = aug.get("#{mpath}/spec")
entry[:fstype] = aug.get("#{mpath}/vfstype")
entry[:blockdevice] = (aug.get("#{mpath}/fsck") or "-")
entry[:pass] = (aug.get("#{mpath}/passno") or "-")
entry[:blockdevice] = (aug.get("#{mpath}/fsck") or '-')
entry[:pass] = (aug.get("#{mpath}/passno") or '-')
entry[:atboot] = aug.get("#{mpath}/atboot")

options = []
Expand All @@ -42,24 +42,22 @@ def self.get_resource(aug, mpath, target)
options << opt
end
entry[:options] = if options.empty?
"-"
else
options
end
'-'
else
options
end

entry
end

def self.create(aug, resource)
aug.set("$resource/spec", resource[:device])
if resource[:blockdevice] and resource[:blockdevice] != ""
aug.set("$resource/fsck", resource[:blockdevice])
end
aug.set("$resource/file", resource[:name])
aug.set("$resource/vfstype", resource[:fstype])
aug.set("$resource/passno", resource[:pass].to_s) unless resource[:pass] == "-"
aug.set("$resource/atboot", resource[:atboot].to_s)
insoptions(aug, "$resource", resource)
aug.set('$resource/spec', resource[:device])
aug.set('$resource/fsck', resource[:blockdevice]) if resource[:blockdevice] and resource[:blockdevice] != ''
aug.set('$resource/file', resource[:name])
aug.set('$resource/vfstype', resource[:fstype])
aug.set('$resource/passno', resource[:pass].to_s) unless resource[:pass] == '-'
aug.set('$resource/atboot', resource[:atboot].to_s)
insoptions(aug, '$resource', resource)
end

def target
Expand All @@ -72,34 +70,32 @@ def self.insoptions(aug, entry, resource)
values = resource.original_parameters[:options]

aug.rm("#{entry}/opt")
if values and not values.empty?
[values].flatten.each do |opt|
optk, optv = opt.split("=", 2)
aug.set("#{entry}/opt[last()+1]", optk)
aug.set("#{entry}/opt[last()]/value", optv) if optv
end
return unless values and !values.empty?

[values].flatten.each do |opt|
optk, optv = opt.split('=', 2)
aug.set("#{entry}/opt[last()+1]", optk)
aug.set("#{entry}/opt[last()]/value", optv) if optv
end
end

def self.dump(aug, resource)
def self.dump(_aug, resource)
resource.should(:dump)
end

def self.set_dump(aug, resource, value)
return
def self.set_dump(_aug, _resource, _value)
nil
end

def self.pass(aug, resource)
aug.get("$target/*[file = '#{resource[:name]}']/passno") or "-"
aug.get("$target/*[file = '#{resource[:name]}']/passno") or '-'
end

def self.set_pass(aug, resource, value)
if value == "-"
if value == '-'
aug.rm("$target/*[file = '#{resource[:name]}']/passno")
else
if aug.match("$target/*[file = '#{resource[:name]}']/passno").empty?
aug.insert("$target/*[file = '#{resource[:name]}']/vfstype", "passno", false)
end
aug.insert("$target/*[file = '#{resource[:name]}']/vfstype", 'passno', false) if aug.match("$target/*[file = '#{resource[:name]}']/passno").empty?
aug.set("$target/*[file = '#{resource[:name]}']/passno", value.to_s)
end
end
Expand Down
Loading

0 comments on commit 5a4e5e5

Please sign in to comment.