Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcfa101d

Browse files
authored
fix: limit app group length (#407)
1 parent442ff2a commitcfa101d

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

‎provider/app.go

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@ var (
2323
appSlugRegex=regexp.MustCompile(`^[a-z0-9](-?[a-z0-9])*$`)
2424
)
2525

26-
constappDisplayNameMaxLength=64// database column limit
26+
const (
27+
appDisplayNameMaxLength=64// database column limit
28+
appGroupNameMaxLength=64
29+
)
2730

2831
funcappResource()*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,iinterface{}) diag.Diagnostics {
36+
CreateContext:func(c context.Context,resourceData*schema.ResourceData,iany) diag.Diagnostics {
3437
resourceData.SetId(uuid.NewString())
3538

3639
diags:= diag.Diagnostics{}
@@ -63,10 +66,10 @@ func appResource() *schema.Resource {
6366

6467
returndiags
6568
},
66-
ReadContext:func(c context.Context,resourceData*schema.ResourceData,iinterface{}) diag.Diagnostics {
69+
ReadContext:func(c context.Context,resourceData*schema.ResourceData,iany) diag.Diagnostics {
6770
returnnil
6871
},
69-
DeleteContext:func(ctx context.Context,rd*schema.ResourceData,iinterface{}) diag.Diagnostics {
72+
DeleteContext:func(ctx context.Context,rd*schema.ResourceData,iany) diag.Diagnostics {
7073
returnnil
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(iinterface{},sstring) ([]string, []error) {
98+
ValidateFunc:func(iany,sstring) ([]string, []error) {
9699
_,err:=url.Parse(s)
97100
iferr!=nil {
98101
returnnil, []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(valinterface{},c cty.Path) diag.Diagnostics {
114+
ValidateDiagFunc:func(valany,c cty.Path) diag.Diagnostics {
112115
valStr,ok:=val.(string)
113116
if!ok {
114117
returndiag.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(valinterface{},c cty.Path) diag.Diagnostics {
132+
ValidateDiagFunc:func(valany,c cty.Path) diag.Diagnostics {
130133
valStr,ok:=val.(string)
131134
if!ok {
132135
returndiag.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(valinterface{},c cty.Path) diag.Diagnostics {
167+
ValidateDiagFunc:func(valany,c cty.Path) diag.Diagnostics {
165168
valStr,ok:=val.(string)
166169
if!ok {
167170
returndiag.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(valany,c cty.Path) diag.Diagnostics {
235+
valStr,ok:=val.(string)
236+
if!ok {
237+
returndiag.Errorf("expected string, got %T",val)
238+
}
239+
240+
iflen(valStr)>appGroupNameMaxLength {
241+
returndiag.Errorf("group name is too long (max %d characters)",appGroupNameMaxLength)
242+
}
243+
returnnil
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(valinterface{},c cty.Path) diag.Diagnostics {
267+
ValidateDiagFunc:func(valany,c cty.Path) diag.Diagnostics {
254268
valStr,ok:=val.(string)
255269
if!ok {
256270
returndiag.Errorf("expected string, got %T",val)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp