Skip to content

Commit e5afa40

Browse files
fix: use server computed org display name (#183)
I picked up on this reviewing #182, but it's a mistake I made when reviewing the resource originally 😓 There's a minor inconsistency between display names on orgs and some other resources with display names on `coderd`. i.e. for organizations: ``` if req.DisplayName == "" { req.DisplayName = req.Name } ``` For some other resources, e.g. users & groups, an empty string display name is retained, and the CLI/Web UI just shows the actual name if the display name is empty. For those, it's okay to have an empty string default in the provider.
1 parent ed8270c commit e5afa40

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

internal/provider/organization_resource.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ This resource is only compatible with Coder version [2.16.0](https://github.com/
121121
MarkdownDescription: "Display name of the organization. Defaults to name.",
122122
Computed: true,
123123
Optional: true,
124-
Default: stringdefault.StaticString(""),
125124
Validators: []validator.String{
126125
codersdkvalidator.DisplayName(),
127126
},

internal/provider/organization_resource_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,29 @@ func TestAccOrganizationResource(t *testing.T) {
121121
},
122122
})
123123
})
124+
125+
t.Run("DefaultDisplayName", func(t *testing.T) {
126+
cfg1 := testAccOrganizationResourceConfig{
127+
URL: client.URL.String(),
128+
Token: client.SessionToken(),
129+
Name: ptr.Ref("example-org"),
130+
Description: ptr.Ref("This is an example organization"),
131+
Icon: ptr.Ref("/icon/coder.svg"),
132+
}
133+
resource.Test(t, resource.TestCase{
134+
IsUnitTest: true,
135+
PreCheck: func() { testAccPreCheck(t) },
136+
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
137+
Steps: []resource.TestStep{
138+
{
139+
Config: cfg1.String(t),
140+
ConfigStateChecks: []statecheck.StateCheck{
141+
statecheck.ExpectKnownValue("coderd_organization.test", tfjsonpath.New("display_name"), knownvalue.StringExact("example-org")),
142+
},
143+
},
144+
},
145+
})
146+
})
124147
}
125148

126149
type testAccOrganizationResourceConfig struct {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy