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/userdel diffs #584

Merged
merged 3 commits into from
Jan 11, 2017
Merged

Feature/userdel diffs #584

merged 3 commits into from
Jan 11, 2017

Conversation

arichardet
Copy link
Contributor

@arichardet arichardet commented Jan 10, 2017

Improve diffs used when deleting a user.
Implements #445

@@ -217,19 +183,10 @@ func (u *User) Check(context.Context, resource.Renderer) (resource.TaskStatus, e

// Apply changes for user
func (u *User) Apply(context.Context) (resource.TaskStatus, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why couldn't apply use the status that you've created already, again? I feel like we had this discussion, but a) I don't remember and b) has the answer changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't believe we can since we no longer keep status as a field of the task struct.

@@ -401,6 +336,40 @@ func (u *User) DiffAdd(status *resource.Status) (*AddUserOptions, error) {
return options, nil
}

// DiffDel checks for differences between the current and desired state for the
// user to be deleted indicated by the User fields.
func (u *User) DiffDel(status *resource.Status, userByName *user.User, nameNotFound bool) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: should this be public?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It makes sense to be private, but is public for testing purposes.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO it would be better to make the tests part of the package than it would be to expose extra members. But it's definitely not a blocker. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After some discussion, we've concluded to leave as is for user since testing is currently performed for a package <name> in package <name_test>. In the next resource added to Converge, we will try testing as part of the package.

Copy link
Contributor

Choose a reason for hiding this comment

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

🤘 ticket?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened #585

case nameNotFound:
return nil
case userByName != nil:
switch {
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: this if … else in fancier clothes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought you liked switch better. ;) I will change it back to if...else.

}
}

if resource.AnyChanges(status.Differences) {
Copy link
Contributor

Choose a reason for hiding this comment

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

possible enhancement: why isn't this a method on status? (cc @rebeccaskinner)

@rebeccaskinner rebeccaskinner merged commit af3eb1c into master Jan 11, 2017
@rebeccaskinner rebeccaskinner deleted the feature/userdel-diffs branch January 11, 2017 17:02
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.

3 participants