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

Fix: cannot create env0_user_team_assignment: validation error #682

Merged
merged 4 commits into from
Jul 24, 2023

Conversation

TomerHeber
Copy link
Collaborator

Issue & Steps to Reproduce / Feature Request

fixes #681

Solution

Some user ids have an "_". Original solution assumed it's not possible.

  1. created a custom split called lastSplit: split by the last underscore.
  2. use lastSplit instead of using strings.Split().
  3. Updated the acceptance tests to cover this use-case.
  4. Added unit tests for lastSplit.

@@ -34,7 +33,8 @@ func (a *UserTeamAssignment) GetId() string {
}

func GetUserTeamAssignmentFromId(id string) (*UserTeamAssignment, error) {
splitUserTeam := strings.Split(id, "_")
// lastSplit is used to avoid issues where the user_id has underscores in it.
splitUserTeam := lastSplit(id, "_")
if len(splitUserTeam) != 2 {
Copy link

@adelinn adelinn Jul 20, 2023

Choose a reason for hiding this comment

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

I think this will error if splitUserTeam is nil.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

in golang len(nil) returns 0.

Copy link
Contributor

@sagilaufer1992 sagilaufer1992 left a comment

Choose a reason for hiding this comment

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

looks good overall, left some comments

env0/resource_user_team_assignment_test.go Outdated Show resolved Hide resolved
env0/utils.go Outdated Show resolved Hide resolved
env0/resource_user_team_assignment.go Show resolved Hide resolved
Copy link
Contributor

@sagilaufer1992 sagilaufer1992 left a comment

Choose a reason for hiding this comment

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

LGTM, my comments were addressed

@github-actions github-actions bot added ready to merge PR approved - can be merged once the PR owner is ready and removed pending final review labels Jul 24, 2023
@sagilaufer1992
Copy link
Contributor

please try and comment your commit hash that resolves a comment, it makes reviewing easier 😃

@TomerHeber TomerHeber merged commit 5e8a7a1 into main Jul 24, 2023
7 checks passed
@TomerHeber TomerHeber deleted the fix-user-with-underscore-#681 branch July 24, 2023 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix provider ready to merge PR approved - can be merged once the PR owner is ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot create env0_user_team_assignment: validation error
3 participants