Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add recursive chmod/chown to remote_directory resource. #218

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

yamajun
Copy link

@yamajun yamajun commented Jul 10, 2016

remote_directory resource with mode/owner/group attributes just only
work at root directory("path" attribute).

This patch add recursively option. And set default(it is good or bad?).

Test case

remote_directory '/var/www/html/webapps' do
  owner 'apache'
  group 'apache'
  mode  'g+w'
  source webapps
end

remote_directory resource with mode/owner/group attributes just only
work at root directory("path" attribute).

This patch add recursively option.  And set default(it is good or bad?).

Test case
---------

    remote_directory '/var/www/html/webapps' do
      owner 'apache'
      group 'apache'
      mode  'g+w'
      source webapps
    end
@@ -9,6 +9,8 @@ class RemoteDirectory < Base
define_attribute :mode, type: String
define_attribute :owner, type: String
define_attribute :group, type: String
define_attribute :recursive_mode, type: [String, Symbol], default: :true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think setting false as the default value is better.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think better way of recursive chown/chmod in default in my local usage.
But, this patch changes behavior from current version. It is not good.

I change to boolean false in default.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just change to default on false.
Sorry too late.

@@ -9,6 +9,8 @@ class RemoteDirectory < Base
define_attribute :mode, type: String
define_attribute :owner, type: String
define_attribute :group, type: String
define_attribute :recursive_mode, type: [String, Symbol], default: :true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use true instead of symbol :true?

@@ -56,10 +58,18 @@ def show_differences

def action_create(options)
if attributes.mode
run_specinfra(:change_file_mode, @temppath, attributes.mode)
if attributes.recursive_mode == :true
run_specinfra(:change_file_mode, @temppath, attributes.mode, :recursive => true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If attributes.recursive_mode is boolean, you can simply write this run_specinfra(:change_file_mode, @temppath, attributes.mode, recursive: attributes.recursive_mode)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to your suggestion!
Replace to your code and testing now.

* Change default value: false on default.
@@ -9,6 +9,8 @@ class RemoteDirectory < Base
define_attribute :mode, type: String
define_attribute :owner, type: String
define_attribute :group, type: String
define_attribute :recursive_mode, type: [TrueClass, FalseClass], default: false
define_attribute :recursive_owner, type: [TrueClass, FalseClass], default: false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the name of recursive_owner, users may not expect that group will be also changed recursively.
How about change the name to recursive_owner_and_group?

Copy link
Author

@yamajun yamajun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just mistake with commit log.
"#218: Change attribute name s/recursive_onwer/recursive_owner_and_group/"
But commented-out :-(

In my opinion. "recursive_owner_and_group" is too long.
Do you want change this attribute to "recursive" like chef / ansible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants