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

Commit0e08cc6

Browse files
author
Rafael Rodriguez
committed
Merge branch 'main' into rafrdz/tooltip-support
2 parents061c7ba +2030907 commit0e08cc6

File tree

10 files changed

+104
-43
lines changed

10 files changed

+104
-43
lines changed

‎cli/exp_task_create.go‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func (r *RootCmd) taskCreate() *serpent.Command {
2222
templateVersionNamestring
2323
presetNamestring
2424
stdinbool
25+
quietbool
2526
)
2627

2728
cmd:=&serpent.Command{
@@ -57,6 +58,13 @@ func (r *RootCmd) taskCreate() *serpent.Command {
5758
Description:"Reads from stdin for the task input.",
5859
Value:serpent.BoolOf(&stdin),
5960
},
61+
{
62+
Name:"quiet",
63+
Flag:"quiet",
64+
FlagShorthand:"q",
65+
Description:"Only display the created task's ID.",
66+
Value:serpent.BoolOf(&quiet),
67+
},
6068
},
6169
Handler:func(inv*serpent.Invocation)error {
6270
var (
@@ -166,12 +174,16 @@ func (r *RootCmd) taskCreate() *serpent.Command {
166174
returnxerrors.Errorf("create task: %w",err)
167175
}
168176

169-
_,_=fmt.Fprintf(
170-
inv.Stdout,
171-
"The task %s has been created at %s!\n",
172-
cliui.Keyword(task.Name),
173-
cliui.Timestamp(task.CreatedAt),
174-
)
177+
ifquiet {
178+
_,_=fmt.Fprintln(inv.Stdout,task.ID)
179+
}else {
180+
_,_=fmt.Fprintf(
181+
inv.Stdout,
182+
"The task %s has been created at %s!\n",
183+
cliui.Keyword(task.Name),
184+
cliui.Timestamp(task.CreatedAt),
185+
)
186+
}
175187

176188
returnnil
177189
},

‎cli/exp_task_create_test.go‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func TestTaskCreate(t *testing.T) {
3131
templateID=uuid.New()
3232
templateVersionID=uuid.New()
3333
templateVersionPresetID=uuid.New()
34+
taskID=uuid.New()
3435
)
3536

3637
templateAndVersionFoundHandler:=func(t*testing.T,ctx context.Context,orgID uuid.UUID,templateName,templateVersionName,presetName,promptstring) http.HandlerFunc {
@@ -44,11 +45,11 @@ func TestTaskCreate(t *testing.T) {
4445
ID:orgID,
4546
}},
4647
})
47-
casefmt.Sprintf("/api/v2/organizations/%s/templates/my-template/versions/my-template-version",orgID):
48+
casefmt.Sprintf("/api/v2/organizations/%s/templates/%s/versions/%s",orgID,templateName,templateVersionName):
4849
httpapi.Write(ctx,w,http.StatusOK, codersdk.TemplateVersion{
4950
ID:templateVersionID,
5051
})
51-
casefmt.Sprintf("/api/v2/organizations/%s/templates/my-template",orgID):
52+
casefmt.Sprintf("/api/v2/organizations/%s/templates/%s",orgID,templateName):
5253
httpapi.Write(ctx,w,http.StatusOK, codersdk.Template{
5354
ID:templateID,
5455
ActiveVersionID:templateVersionID,
@@ -83,7 +84,8 @@ func TestTaskCreate(t *testing.T) {
8384
assert.Equal(t,templateVersionPresetID,req.TemplateVersionPresetID,"template version preset id mismatch")
8485
}
8586

86-
httpapi.Write(ctx,w,http.StatusCreated, codersdk.Workspace{
87+
httpapi.Write(ctx,w,http.StatusCreated, codersdk.Task{
88+
ID:taskID,
8789
Name:"task-wild-goldfish-27",
8890
CreatedAt:taskCreatedAt,
8991
})
@@ -161,6 +163,13 @@ func TestTaskCreate(t *testing.T) {
161163
returntemplateAndVersionFoundHandler(t,ctx,organizationID,"my-template","","my-preset","my custom prompt")
162164
},
163165
},
166+
{
167+
args: []string{"my custom prompt","-q"},
168+
expectOutput:taskID.String(),
169+
handler:func(t*testing.T,ctx context.Context) http.HandlerFunc {
170+
returntemplateAndVersionFoundHandler(t,ctx,organizationID,"my-template","my-template-version","","my custom prompt")
171+
},
172+
},
164173
{
165174
args: []string{"my custom prompt","--template","my-template","--preset","not-real-preset"},
166175
expectError:`preset "not-real-preset" not found`,

‎cli/templatepush.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,9 @@ func (pf *templateUploadFlags) stdin(inv *serpent.Invocation) (out bool) {
309309
inv.Logger.Info(inv.Context(),"uploading tar read from stdin")
310310
}
311311
}()
312-
// We let the directory override our isTTY check
313-
returnpf.directory=="-"|| (!isTTYIn(inv)&&pf.directory==".")
312+
// We read a tar from stdin if the directory is "-" or if we're not in a
313+
// TTY and the directory flag is unset.
314+
returnpf.directory=="-"|| (!isTTYIn(inv)&&!inv.ParsedFlags().Lookup("directory").Changed)
314315
}
315316

316317
func (pf*templateUploadFlags)upload(inv*serpent.Invocation,client*codersdk.Client) (*codersdk.UploadResponse,error) {

‎cli/templatepush_test.go‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ func TestTemplatePush(t *testing.T) {
339339
inv,root:=clitest.New(t,"templates","push",
340340
"--test.provisioner",string(database.ProvisionerTypeEcho),
341341
"--test.workdir",source,
342+
"--force-tty",
342343
)
343344
clitest.SetupConfig(t,templateAdmin,root)
344345
pty:=ptytest.New(t).Attach(inv)
@@ -1075,6 +1076,45 @@ func TestTemplatePush(t *testing.T) {
10751076
require.Equal(t,templateName,template.Name)
10761077
require.NotEqual(t,uuid.Nil,template.ActiveVersionID)
10771078
})
1079+
1080+
t.Run("NoStdinWithCurrentDirectory",func(t*testing.T) {
1081+
t.Parallel()
1082+
client:=coderdtest.New(t,&coderdtest.Options{IncludeProvisionerDaemon:true})
1083+
owner:=coderdtest.CreateFirstUser(t,client)
1084+
templateAdmin,_:=coderdtest.CreateAnotherUser(t,client,owner.OrganizationID,rbac.RoleTemplateAdmin())
1085+
version:=coderdtest.CreateTemplateVersion(t,client,owner.OrganizationID,nil)
1086+
_=coderdtest.AwaitTemplateVersionJobCompleted(t,client,version.ID)
1087+
1088+
template:=coderdtest.CreateTemplate(t,client,owner.OrganizationID,version.ID)
1089+
1090+
source:=clitest.CreateTemplateVersionSource(t,&echo.Responses{
1091+
Parse:echo.ParseComplete,
1092+
ProvisionApply:echo.ApplyComplete,
1093+
})
1094+
1095+
inv,root:=clitest.New(t,"templates","push",template.Name,
1096+
"--directory",".",
1097+
"--test.provisioner",string(database.ProvisionerTypeEcho),
1098+
"--test.workdir",source,
1099+
"--name","example",
1100+
"--yes")
1101+
clitest.SetupConfig(t,templateAdmin,root)
1102+
1103+
inv.Stdin=strings.NewReader("invalid tar content that would cause failure")
1104+
1105+
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitMedium)
1106+
defercancel()
1107+
1108+
err:=inv.WithContext(ctx).Run()
1109+
require.NoError(t,err,"Should succeed without reading from stdin")
1110+
1111+
templateVersions,err:=client.TemplateVersionsByTemplate(ctx, codersdk.TemplateVersionsByTemplateRequest{
1112+
TemplateID:template.ID,
1113+
})
1114+
require.NoError(t,err)
1115+
require.Len(t,templateVersions,2)
1116+
require.Equal(t,"example",templateVersions[1].Name)
1117+
})
10781118
})
10791119
}
10801120

