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

Change vultr_user.acl to typeset as the ordering is not important and causes extraneous plans #495

Merged
merged 1 commit into from
Jun 5, 2024

Conversation

F21
Copy link
Contributor

@F21 F21 commented Jun 4, 2024

Description

This PR changes the acl property in the vultr_user resource from TypeList to TypeSet. The order of the ACLs is not important and due causes a lot of extraneous plans when the order of the ACLs do not match the order returned from the server.

Related Issues

Closes #494

Checklist:

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you linted your code locally prior to submission?
  • Have you successfully ran tests with your changes locally?

@optik-aper optik-aper added the bug label Jun 4, 2024
Copy link
Member

@optik-aper optik-aper left a comment

Choose a reason for hiding this comment

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

Thanks for this! Unfortunately, this won't work without changing how the ACL field is converted to a slice when creating and updating.

panic: interface conversion: interface {} is *schema.Set, not []interface {}

I took a look and this should be added to accommodate the type change.

	acl, aclOK := d.GetOk("acl")
	acls := acl.(*schema.Set).List()

	var aclReq []string
	if aclOK {
		for i := range acls {
			aclReq = append(aclReq, acls[i].(string))
		}

		userReq.ACL = aclReq
	}

You can replace the conversion logic in the create and also replace it in the update

@F21
Copy link
Contributor Author

F21 commented Jun 4, 2024

Thanks for catching this! I updated the type assertions in the create and update functions.

@optik-aper optik-aper self-requested a review June 5, 2024 00:09
Copy link
Member

@optik-aper optik-aper left a comment

Choose a reason for hiding this comment

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

Tested and working. Thanks!

@optik-aper optik-aper merged commit 2f4bf19 into vultr:master Jun 5, 2024
3 checks passed
@F21 F21 deleted the acl-typeset branch June 5, 2024 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] - acl in vultr_user causes endless updates due to ordering of acls
2 participants