Skip to content

Commit 47f7940

Browse files
committed
Merge branch 'main' into unnestws
2 parents 63ea39a + 252d868 commit 47f7940

37 files changed

+1077
-223
lines changed

agent/agent.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ type Metadata struct {
4949
OwnerUsername string `json:"owner_username"`
5050
EnvironmentVariables map[string]string `json:"environment_variables"`
5151
StartupScript string `json:"startup_script"`
52+
Directory string `json:"directory"`
5253
}
5354

5455
type Dialer func(ctx context.Context, logger slog.Logger) (Metadata, *peerbroker.Listener, error)
@@ -340,6 +341,11 @@ func (a *agent) createCommand(ctx context.Context, rawCommand string, env []stri
340341
caller = "/c"
341342
}
342343
cmd := exec.CommandContext(ctx, shell, caller, command)
344+
cmd.Dir = metadata.Directory
345+
if cmd.Dir == "" {
346+
// Default to $HOME if a directory is not set!
347+
cmd.Dir = os.Getenv("HOME")
348+
}
343349
cmd.Env = append(os.Environ(), env...)
344350
executablePath, err := os.Executable()
345351
if err != nil {

buildinfo/buildinfo.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,17 @@ func Version() string {
3333
revision = "+" + revision[:7]
3434
}
3535
if tag == "" {
36+
// This occurs when the tag hasn't been injected,
37+
// like when using "go run".
3638
version = "v0.0.0-devel" + revision
3739
return
3840
}
39-
if semver.Build(tag) == "" {
40-
tag += revision
41-
}
4241
version = "v" + tag
42+
// The tag must be prefixed with "v" otherwise the
43+
// semver library will return an empty string.
44+
if semver.Build(version) == "" {
45+
version += revision
46+
}
4347
})
4448
return version
4549
}

cli/configssh.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ func configSSH() *cobra.Command {
106106
// Without this, the "REMOTE HOST IDENTITY CHANGED"
107107
// message will appear.
108108
"\tUserKnownHostsFile=/dev/null",
109+
// This disables the "Warning: Permanently added 'hostname' (RSA) to the list of known hosts."
110+
// message from appearing on every SSH. This happens because we ignore the known hosts.
111+
"\tLogLevel ERROR",
109112
)
110113
if !skipProxyCommand {
111114
configOptions = append(configOptions, fmt.Sprintf("\tProxyCommand %q --global-config %q ssh --stdio %s", binaryFile, root, hostname))

cli/server.go

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"encoding/pem"
99
"errors"
1010
"fmt"
11+
"io"
12+
"log"
1113
"net"
1214
"net/http"
1315
"net/url"
@@ -263,7 +265,10 @@ func server() *cobra.Command {
263265
go func() {
264266
defer close(errCh)
265267
server := http.Server{
266-
Handler: handler,
268+
// These errors are typically noise like "TLS: EOF". Vault does similar:
269+
// https://github.com/hashicorp/vault/blob/e2490059d0711635e529a4efcbaa1b26998d6e1c/command/server.go#L2714
270+
ErrorLog: log.New(io.Discard, "", 0),
271+
Handler: handler,
267272
BaseContext: func(_ net.Listener) context.Context {
268273
return shutdownConnsCtx
269274
},
@@ -356,18 +361,7 @@ func server() *cobra.Command {
356361
return xerrors.Errorf("delete workspace: %w", err)
357362
}
358363

359-
err = cliui.ProvisionerJob(cmd.Context(), cmd.OutOrStdout(), cliui.ProvisionerJobOptions{
360-
Fetch: func() (codersdk.ProvisionerJob, error) {
361-
build, err := client.WorkspaceBuild(cmd.Context(), build.ID)
362-
return build.Job, err
363-
},
364-
Cancel: func() error {
365-
return client.CancelWorkspaceBuild(cmd.Context(), build.ID)
366-
},
367-
Logs: func() (<-chan codersdk.ProvisionerJobLog, error) {
368-
return client.WorkspaceBuildLogsAfter(cmd.Context(), build.ID, before)
369-
},
370-
})
364+
err = cliui.WorkspaceBuild(cmd.Context(), cmd.OutOrStdout(), client, build.ID, before)
371365
if err != nil {
372366
return xerrors.Errorf("delete workspace %s: %w", workspace.Name, err)
373367
}

cli/start.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,7 @@ func start() *cobra.Command {
3434
if err != nil {
3535
return err
3636
}
37-
err = cliui.ProvisionerJob(cmd.Context(), cmd.OutOrStdout(), cliui.ProvisionerJobOptions{
38-
Fetch: func() (codersdk.ProvisionerJob, error) {
39-
build, err := client.WorkspaceBuild(cmd.Context(), build.ID)
40-
return build.Job, err
41-
},
42-
Cancel: func() error {
43-
return client.CancelWorkspaceBuild(cmd.Context(), build.ID)
44-
},
45-
Logs: func() (<-chan codersdk.ProvisionerJobLog, error) {
46-
return client.WorkspaceBuildLogsAfter(cmd.Context(), build.ID, before)
47-
},
48-
})
49-
return err
37+
return cliui.WorkspaceBuild(cmd.Context(), cmd.OutOrStdout(), client, build.ID, before)
5038
},
5139
}
5240
}

cli/stop.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,7 @@ func stop() *cobra.Command {
3434
if err != nil {
3535
return err
3636
}
37-
err = cliui.ProvisionerJob(cmd.Context(), cmd.OutOrStdout(), cliui.ProvisionerJobOptions{
38-
Fetch: func() (codersdk.ProvisionerJob, error) {
39-
build, err := client.WorkspaceBuild(cmd.Context(), build.ID)
40-
return build.Job, err
41-
},
42-
Cancel: func() error {
43-
return client.CancelWorkspaceBuild(cmd.Context(), build.ID)
44-
},
45-
Logs: func() (<-chan codersdk.ProvisionerJobLog, error) {
46-
return client.WorkspaceBuildLogsAfter(cmd.Context(), build.ID, before)
47-
},
48-
})
49-
if err != nil {
50-
return err
51-
}
52-
return nil
37+
return cliui.WorkspaceBuild(cmd.Context(), cmd.OutOrStdout(), client, build.ID, before)
5338
},
5439
}
5540
}

coderd/database/databasefake/databasefake.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,7 @@ func (q *fakeQuerier) InsertWorkspaceAgent(_ context.Context, arg database.Inser
11731173
Name: arg.Name,
11741174
Architecture: arg.Architecture,
11751175
OperatingSystem: arg.OperatingSystem,
1176+
Directory: arg.Directory,
11761177
StartupScript: arg.StartupScript,
11771178
InstanceMetadata: arg.InstanceMetadata,
11781179
ResourceMetadata: arg.ResourceMetadata,

coderd/database/dump.sql

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ALTER TABLE ONLY workspace_agents
2+
DROP COLUMN IF EXISTS directory;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE ONLY workspace_agents
2+
-- UNIX paths are a maximum length of 4096.
3+
ADD COLUMN IF NOT EXISTS directory varchar(4096) DEFAULT '' NOT NULL;

0 commit comments

Comments
 (0)