‎coderd/database/dbtestutil/db.go‎

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"os/exec"
1111
"path/filepath"
1212
"regexp"
13-
"strconv"
1413
"strings"
1514
"testing"
1615
"time"
@@ -251,26 +250,31 @@ func PGDump(dbURL string) ([]byte, error) {
251250
returnstdout.Bytes(),nil
252251
}
253252

254-
constminimumPostgreSQLVersion=13
253+
const (
254+
minimumPostgreSQLVersion=13
255+
postgresImageSha="sha256:467e7f2fb97b2f29d616e0be1d02218a7bbdfb94eb3cda7461fd80165edfd1f7"
256+
)
255257

256258
// PGDumpSchemaOnly is for use by gen/dump only.
257259
// It runs pg_dump against dbURL and sets a consistent timezone and encoding.
258260
funcPGDumpSchemaOnly(dbURLstring) ([]byte,error) {
259261
hasPGDump:=false
260-
if_,err:=exec.LookPath("pg_dump");err==nil {
261-
out,err:=exec.Command("pg_dump","--version").Output()
262-
iferr==nil {
263-
// Parse output:
264-
// pg_dump (PostgreSQL) 14.5 (Ubuntu 14.5-0ubuntu0.22.04.1)
265-
parts:=strings.Split(string(out)," ")
266-
iflen(parts)>2 {
267-
version,err:=strconv.Atoi(strings.Split(parts[2],".")[0])
268-
iferr==nil&&version>=minimumPostgreSQLVersion {
269-
hasPGDump=true
270-
}
271-
}
272-
}
273-
}
262+
// TODO: Temporarily pin pg_dump to the docker image until
263+
// https://github.com/sqlc-dev/sqlc/issues/4065 is resolved.
264+
// if _, err := exec.LookPath("pg_dump"); err == nil {
265+
// out, err := exec.Command("pg_dump", "--version").Output()
266+
// if err == nil {
267+
// // Parse output:
268+
// // pg_dump (PostgreSQL) 14.5 (Ubuntu 14.5-0ubuntu0.22.04.1)
269+
// parts := strings.Split(string(out), " ")
270+
// if len(parts) > 2 {
271+
// version, err := strconv.Atoi(strings.Split(parts[2], ".")[0])
272+
// if err == nil && version >= minimumPostgreSQLVersion {
273+
// hasPGDump = true
274+
// }
275+
// }
276+
// }
277+
// }
274278

275279
cmdArgs:= []string{
276280
"pg_dump",
@@ -295,7 +299,7 @@ func PGDumpSchemaOnly(dbURL string) ([]byte, error) {
295299
"run",
296300
"--rm",
297301
"--network=host",
298-
fmt.Sprintf("%s:%d",postgresImage,minimumPostgreSQLVersion),
302+
fmt.Sprintf("%s:%d@%s",postgresImage,minimumPostgreSQLVersion,postgresImageSha),
299303
},cmdArgs...)
300304
}
301305
cmd:=exec.Command(cmdArgs[0],cmdArgs[1:]...)//#nosec

