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

fix: limit app group length#407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
aslilac merged 1 commit intomainfromlilac/limit-app-group-length
May 27, 2025
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletionsprovider/app.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,14 +23,17 @@ var (
appSlugRegex = regexp.MustCompile(`^[a-z0-9](-?[a-z0-9])*$`)
)

const appDisplayNameMaxLength = 64 // database column limit
const (
appDisplayNameMaxLength = 64 // database column limit
appGroupNameMaxLength = 64
)

func appResource() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,

Description: "Use this resource to define shortcuts to access applications in a workspace.",
CreateContext: func(c context.Context, resourceData *schema.ResourceData, iinterface{}) diag.Diagnostics {
CreateContext: func(c context.Context, resourceData *schema.ResourceData, iany) diag.Diagnostics {
resourceData.SetId(uuid.NewString())

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

return diags
},
ReadContext: func(c context.Context, resourceData *schema.ResourceData, iinterface{}) diag.Diagnostics {
ReadContext: func(c context.Context, resourceData *schema.ResourceData, iany) diag.Diagnostics {
return nil
},
DeleteContext: func(ctx context.Context, rd *schema.ResourceData, iinterface{}) diag.Diagnostics {
DeleteContext: func(ctx context.Context, rd *schema.ResourceData, iany) diag.Diagnostics {
return nil
},
Schema: map[string]*schema.Schema{
Expand All@@ -92,7 +95,7 @@ func appResource() *schema.Resource {
"built-in icon with `\"${data.coder_workspace.me.access_url}/icon/<path>\"`.",
ForceNew: true,
Optional: true,
ValidateFunc: func(iinterface{}, s string) ([]string, []error) {
ValidateFunc: func(iany, s string) ([]string, []error) {
_, err := url.Parse(s)
if err != nil {
return nil, []error{err}
Expand All@@ -108,7 +111,7 @@ func appResource() *schema.Resource {
"hyphen or contain two consecutive hyphens.",
ForceNew: true,
Required: true,
ValidateDiagFunc: func(valinterface{}, c cty.Path) diag.Diagnostics {
ValidateDiagFunc: func(valany, c cty.Path) diag.Diagnostics {
valStr, ok := val.(string)
if !ok {
return diag.Errorf("expected string, got %T", val)
Expand All@@ -126,7 +129,7 @@ func appResource() *schema.Resource {
Description: "A display name to identify the app. Defaults to the slug.",
ForceNew: true,
Optional: true,
ValidateDiagFunc: func(valinterface{}, c cty.Path) diag.Diagnostics {
ValidateDiagFunc: func(valany, c cty.Path) diag.Diagnostics {
valStr, ok := val.(string)
if !ok {
return diag.Errorf("expected string, got %T", val)
Expand DownExpand Up@@ -161,7 +164,7 @@ func appResource() *schema.Resource {
ForceNew: true,
Optional: true,
Default: "owner",
ValidateDiagFunc: func(valinterface{}, c cty.Path) diag.Diagnostics {
ValidateDiagFunc: func(valany, c cty.Path) diag.Diagnostics {
valStr, ok := val.(string)
if !ok {
return diag.Errorf("expected string, got %T", val)
Expand DownExpand Up@@ -228,6 +231,17 @@ func appResource() *schema.Resource {
Description: "The name of a group that this app belongs to.",
ForceNew: true,
Optional: true,
ValidateDiagFunc: func(val any, c cty.Path) diag.Diagnostics {
valStr, ok := val.(string)
if !ok {
return diag.Errorf("expected string, got %T", val)
}

if len(valStr) > appGroupNameMaxLength {
return diag.Errorf("group name is too long (max %d characters)", appGroupNameMaxLength)
}
return nil
},
},
"order": {
Type: schema.TypeInt,
Expand All@@ -250,7 +264,7 @@ func appResource() *schema.Resource {
ForceNew: true,
Optional: true,
Default: "slim-window",
ValidateDiagFunc: func(valinterface{}, c cty.Path) diag.Diagnostics {
ValidateDiagFunc: func(valany, c cty.Path) diag.Diagnostics {
valStr, ok := val.(string)
if !ok {
return diag.Errorf("expected string, got %T", val)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp