diff options
author | antima-gupta <agupta@msystechnologies.com> | 2020-11-11 03:30:33 -0800 |
---|---|---|
committer | antima-gupta <agupta@msystechnologies.com> | 2020-11-11 03:45:31 -0800 |
commit | f913aa17ecf387a62e38699854a4faba7e8030f6 (patch) | |
tree | 6b7a344650617f1a4bba25810d9ad1f42a4523b0 | |
parent | 159cb08880750fd72994ba69ca5e244b558a8bcc (diff) | |
download | chef-f913aa17ecf387a62e38699854a4faba7e8030f6.tar.gz |
Removed '/' from mount_point property.
Added mount_options method to remove leading and trailing whitespace from the options value.
Fixed chefstyle spec failure.
Signed-off-by: antima-gupta <agupta@msystechnologies.com>
-rw-r--r-- | lib/chef/provider/mount.rb | 2 | ||||
-rw-r--r-- | lib/chef/provider/mount/linux.rb | 2 | ||||
-rw-r--r-- | lib/chef/resource/mount.rb | 8 |
3 files changed, 9 insertions, 3 deletions
diff --git a/lib/chef/provider/mount.rb b/lib/chef/provider/mount.rb index e4592a810d..f8c71c6706 100644 --- a/lib/chef/provider/mount.rb +++ b/lib/chef/provider/mount.rb @@ -175,7 +175,7 @@ class Chef # Returns the new_resource device as per device_type def device_fstab - # Removed "/" from the end of str, because it was causing idempotency issues + # Removed "/" from the end of str, because it was causing idempotency issue. device = @new_resource.device.chomp("/") case @new_resource.device_type when :device diff --git a/lib/chef/provider/mount/linux.rb b/lib/chef/provider/mount/linux.rb index 260c8f9349..382e37d41a 100644 --- a/lib/chef/provider/mount/linux.rb +++ b/lib/chef/provider/mount/linux.rb @@ -54,7 +54,7 @@ class Chef mounted = true logger.trace("Bind device #{device_logstring} mounted as #{real_mount_point}") # Permalink for network device mounted to an existing mount point: https://rubular.com/r/JRTXXGFdQtwCD6 - when %r{\A#{Regexp.escape(real_mount_point)}\s+#{device_mount_regex}\[} + when /\A#{Regexp.escape(real_mount_point)}\s+#{device_mount_regex}\[/ mounted = true logger.trace("Network device #{device_logstring} mounted as #{real_mount_point}") end diff --git a/lib/chef/resource/mount.rb b/lib/chef/resource/mount.rb index ed5d9a0e0b..c23ba9bbee 100644 --- a/lib/chef/resource/mount.rb +++ b/lib/chef/resource/mount.rb @@ -41,6 +41,7 @@ class Chef sensitive: true property :mount_point, String, name_property: true, + coerce: proc { |arg| arg.chomp("/") }, # Removed "/" from the end of str, because it was causing idempotency issue. description: "The directory (or path) in which the device is to be mounted. Defaults to the name of the resource block if not provided." property :device, String, identity: true, @@ -65,7 +66,7 @@ class Chef property :options, [Array, String, nil], description: "An array or comma separated list of options for the mount.", - coerce: proc { |arg| arg.is_a?(String) ? arg.split(",") : arg }, + coerce: proc { |arg| mount_options(arg) }, # Please see #mount_options method. default: %w{defaults} property :dump, [Integer, FalseClass], @@ -94,6 +95,11 @@ class Chef @fstype = nil end + # Returns array of string without leading and trailing whitespace. + def mount_options(options) + (options.is_a?(String) ? options.split(",") : options).collect(&:strip) + end + end end end |