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
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Commit8e81679

Browse files
feat: allow hyphens and underscores in devurl names (#404)
* allow hyphens and underscores in devurl names* update unit tests to use image with correct certsCo-authored-by: Dean Sheather <dean@coder.com>
1 parent802eac8 commit8e81679

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

‎internal/cmd/tags_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func Test_tags(t *testing.T) {
1818
res:=execute(t,nil,"tags","ls")
1919
res.error(t)
2020

21-
ensureImageImported(ctx,t,testCoderClient,"ubuntu")
21+
ensureImageImported(ctx,t,testCoderClient,"ubuntu","latest")
2222

2323
res=execute(t,nil,"tags","ls","--image=ubuntu","--org=default")
2424
res.success(t)

‎internal/cmd/urls.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ func createDevURLCmd() *cobra.Command {
144144
returnxerrors.Errorf("invalid access level %q",access)
145145
}
146146

147-
ifurlname!=""&&!devURLNameValidRx.MatchString(urlname) {
148-
returnxerrors.New("update devurl: name must be < 64 chars in length, begin with a letter and only contain letters or digits.")
147+
ifurlname!=""&&!devURLValidNameRx.MatchString(urlname) {
148+
returnxerrors.Errorf(devURLInvalidNameMsg,urlname)
149149
}
150150
client,err:=newClient(ctx,true)
151151
iferr!=nil {
@@ -199,9 +199,14 @@ func createDevURLCmd() *cobra.Command {
199199
}
200200

201201
// devURLNameValidRx is the regex used to validate devurl names specified
202-
// via the --name subcommand. Named devurls must begin with a letter, and
203-
// consist solely of letters and digits, with a max length of 64 chars.
204-
vardevURLNameValidRx=regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9]{0,63}$")
202+
// via the --name subcommand. Named devurls must begin with a letter
203+
// followed by zero or more letters, numbers, hyphens, or underscores,
204+
// end with a letter or a number, and be maximum 64 characters in length.
205+
// The maximum length of the name component is 43 characters.
206+
vardevURLValidNameRx=regexp.MustCompile("^[a-zA-Z]([a-zA-Z0-9_-]{0,41}[a-zA-Z0-9])?$")
207+
vardevURLInvalidNameMsg="invalid devurl name %q: names must begin with a letter, "+
208+
"followed by zero or more letters, digits, hyphens, or underscores, and end with a "+
209+
"letter or digit, and be a maximum of 43 characters in length."
205210

206211
// devURLID returns the ID of a devURL, given the workspace name and port
207212
// from a list of DevURL records.

‎internal/cmd/workspaces_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ func Test_workspace_create(t *testing.T) {
8181
res.error(t)
8282
res.stderrContains(t,"fatal: image not found - did you forget to import this image?")
8383

84-
ensureImageImported(ctx,t,testCoderClient,"ubuntu")
84+
ensureImageImported(ctx,t,testCoderClient,"codercom/enterprise-base","ubuntu")
8585

8686
name:=randString(10)
8787
cpu:=2.3
8888

8989
// attempt to remove the workspace on cleanup
9090
t.Cleanup(func() {_=execute(t,nil,"workspaces","rm",name,"--force") })
9191

92-
res=execute(t,nil,"workspaces","create",name,"--image=ubuntu",fmt.Sprintf("--cpu=%f",cpu))
92+
res=execute(t,nil,"workspaces","create",name,"--image=codercom/enterprise-base","--tag=ubuntu",fmt.Sprintf("--cpu=%f",cpu))
9393
res.success(t)
9494

9595
res=execute(t,nil,"workspaces","ls")
@@ -108,7 +108,7 @@ func Test_workspace_create(t *testing.T) {
108108

109109
// edit the CPU of the workspace
110110
cpu=2.1
111-
res=execute(t,nil,"workspaces","edit",name,fmt.Sprintf("--cpu=%f",cpu),"--follow","--force")
111+
res=execute(t,nil,"workspaces","edit",name,"--image=codercom/enterprise-base","--tag=ubuntu",fmt.Sprintf("--cpu=%f",cpu),"--follow","--force")
112112
res.success(t)
113113

114114
// assert that the CPU actually did change after edit
@@ -153,7 +153,7 @@ var floatComparer = cmp.Comparer(func(x, y float64) bool {
153153
// this is a stopgap until we have support for a `coder images` subcommand
154154
// until then, we can use the coder.Client to ensure our integration tests
155155
// work on fresh deployments.
156-
funcensureImageImported(ctx context.Context,t*testing.T,client coder.Client,imgstring) {
156+
funcensureImageImported(ctx context.Context,t*testing.T,client coder.Client,img,tagstring) {
157157
orgs,err:=client.Organizations(ctx)
158158
assert.Success(t,"get orgs",err)
159159

@@ -198,7 +198,7 @@ search:
198198
RegistryID:&dockerhubID,
199199
OrgID:org.ID,
200200
Repository:img,
201-
Tag:"latest",
201+
Tag:tag,
202202
DefaultCPUCores:2.5,
203203
DefaultDiskGB:22,
204204
DefaultMemoryGB:3,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp