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

Feat: Assign teams a project resource #140

Merged
merged 12 commits into from
Sep 5, 2021

Conversation

liranfarage89
Copy link
Contributor

@liranfarage89 liranfarage89 commented Aug 31, 2021

Issue & Steps to Reproduce / Feature Request

  • a new resource: team-project-assignments
    image

Solution

  • Use the rest CRUD API that was created for that: #4781 #4797

@liranfarage89
Copy link
Contributor Author

Copy link
Contributor

@razbensimon razbensimon left a comment

Choose a reason for hiding this comment

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

Greate job, see some questions and comments

if payload.TeamId == "" {
return TeamProjectAssignment{}, errors.New("must specify team_id")
}
if payload.ProjectRole == "" ||
Copy link
Contributor

Choose a reason for hiding this comment

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

just asking, payload.ProjectRole == "" is not enough?

Copy link
Contributor Author

@liranfarage89 liranfarage89 Sep 5, 2021

Choose a reason for hiding this comment

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

nope.. I tried that but since it's a string (typedef of a string) it could be any string.

client/team_project_assignment_test.go Outdated Show resolved Hide resolved
const dummyProjectRole = "Admin"
const dummyTeamId = "dummyTeamId"

var _ = Describe("TeamProjectAssignment", func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Where are the tests for your argument's validations? like missing field you have checked

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Type: schema.TypeString,
Description: "id of the team",
Required: true,
ForceNew: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

what ForceNew do?
do we need it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ForceNew indicates that any change in this field requires the resource to be destroyed and recreated.

https://www.terraform.io/docs/extend/schemas/schema-behaviors.html#forcenew

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in other words, we want to destroy the existing teamProjectAssignment when the teamId was changed.

if assignment.Id == id {
d.Set("project_id", assignment.ProjectId)
d.Set("team_id", assignment.TeamId)
d.Set("role", assignment.ProjectRole)
Copy link
Contributor

Choose a reason for hiding this comment

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

should break after found?

Copy link
Contributor

Choose a reason for hiding this comment

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

also, should we use SetId in this method?

Copy link
Contributor Author

@liranfarage89 liranfarage89 Sep 5, 2021

Choose a reason for hiding this comment

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

should break after found?

yes 7992743

also, should we use SetId in this method?

nope, we already have it ( they are equal...)

@@ -0,0 +1 @@
{}
Copy link
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

empty output... we don't print anything

Copy link
Contributor

@razbensimon razbensimon left a comment

Choose a reason for hiding this comment

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

🐐

@liranfarage89 liranfarage89 merged commit 1d3f038 into main Sep 5, 2021
@liranfarage89 liranfarage89 deleted the feat-team-project-assignment branch September 5, 2021 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants