-
Notifications
You must be signed in to change notification settings - Fork 157
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
Import branch #220
Import branch #220
Conversation
0417f8d
to
1ee833c
Compare
tfe/resource_tfe_workspace.go
Outdated
@@ -163,6 +163,7 @@ func resourceTFEWorkspaceCreate(d *schema.ResourceData, meta interface{}) error | |||
|
|||
options.VCSRepo = &tfe.VCSRepoOptions{ | |||
Identifier: tfe.String(vcsRepo["identifier"].(string)), | |||
Branch: tfe.String(vcsRepo["branch"].(string)), |
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.
does this override the conditional setting of branch on lines 171-175?
it seemed like previously, this was attempting to only set the branch if it was actually set in the config.
i'm pretty sure it will work either way but i think we might want to pick one way or the other and remove the redundant code.
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.
You are right on this one, I missed it on the initial review because the diff was too short :) Good catch!
@@ -231,6 +232,7 @@ func resourceTFEWorkspaceRead(d *schema.ResourceData, meta interface{}) error { | |||
if workspace.VCSRepo != nil { | |||
vcsConfig := map[string]interface{}{ | |||
"identifier": workspace.VCSRepo.Identifier, | |||
"branch": workspace.VCSRepo.Branch, |
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.
sort of the same question here as the one above. i think the goal is to only set the branch if we actually get one back from the API request and it isn't ""
. there's clearly something wrong with the way we were attempting to do this before but i'm not sure what
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.
In this case we should remove the if block below. Read()'s result should not be affected by the HCL config at all, instead it should be reporting what the resource actually looks like.
I'll update this PR shortly!
The Create method was already adding the branch name. The Read method on the other hand was conditionally updating the branch value based on the TF config, which was causing issues when importing branches.
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.
this looks great to me! imported and created some workspaces locally and everything worked as expected 👍🏼
Description
Importing a workspace with a non-default branch fails to import the branch.
Output from acceptance tests
Please run the full suite of acceptance tests locally and include the output here.