Skip to content

Commit 4086202

Browse files
committed
Merge branch 'main' into dean/app-urls-use-slug
2 parents 1a5eabc + d0fb054 commit 4086202

File tree

96 files changed

+3670
-1553
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+3670
-1553
lines changed

.golangci.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,15 @@ linters:
235235
- noctx
236236
- paralleltest
237237
- revive
238-
- rowserrcheck
239-
- sqlclosecheck
238+
239+
# These don't work until the following issue is solved.
240+
# https://github.com/golangci/golangci-lint/issues/2649
241+
# - rowserrcheck
242+
# - sqlclosecheck
243+
# - structcheck
244+
# - wastedassign
245+
240246
- staticcheck
241-
- structcheck
242247
- tenv
243248
# In Go, it's possible for a package to test it's internal functionality
244249
# without testing any exported functions. This is enabled to promote
@@ -253,4 +258,3 @@ linters:
253258
- unconvert
254259
- unused
255260
- varcheck
256-
- wastedassign

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ LABEL \
1212
org.opencontainers.image.description="A tool for provisioning self-hosted development environments with Terraform." \
1313
org.opencontainers.image.url="https://github.com/coder/coder" \
1414
org.opencontainers.image.source="https://github.com/coder/coder" \
15-
org.opencontainers.image.version="$CODER_VERSION" \
16-
org.opencontainers.image.licenses="AGPL-3.0"
15+
org.opencontainers.image.version="$CODER_VERSION"
1716

1817
# The coder binary is injected by scripts/build_docker.sh.
1918
COPY --chown=coder:coder --chmod=755 coder /opt/coder

agent/agent.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,18 @@ func (a *agent) init(ctx context.Context) {
448448
"sftp": func(session ssh.Session) {
449449
session.DisablePTYEmulation()
450450

451-
server, err := sftp.NewServer(session)
451+
var opts []sftp.ServerOption
452+
// Change current working directory to the users home
453+
// directory so that SFTP connections land there.
454+
// https://github.com/coder/coder/issues/3620
455+
u, err := user.Current()
456+
if err != nil {
457+
a.logger.Warn(ctx, "get sftp working directory failed, unable to get current user", slog.Error(err))
458+
} else {
459+
opts = append(opts, sftp.WithServerWorkingDirectory(u.HomeDir))
460+
}
461+
462+
server, err := sftp.NewServer(session, opts...)
452463
if err != nil {
453464
a.logger.Debug(session.Context(), "initialize sftp server", slog.Error(err))
454465
return

agent/agent_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"net/netip"
1111
"os"
1212
"os/exec"
13+
"os/user"
1314
"path/filepath"
1415
"runtime"
1516
"strconv"
@@ -212,12 +213,21 @@ func TestAgent(t *testing.T) {
212213

213214
t.Run("SFTP", func(t *testing.T) {
214215
t.Parallel()
216+
u, err := user.Current()
217+
require.NoError(t, err, "get current user")
218+
home := u.HomeDir
219+
if runtime.GOOS == "windows" {
220+
home = "/" + strings.ReplaceAll(home, "\\", "/")
221+
}
215222
conn, _ := setupAgent(t, codersdk.WorkspaceAgentMetadata{}, 0)
216223
sshClient, err := conn.SSHClient()
217224
require.NoError(t, err)
218225
defer sshClient.Close()
219226
client, err := sftp.NewClient(sshClient)
220227
require.NoError(t, err)
228+
wd, err := client.Getwd()
229+
require.NoError(t, err, "get working directory")
230+
require.Equal(t, home, wd, "working directory should be home user home")
221231
tempFile := filepath.Join(t.TempDir(), "sftp")
222232
file, err := client.Create(tempFile)
223233
require.NoError(t, err)

cli/cliui/provisionerjob.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func ProvisionerJob(ctx context.Context, writer io.Writer, opts ProvisionerJobOp
134134

135135
logs, closer, err := opts.Logs()
136136
if err != nil {
137-
return xerrors.Errorf("logs: %w", err)
137+
return xerrors.Errorf("begin streaming logs: %w", err)
138138
}
139139
defer closer.Close()
140140

cli/config/file.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import (
66
"path/filepath"
77
)
88

9+
const (
10+
FlagName = "global-config"
11+
)
12+
913
// Root represents the configuration directory.
1014
type Root string
1115

@@ -42,6 +46,10 @@ func (r Root) PostgresPort() File {
4246
return File(filepath.Join(r.PostgresPath(), "port"))
4347
}
4448

49+
func (r Root) DeploymentConfigPath() string {
50+
return filepath.Join(string(r), "server.yaml")
51+
}
52+
4553
// File provides convenience methods for interacting with *os.File.
4654
type File string
4755

0 commit comments

Comments
 (0)