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/groups_datasource show_all_flag #520

Merged

Conversation

Threpio
Copy link
Contributor

@Threpio Threpio commented Aug 14, 2021

For issue: #516

This flag allows for terraform to interact with a list of currently existing groups within AAD for use in other environments (EG. Pagerduty).

It returns the same as other flags/inputs for the datasource and checks to ensure that a number greater than 0 are returned (otherwise an error is thrown in line with logic elsewhere)

@Threpio
Copy link
Contributor Author

Threpio commented Sep 2, 2021

@manicminer I have fixed the merge conflicts - Apologies for the delay.

@github-actions github-actions bot added size/M and removed size/S labels Sep 2, 2021
@manicminer manicminer force-pushed the feature/groups_datasource-show-all-flag branch from 6afa9ab to 944a7a6 Compare September 2, 2021 10:01
Copy link
Contributor

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

Thanks again for this @Threpio! I pushed some changes but I noted them inline below in case it's useful to you.

Test results
Screenshot 2021-09-02 at 11 10 10

Comment on lines +81 to +83
if err != nil {
return tf.ErrorDiagF(err, "Could not retrieve groups")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We try to check errors separately so it's more obvious when they occur

Comment on lines +84 to +86
if result == nil {
return tf.ErrorDiagF(errors.New("API returned nil result"), "Bad API Response")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should check for nil pointers before dereferencing as doing *result when result is nil would cause a crash

return tf.ErrorDiagPathF(err, "return_all", "No groups found")
}

groups = append(groups, *result...)
Copy link
Contributor

Choose a reason for hiding this comment

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

This notation is a useful shortcut to iterating with a for loop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Didn't know this one - Thank you for that - I will read through all these comments :)

@manicminer manicminer merged commit 425100e into hashicorp:main Sep 2, 2021
manicminer added a commit that referenced this pull request Sep 2, 2021
@Threpio Threpio deleted the feature/groups_datasource-show-all-flag branch September 2, 2021 11:11
@github-actions
Copy link

github-actions bot commented Sep 2, 2021

This functionality has been released in v2.1.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

github-actions bot commented Oct 3, 2021

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: <show_all_groups = true> groups_datasource.go
2 participants