-
Notifications
You must be signed in to change notification settings - Fork 15
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 drift handling #226
Add drift handling #226
Changes from 10 commits
e3f4b72
79fd80d
3868f81
234334f
0003acd
d1d60de
357054e
85267ae
696d15c
d388c31
4649799
443bf24
b89584f
8b20dc4
8f87942
c2ec119
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -884,4 +884,5 @@ func TestUnitEnvironmentResource(t *testing.T) { | |
}) | ||
|
||
}) | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package env0 | |
import ( | ||
"context" | ||
"fmt" | ||
|
||
. "github.com/env0/terraform-provider-env0/client" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
|
@@ -59,14 +60,21 @@ func resourceTeamProjectAssignmentRead(ctx context.Context, d *schema.ResourceDa | |
return diag.Errorf("could not get TeamProjectAssignment: %v", err) | ||
} | ||
|
||
found := false | ||
for _, assignment := range assignments { | ||
if assignment.Id == id { | ||
d.Set("project_id", assignment.ProjectId) | ||
d.Set("team_id", assignment.TeamId) | ||
d.Set("role", assignment.ProjectRole) | ||
found = true | ||
yaronya marked this conversation as resolved.
Show resolved
Hide resolved
|
||
break | ||
} | ||
} | ||
if !found { | ||
if !d.IsNewResource() { | ||
d.SetId("") | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Looks better to me. I took it from S3 bucket provider as example / reference. I am still not sure about this one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't think we need to throw something, but we do need to return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, @eranelbaz is correct - we don't need to throw anything. This is what we wanted to avoid in first place. @samuel-br haven't we previously discussed it and said that we don't really need to check whether There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yaronya i think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @razbensimon did you mean to fix the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "drift detected: TerraForm will remove {this resource} from state" is that good wording? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "[WARN] Drift Detected: Terraform will remove {this resource} from state" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
return nil | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we need to use it on the logic somewhere?
just wondering
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR handled also environment resource at start but since it isn't so trivial to re-create an environment on some drift and there's a deeper product decision to make before implementing it, we've decided to ditch it for now and create a separate issue for environment and project resources.
This looks like a leftover tho.
@samuel-br did you create that seperate issue btw?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yaronya #225?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not so sure. I expect to see an issue that includes environment and project resources in its description, but couldn't find it.
If I get that correctly:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, Ill do it later today, but I want to summary this before on channel, cause for now there is three or for types of resources in this contexts of problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samuel-br maybe just change their title?
Handle drift - general
Handle drift - specific resources
etc
and link themThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am confused with all of those issues.
I just asked to make the PR with a good description (copy-paste the issue if needed to the PR).
anyways, if that line of code is related to this PR keep it.
if not - remove it
@samuel-br
cc @eranelbaz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed the title for #250 already FYI.
And yes, prefer not having multiple issues with the same name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samuel-br can you please share on the main issue (i.e #205) what's needed to be done basically and why it differs from the other issues (parsing the error codes from http client layer and etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yaronya @eranelbaz I changed the issues names (@yaronya thanks on #250 ) and add #205 (comment) on the main issue, please take a look on that comment to ensure its clear enough