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

Feature/74 file owner #549

Merged
merged 31 commits into from
Dec 21, 2016
Merged

Feature/74 file owner #549

merged 31 commits into from
Dec 21, 2016

Conversation

rebeccaskinner
Copy link
Contributor

fixes #74

Copy link
Contributor

@arichardet arichardet left a comment

Choose a reason for hiding this comment

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

A few questions/suggestions.

"golang.org/x/net/context"
)

// Preparer for Owern
Copy link
Contributor

Choose a reason for hiding this comment

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

owner typo


// Recursive indicates whether ownership changes should be applied
// recursively. Symlinks are not followed.
Recursive bool `hcl:"recursive" default:"false" export:"recursive"`
Copy link
Contributor

Choose a reason for hiding this comment

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

we do not have a default tag

UID *int `hcl:"uid" mutually_exclusive:"user" export:"uid"`

// Groupname specifies group-ownership by groupname
Groupname string `hcl:"group" mutually_exclusive:"gid" export:"gid"`
Copy link
Contributor

Choose a reason for hiding this comment

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

You should change the mutually_exclusive tags for Groupname and GID to contain both of the fields:
mutually_exclusive:"group,gid"

Groupname string `hcl:"group" mutually_exclusive:"gid" export:"gid"`

// GID specifies group ownership by gid
GID *int `hcl:"gid" mutually_exclusive:"group" export:"group"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably should remove the export tags in Preparer

@@ -0,0 +1,21 @@
/* This file demonstrates proper usage of the file.owner module by creating a
Copy link
Contributor

Choose a reason for hiding this comment

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

your sample has an error:
root/file.owner.owner-test:
Error: stat to-change: no such file or directory
Messages:
Has Changes: no
Changes: No changes

}
w := &fileWalker{Status: status, NewOwner: newOwner, Executor: o.executor}
if o.Recursive {
status.AddMessage("Recursively updating permissions in " + o.Destination)
Copy link
Contributor

Choose a reason for hiding this comment

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

You should check whether destination is a directory

if idx > 1 {
return "Error executing diff generation on " + d.Path
}
if nil != d.UIDs && d.UIDs[0] != d.UIDs[1] {
Copy link
Contributor

Choose a reason for hiding this comment

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

There are a few if nil !=s in this file

func (o *Owner) Apply(context.Context) (resource.TaskStatus, error) {
showDetails := !(o.Recursive && o.HideDetails)
status := resource.NewStatus()
if o.Recursive {
Copy link
Contributor

Choose a reason for hiding this comment

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

and if destination is not a directory?

return os.Chown(path, uid, gid)
}

func osStat(path string) (*syscall.Stat_t, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe move this to the end of the file?

t.Parallel()
assert.Implements(t, (*resource.Task)(nil), new(owner.Owner))
}

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add some tests to check/apply when destination is and is not a directory with recursive = true

Copy link
Contributor

@arichardet arichardet left a comment

Choose a reason for hiding this comment

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

Also, you might want to check the value of the error returned and the value of the message in tests for some extra confirmation.

showDetails := !(o.Recursive && o.HideDetails)

if _, err := os.Stat(o.Destination); os.IsNotExist(err) {
return nil, fmt.Errorf("cannot change ownership of non-existant file: %s", o.Destination)
Copy link
Contributor

Choose a reason for hiding this comment

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

correct spelling is existent

@arichardet arichardet merged commit c3c73b7 into master Dec 21, 2016
@arichardet arichardet deleted the feature/74-file-owner branch December 21, 2016 14:34
BrianHicks pushed a commit that referenced this pull request Dec 22, 2016
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.

builtin file owner module
3 participants