‎coderd/files_test.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"testing"
1010

1111
"github.com/google/uuid"
12+
"github.com/stretchr/testify/assert"
1213
"github.com/stretchr/testify/require"
1314

1415
"github.com/coder/coder/v2/archive"
@@ -88,7 +89,7 @@ func TestPostFiles(t *testing.T) {
8889
data:=make([]byte,1024)
8990
_,err:=client.Upload(ctx,codersdk.ContentTypeTar,bytes.NewReader(data))
9091
end.Done()
91-
require.NoError(t,err)
92+
assert.NoError(t,err)
9293
}()
9394
}
9495
wg.Done()

‎docs/admin/networking/index.md‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@ but this can be disabled or changed for
123123
By default, your Coder server also runs a built-in DERP relay which can be used
124124
for both public and[Air-gapped deployments](../../install/airgap.md).
125125

126-
However, our Wireguard integration through Tailscale has graciously allowed us
127-
to use
128-
[their global DERP relays](https://tailscale.com/kb/1118/custom-derp-servers/#what-are-derp-servers).
126+
However, Tailscale maintains a global fleet of[DERP relays](https://tailscale.com/kb/1118/custom-derp-servers/#what-are-derp-servers) intended for their product, and has allowed Coder to access and use them.
129127
You can launch`coder server` with Tailscale's DERPs like so:
130128

131129
```bash

‎enterprise/tailnet/pgcoord_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,8 @@ func TestPGCoordinatorSingle_SendsHeartbeats(t *testing.T) {
409409
iflen(heartbeats)<2 {
410410
returnfalse
411411
}
412-
require.Greater(t,heartbeats[0].Sub(start),time.Duration(0))
413-
require.Greater(t,heartbeats[1].Sub(start),time.Duration(0))
412+
assert.Greater(t,heartbeats[0].Sub(start),time.Duration(0))
413+
assert.Greater(t,heartbeats[1].Sub(start),time.Duration(0))
414414
returnassert.Greater(t,heartbeats[1].Sub(heartbeats[0]),tailnet.HeartbeatPeriod*3/4)
415415
},testutil.WaitMedium,testutil.IntervalMedium)
416416
}

‎scaletest/createworkspaces/run_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ func Test_Runner(t *testing.T) {
257257
err:=runner.Run(runnerCtx,"1",logs)
258258
logsStr:=logs.String()
259259
t.Log("Runner logs:\n\n"+logsStr)
260-
require.ErrorIs(t,err,context.Canceled)
260+
assert.ErrorIs(t,err,context.Canceled)
261261
close(done)
262262
}()
263263

‎scripts/rules.go‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,32 +182,28 @@ func doNotCallTFailNowInsideGoroutine(m dsl.Matcher) {
182182
m.Match(`
183183
go func($*_){
184184
$*_
185-
$require.$_($*_)
185+
require.$_($*_)
186186
$*_
187187
}($*_)`).
188-
At(m["require"]).
189-
Where(m["require"].Text=="require").
190188
Report("Do not call functions that may call t.FailNow in a goroutine, as this can cause data races (see testing.go:834)")
191189

192190
// require.Eventually runs the function in a goroutine.
193191
m.Match(`
194192
require.Eventually(t, func() bool {
195193
$*_
196-
$require.$_($*_)
194+
require.$_($*_)
197195
$*_
198196
}, $*_)`).
199-
At(m["require"]).
200-
Where(m["require"].Text=="require").
201197
Report("Do not call functions that may call t.FailNow in a goroutine, as this can cause data races (see testing.go:834)")
202198

203199
m.Match(`
204200
go func($*_){
205201
$*_
206-
$t.$fail($*_)
202+
t.$fail($*_)
207203
$*_
208204
}($*_)`).
209205
At(m["fail"]).
210-
Where(m["t"].Type.Implements("testing.TB")&&m["fail"].Text.Matches("^(FailNow|Fatal|Fatalf)$")).
206+
Where(m["fail"].Text.Matches("^(FailNow|Fatal|Fatalf)$")).
211207
Report("Do not call functions that may call t.FailNow in a goroutine, as this can cause data races (see testing.go:834)")
212208
}
213209

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp