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