@@ -23,14 +23,17 @@ var (
2323 appSlugRegex = regexp .MustCompile (`^[a-z0-9](-?[a-z0-9])*$` )
2424)
2525
26- const appDisplayNameMaxLength = 64 // database column limit
26+ const (
27+ appDisplayNameMaxLength = 64 // database column limit
28+ appGroupNameMaxLength = 64
29+ )
2730
2831func appResource () * schema.Resource {
2932 return & schema.Resource {
3033 SchemaVersion : 1 ,
3134
3235 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 {
3437 resourceData .SetId (uuid .NewString ())
3538
3639 diags := diag.Diagnostics {}
@@ -63,10 +66,10 @@ func appResource() *schema.Resource {
6366
6467 return diags
6568 },
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 {
6770 return nil
6871 },
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 {
7073 return nil
7174 },
7275 Schema : map [string ]* schema.Schema {
@@ -92,7 +95,7 @@ func appResource() *schema.Resource {
9295 "built-in icon with `\" ${data.coder_workspace.me.access_url}/icon/<path>\" `." ,
9396 ForceNew : true ,
9497 Optional : true ,
95- ValidateFunc : func (i interface {} , s string ) ([]string , []error ) {
98+ ValidateFunc : func (i any , s string ) ([]string , []error ) {
9699 _ , err := url .Parse (s )
97100 if err != nil {
98101 return nil , []error {err }
@@ -108,7 +111,7 @@ func appResource() *schema.Resource {
108111 "hyphen or contain two consecutive hyphens." ,
109112 ForceNew : true ,
110113 Required : true ,
111- ValidateDiagFunc : func (val interface {} , c cty.Path ) diag.Diagnostics {
114+ ValidateDiagFunc : func (val any , c cty.Path ) diag.Diagnostics {
112115 valStr , ok := val .(string )
113116 if ! ok {
114117 return diag .Errorf ("expected string, got %T" , val )
@@ -126,7 +129,7 @@ func appResource() *schema.Resource {
126129 Description : "A display name to identify the app. Defaults to the slug." ,
127130 ForceNew : true ,
128131 Optional : true ,
129- ValidateDiagFunc : func (val interface {} , c cty.Path ) diag.Diagnostics {
132+ ValidateDiagFunc : func (val any , c cty.Path ) diag.Diagnostics {
130133 valStr , ok := val .(string )
131134 if ! ok {
132135 return diag .Errorf ("expected string, got %T" , val )
@@ -161,7 +164,7 @@ func appResource() *schema.Resource {
161164 ForceNew : true ,
162165 Optional : true ,
163166 Default : "owner" ,
164- ValidateDiagFunc : func (val interface {} , c cty.Path ) diag.Diagnostics {
167+ ValidateDiagFunc : func (val any , c cty.Path ) diag.Diagnostics {
165168 valStr , ok := val .(string )
166169 if ! ok {
167170 return diag .Errorf ("expected string, got %T" , val )
@@ -228,6 +231,17 @@ func appResource() *schema.Resource {
228231 Description : "The name of a group that this app belongs to." ,
229232 ForceNew : true ,
230233 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+ },
231245 },
232246 "order" : {
233247 Type : schema .TypeInt ,
@@ -250,7 +264,7 @@ func appResource() *schema.Resource {
250264 ForceNew : true ,
251265 Optional : true ,
252266 Default : "slim-window" ,
253- ValidateDiagFunc : func (val interface {} , c cty.Path ) diag.Diagnostics {
267+ ValidateDiagFunc : func (val any , c cty.Path ) diag.Diagnostics {
254268 valStr , ok := val .(string )
255269 if ! ok {
256270 return diag .Errorf ("expected string, got %T" , val )
0 commit comments