@@ -23,14 +23,17 @@ var (
23
23
appSlugRegex = regexp .MustCompile (`^[a-z0-9](-?[a-z0-9])*$` )
24
24
)
25
25
26
- const appDisplayNameMaxLength = 64 // database column limit
26
+ const (
27
+ appDisplayNameMaxLength = 64 // database column limit
28
+ appGroupNameMaxLength = 64
29
+ )
27
30
28
31
func appResource ()* schema.Resource {
29
32
return & schema.Resource {
30
33
SchemaVersion :1 ,
31
34
32
35
Description :"Use this resource to define shortcuts to access applications in a workspace." ,
33
- CreateContext :func (c context.Context ,resourceData * schema.ResourceData ,i interface {} ) diag.Diagnostics {
36
+ CreateContext :func (c context.Context ,resourceData * schema.ResourceData ,i any ) diag.Diagnostics {
34
37
resourceData .SetId (uuid .NewString ())
35
38
36
39
diags := diag.Diagnostics {}
@@ -63,10 +66,10 @@ func appResource() *schema.Resource {
63
66
64
67
return diags
65
68
},
66
- ReadContext :func (c context.Context ,resourceData * schema.ResourceData ,i interface {} ) diag.Diagnostics {
69
+ ReadContext :func (c context.Context ,resourceData * schema.ResourceData ,i any ) diag.Diagnostics {
67
70
return nil
68
71
},
69
- DeleteContext :func (ctx context.Context ,rd * schema.ResourceData ,i interface {} ) diag.Diagnostics {
72
+ DeleteContext :func (ctx context.Context ,rd * schema.ResourceData ,i any ) diag.Diagnostics {
70
73
return nil
71
74
},
72
75
Schema :map [string ]* schema.Schema {
@@ -92,7 +95,7 @@ func appResource() *schema.Resource {
92
95
"built-in icon with `\" ${data.coder_workspace.me.access_url}/icon/<path>\" `." ,
93
96
ForceNew :true ,
94
97
Optional :true ,
95
- ValidateFunc :func (i interface {} ,s string ) ([]string , []error ) {
98
+ ValidateFunc :func (i any ,s string ) ([]string , []error ) {
96
99
_ ,err := url .Parse (s )
97
100
if err != nil {
98
101
return nil , []error {err }
@@ -108,7 +111,7 @@ func appResource() *schema.Resource {
108
111
"hyphen or contain two consecutive hyphens." ,
109
112
ForceNew :true ,
110
113
Required :true ,
111
- ValidateDiagFunc :func (val interface {} ,c cty.Path ) diag.Diagnostics {
114
+ ValidateDiagFunc :func (val any ,c cty.Path ) diag.Diagnostics {
112
115
valStr ,ok := val .(string )
113
116
if ! ok {
114
117
return diag .Errorf ("expected string, got %T" ,val )
@@ -126,7 +129,7 @@ func appResource() *schema.Resource {
126
129
Description :"A display name to identify the app. Defaults to the slug." ,
127
130
ForceNew :true ,
128
131
Optional :true ,
129
- ValidateDiagFunc :func (val interface {} ,c cty.Path ) diag.Diagnostics {
132
+ ValidateDiagFunc :func (val any ,c cty.Path ) diag.Diagnostics {
130
133
valStr ,ok := val .(string )
131
134
if ! ok {
132
135
return diag .Errorf ("expected string, got %T" ,val )
@@ -161,7 +164,7 @@ func appResource() *schema.Resource {
161
164
ForceNew :true ,
162
165
Optional :true ,
163
166
Default :"owner" ,
164
- ValidateDiagFunc :func (val interface {} ,c cty.Path ) diag.Diagnostics {
167
+ ValidateDiagFunc :func (val any ,c cty.Path ) diag.Diagnostics {
165
168
valStr ,ok := val .(string )
166
169
if ! ok {
167
170
return diag .Errorf ("expected string, got %T" ,val )
@@ -228,6 +231,17 @@ func appResource() *schema.Resource {
228
231
Description :"The name of a group that this app belongs to." ,
229
232
ForceNew :true ,
230
233
Optional :true ,
234
+ ValidateDiagFunc :func (val any ,c cty.Path ) diag.Diagnostics {
235
+ valStr ,ok := val .(string )
236
+ if ! ok {
237
+ return diag .Errorf ("expected string, got %T" ,val )
238
+ }
239
+
240
+ if len (valStr )> appGroupNameMaxLength {
241
+ return diag .Errorf ("group name is too long (max %d characters)" ,appGroupNameMaxLength )
242
+ }
243
+ return nil
244
+ },
231
245
},
232
246
"order" : {
233
247
Type :schema .TypeInt ,
@@ -250,7 +264,7 @@ func appResource() *schema.Resource {
250
264
ForceNew :true ,
251
265
Optional :true ,
252
266
Default :"slim-window" ,
253
- ValidateDiagFunc :func (val interface {} ,c cty.Path ) diag.Diagnostics {
267
+ ValidateDiagFunc :func (val any ,c cty.Path ) diag.Diagnostics {
254
268
valStr ,ok := val .(string )
255
269
if ! ok {
256
270
return diag .Errorf ("expected string, got %T" ,val )