func configureTeamMembers(client teamMembersClient, gt github.Team, team org.Team) error {
	// Get desired state
	wantMaintainers := sets.NewString(team.Maintainers...)
	wantMembers := sets.NewString(team.Members...)

	// Get current state
	haveMaintainers := sets.String{}
	haveMembers := sets.String{}

	members, err := client.ListTeamMembers(gt.ID, github.RoleMember)
	if err != nil {
		return fmt.Errorf("failed to list %d(%s) members: %v", gt.ID, gt.Name, err)
	}
	for _, m := range members {
		haveMembers.Insert(m.Login)
	}

	maintainers, err := client.ListTeamMembers(gt.ID, github.RoleMaintainer)
	if err != nil {
		return fmt.Errorf("failed to list %d(%s) maintainers: %v", gt.ID, gt.Name, err)
	}
	for _, m := range maintainers {
		haveMaintainers.Insert(m.Login)
	}

	invitees, err := teamInvitations(client, gt.ID)
	if err != nil {
		return fmt.Errorf("failed to list %d(%s) invitees: %v", gt.ID, gt.Name, err)
	}

	adder := func(user string, super bool) error {
		if invitees.Has(user) {
			logrus.Infof("Waiting for %s to accept invitation to %d(%s)", user, gt.ID, gt.Name)
			return nil
		}
		role := github.RoleMember
		if super {
			role = github.RoleMaintainer
		}
		tm, err := client.UpdateTeamMembership(gt.ID, user, super)
		if err != nil {
			logrus.WithError(err).Warnf("UpdateTeamMembership(%d(%s), %s, %t) failed", gt.ID, gt.Name, user, super)
		} else if tm.State == github.StatePending {
			logrus.Infof("Invited %s to %d(%s) as a %s", user, gt.ID, gt.Name, role)
		} else {
			logrus.Infof("Set %s as a %s of %d(%s)", user, role, gt.ID, gt.Name)
		}
		return err
	}

	remover := func(user string) error {
		err := client.RemoveTeamMembership(gt.ID, user)
		if err != nil {
			logrus.WithError(err).Warnf("RemoveTeamMembership(%d(%s), %s) failed", gt.ID, gt.Name, user)
		} else {
			logrus.Infof("Removed %s from team %d(%s)", user, gt.ID, gt.Name)
		}
		return err
	}

	want := memberships{members: wantMembers, super: wantMaintainers}
	have := memberships{members: haveMembers, super: haveMaintainers}
	return configureMembers(have, want, invitees, adder, remover)
}
func configureTeamMembers(client teamMembersClient, gt github.Team, team org.Team) error {
	// Get desired state
	wantMaintainers := sets.NewString(team.Maintainers...)
	wantMembers := sets.NewString(team.Members...)

	// Get current state
	haveMaintainers := sets.String{}
	haveMembers := sets.String{}

	members, err := client.ListTeamMembers(gt.ID, github.RoleMember)
	if err != nil {
		return fmt.Errorf("failed to list %d(%s) members: %v", gt.ID, gt.Name, err)
	}
	for _, m := range members {
		haveMembers.Insert(m.Login)
	}

	maintainers, err := client.ListTeamMembers(gt.ID, github.RoleMaintainer)
	if err != nil {
		return fmt.Errorf("failed to list %d(%s) maintainers: %v", gt.ID, gt.Name, err)
	}
	for _, m := range maintainers {
		haveMaintainers.Insert(m.Login)
	}

	invitees, err := teamInvitations(client, gt.ID)
	if err != nil {
		return fmt.Errorf("failed to list %d(%s) invitees: %v", gt.ID, gt.Name, err)
	}

	adder := func(user string, super bool) error {
		if invitees.Has(user) {
			logrus.Infof("Waiting for %s to accept invitation to %d(%s)", user, gt.ID, gt.Name)
			return nil
		}
		role := github.RoleMember
		if super {
			role = github.RoleMaintainer
		}
		tm, err := client.UpdateTeamMembership(gt.ID, user, super)
		if err != nil {
			logrus.WithError(err).Warnf("UpdateTeamMembership(%d(%s), %s, %t) failed", gt.ID, gt.Name, user, super)
		} else if tm.State == github.StatePending {
			logrus.Infof("Invited %s to %d(%s) as a %s", user, gt.ID, gt.Name, role)
		} else {
			logrus.Infof("Set %s as a %s of %d(%s)", user, role, gt.ID, gt.Name)
		}
		return err
	}

	remover := func(user string) error {
		err := client.RemoveTeamMembership(gt.ID, user)
		if err != nil {
			logrus.WithError(err).Warnf("RemoveTeamMembership(%d(%s), %s) failed", gt.ID, gt.Name, user)
		} else {
			logrus.Infof("Removed %s from team %d(%s)", user, gt.ID, gt.Name)
		}
		return err
	}

	want := memberships{members: wantMembers, super: wantMaintainers}
	have := memberships{members: haveMembers, super: haveMaintainers}
	return configureMembers(have, want, invitees, adder, remover)
}
// configureTeamMembers will add/update people to the appropriate role on the team, and remove anyone else.