-
Notifications
You must be signed in to change notification settings - Fork 160
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
Allow Importing workspaces using workspace name #401
Conversation
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 tried this and it worked with both methods. I think you can test import by using the ImportState/ImportStateId property of resource.TestStep.
tfeClient := meta.(*tfe.Client) | ||
|
||
s := strings.SplitN(d.Id(), "/", 2) | ||
if len(s) >= 3 { |
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.
At most 2 strings will be returned by strings.SplitN(d.Id(), "/", 2)
tfe/resource_tfe_workspace.go
Outdated
} | ||
|
||
d.SetId(workspaceID) | ||
return []*schema.ResourceData{d}, 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.
This line can be omitted
This changes the Importer function for the Workspace resource to handle passing an organization name and workspace name pair to import the workspace. If no pair is specified the importer function will assume an opaque external id was passed. An example import command looks as follows: terraform import tfe_workspace.test my-org-name/my-wkspace-name
4c3f400
to
3c5f110
Compare
Nice! 👏🏻 |
Description
This PR adds support for importing workspaces using a
<ORGANIZATION NAME>/<WORKSPACE NAME>
nested combo. You can still pass a workspace external id.An example import command looks as follows:
How to test
To run acceptance tests:
TESTARGS="-run TestAccTFEWorkspace_import" make testacc
To smoke test:
Ensure you have the dev overrides set to the compiled binary of this PR in your
go/bin
.