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

Filter teams by name, org members by email #393

Merged
merged 5 commits into from May 5, 2022

Conversation

sebasslash
Copy link
Contributor

@sebasslash sebasslash commented May 4, 2022

Two new query params have been added to the list endpoints for Teams and OrganizationMemberships:

filter[names] - List Teams
filter[email] - List Org Members


// validEmail checks if the given input is a correct email
func validEmail(v string) bool {
_, err := mail.ParseAddress(v)
Copy link
Contributor

@Uk1288 Uk1288 May 4, 2022

Choose a reason for hiding this comment

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

nice 🎉

@@ -77,6 +77,9 @@ type OrganizationMembershipListOptions struct {
// Optional: A list of relations to include. See available resources
// https://www.terraform.io/cloud-docs/api-docs/organization-memberships#available-related-resources
Include []OrgMembershipIncludeOpt `url:"include,omitempty"`

// Optional: A list of organization member emails to filter by.
Emails []string `url:"filter[email],omitempty"`
Copy link
Contributor

@Uk1288 Uk1288 May 4, 2022

Choose a reason for hiding this comment

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

should this be,

Suggested change
Emails []string `url:"filter[email],omitempty"`
Emails []string `url:"filter[emails],omitempty"`

Copy link
Contributor Author

@sebasslash sebasslash May 4, 2022

Choose a reason for hiding this comment

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

brandonc
brandonc previously approved these changes May 4, 2022
Copy link
Collaborator

@brandonc brandonc left a comment

@@ -278,3 +285,13 @@ func validateTeamIncludeParams(params []TeamIncludeOpt) error {

return nil
}

func validateTeamNames(names []string) error {
for _, name := range names {
Copy link
Collaborator

@brandonc brandonc May 4, 2022

Choose a reason for hiding this comment

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

This works when names is nil, right?

Copy link
Contributor Author

@sebasslash sebasslash May 5, 2022

Choose a reason for hiding this comment

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

Yessir!

Uk1288
Uk1288 approved these changes May 5, 2022
Copy link
Contributor

@Uk1288 Uk1288 left a comment

LGTM 🎉

@@ -262,4 +262,8 @@ var (
ErrRequiredWorkspacesList = errors.New("no workspaces list provided")

ErrCommentBody = errors.New("comment body is required")

ErrEmptyTeamName = errors.New("team name can not be empty")
Copy link
Contributor

@annawinkler annawinkler May 5, 2022

Choose a reason for hiding this comment

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

Suggested change
ErrEmptyTeamName = errors.New("team name can not be empty")
ErrEmptyTeamName = errors.New("team name cannot be empty")

Copy link
Contributor

@annawinkler annawinkler May 5, 2022

Choose a reason for hiding this comment

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

I'm asking @laurapacilio about this because ... after doing a quick search I realized that this suggestion may not be consistent with what we do as a company.

Copy link
Contributor

@annawinkler annawinkler left a comment

Nice!

@sebasslash sebasslash merged commit 836895d into main May 5, 2022
4 checks passed
@sebasslash sebasslash deleted the sebasslash/filter-teams-org-members branch May 5, 2022
@github-actions
Copy link

github-actions bot commented May 5, 2022

Reminder to the contributor that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update CHANGELOG.md with a note on your changes.

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.

None yet

4 participants