Skip to content

Commit 16d10e7

Browse files
committed
:^)
1 parent 236c11e commit 16d10e7

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

docs/resources/organization.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,12 @@ An organization on the Coder deployment
2828
### Read-Only
2929

3030
- `id` (String) Organization ID
31+
32+
## Import
33+
34+
Import is supported using the following syntax:
35+
36+
```shell
37+
# Organizations can be imported by their name
38+
terraform import coderd_organization.our_org our_org
39+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
# Organizations can be imported by their name
12
terraform import coderd_organization.our_org our_org

internal/provider/organization_resource.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ func (r *OrganizationResource) Read(ctx context.Context, req resource.ReadReques
114114
return
115115
}
116116

117-
orgID := data.ID.ValueUUID()
118-
org, err := r.Client.Organization(ctx, orgID)
117+
orgName := data.Name.ValueString()
118+
org, err := r.Client.OrganizationByName(ctx, orgName)
119119
if err != nil {
120120
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to get organization by ID, got error: %s", err))
121121
return

internal/provider/organization_resource_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ func TestAccOrganizationResource(t *testing.T) {
4040
cfg2.Name = ptr.Ref("example-org-new")
4141
cfg2.DisplayName = ptr.Ref("Example Organization New")
4242

43-
cfg3 := cfg2
44-
4543
t.Run("CreateImportUpdateReadOk", func(t *testing.T) {
4644
resource.Test(t, resource.TestCase{
4745
IsUnitTest: true,

0 commit comments

Comments
 (0)