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

Add a test to check if team members are org members #350

Merged
merged 2 commits into from
Jan 14, 2019

Conversation

nikhita
Copy link
Member

@nikhita nikhita commented Jan 12, 2019

This would be useful to fail early if someone who is added as a team maintainer or member is not an org member. See #346 (review) for an example.

This PR also validates:

  • a user is not mentioned as both an org admin and org member
  • a user is not mentioned as both a team maintainer and member
  • no duplicates exist in the list of team maintainers and members

/assign @cblecker @fejta

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 12, 2019
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 12, 2019
@@ -24,7 +24,7 @@ members:
- animeshsingh
- ant31
- apelisse
- atoms
- Atoms
Copy link
Member Author

Choose a reason for hiding this comment

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

--- FAIL: TestAllOrgs (0.03s)
    --- FAIL: TestAllOrgs/kubernetes-sigs (0.00s)
        config_test.go:169: The following members of team kubespray-maintainers are not org members: Atoms
FAIL

Copy link
Member

Choose a reason for hiding this comment

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

This is actually a good test case, because we shouldn't care about capitalization. The peribolos code has normalization functions we should use.

func normalize(s sets.String) sets.String {
out := sets.String{}
for i := range s {
out.Insert(github.NormLogin(i))
}
return out
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Can we export this as well?

Copy link
Member

@cblecker cblecker left a comment

Choose a reason for hiding this comment

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

I wonder if this config validation stuff should actually be functions in the prow/config/ package that we export, so that they're reusable.

WDYT @fejta?

@@ -24,7 +24,7 @@ members:
- animeshsingh
- ant31
- apelisse
- atoms
- Atoms
Copy link
Member

Choose a reason for hiding this comment

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

This is actually a good test case, because we shouldn't care about capitalization. The peribolos code has normalization functions we should use.

func normalize(s sets.String) sets.String {
out := sets.String{}
for i := range s {
out.Insert(github.NormLogin(i))
}
return out
}

@@ -87,6 +87,28 @@ func isSorted(list []string) bool {
return sort.StringsAreSorted(items)
}

// testTeamMembers checks if team maintainers and members are org members.
// TODO: also ensure that the list is sorted.
func testTeamMembers(teams map[string]org.Team, orgMembers sets.String) []error {
Copy link
Member

Choose a reason for hiding this comment

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

Can we also add a test case to ensure that a particular user doesn't exist in both the maintainers and members lists at the same time? This is also a condition that peribolos will error on, but the config checker presubmit doesn't handle.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Also added a check for duplicate names in the lists.

@nikhita
Copy link
Member Author

nikhita commented Jan 13, 2019

I wonder if this config validation stuff should actually be functions in the prow/config/ package that we export, so that they're reusable.

+1. Can we also make sure that we are sorting before dumping all names? We would be sorted (sorry for the pun, couldn't resist) once we sort all names and add a test for new ones in the CI, but it might prove useful to others who will use peribolos.

Also ensure that:
- a user is not mentioned as both an org admin and org member
- a user is not mentioned as both a team maintainer and member
- no duplicates exist in the list of team maintainers and members
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 14, 2019
Copy link
Contributor

@fejta fejta left a comment

Choose a reason for hiding this comment

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

/lgtm

@cblecker
Copy link
Member

/lgtm
/approve

Thanks so much @nikhita! 🎈

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cblecker, nikhita

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 14, 2019
@k8s-ci-robot k8s-ci-robot merged commit f6b171c into kubernetes:master Jan 14, 2019
@nikhita nikhita deleted the team-members-test branch February 20, 2019 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants