Skip to content

Commit 22886d3

Browse files
authored
Merge branch 'main' into mafredri/provisionerd-cache-path
2 parents 9e0e271 + 6377f17 commit 22886d3

File tree

135 files changed

+2552
-1418
lines changed

Some content is hidden

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

135 files changed

+2552
-1418
lines changed

.github/workflows/coder.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ jobs:
8585
env:
8686
GITHUB_CONTEXT: ${{ toJSON(github) }}
8787
run: |
88-
go run github.com/coder/coder/.github/workflows/prcontext
88+
(cd .github/workflows/prcontext && go build)
89+
./.github/workflows/prcontext/prcontext
8990
9091
style-lint-golangci:
9192
name: style/lint/golangci

.github/workflows/prcontext/go.mod

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module github.com/coder/coder/.github/workflows/prcontext
2+
3+
go 1.18
4+
5+
require github.com/coder/flog v1.0.0
6+
7+
require (
8+
github.com/fatih/color v1.13.0 // indirect
9+
github.com/mattn/go-colorable v0.1.12 // indirect
10+
github.com/mattn/go-isatty v0.0.14 // indirect
11+
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 // indirect
12+
)

.github/workflows/prcontext/go.sum

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
github.com/coder/flog v1.0.0 h1:gqr4jYDQWYmsvFD0RV6Vs+SAj1Kbn0HGlV7UghfxP+8=
2+
github.com/coder/flog v1.0.0/go.mod h1:UQlQvrkJBvnRGo69Le8E24Tcl5SJleAAR7gYEHzAmdQ=
3+
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
4+
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
5+
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
6+
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
7+
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
8+
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
9+
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
10+
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
11+
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
12+
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
13+
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
14+
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
15+
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo=
16+
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

.github/workflows/release.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,19 @@ jobs:
275275
- name: ls artifacts
276276
run: ls artifacts
277277

278+
- name: Publish Helm
279+
run: |
280+
set -euxo pipefail
281+
./scripts/helm.sh --push
282+
mv ./dist/*.tgz ./artifacts/
283+
278284
- name: Publish Release
279285
run: |
280286
./scripts/publish_release.sh \
281287
${{ (github.event.inputs.dry_run || github.event.inputs.snapshot) && '--dry-run' }} \
282288
./artifacts/*.zip \
283289
./artifacts/*.tar.gz \
290+
./artifacts/*.tgz \
284291
./artifacts/*.apk \
285292
./artifacts/*.deb \
286293
./artifacts/*.rpm

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@ LABEL \
1414
# The coder binary is injected by scripts/build_docker.sh.
1515
ADD coder /opt/coder
1616

17+
# Create coder group and user.
18+
RUN addgroup -g 1000 coder && \
19+
adduser -D -g "" -h /home/coder -G coder -u 1000 -S -s /bin/sh coder
20+
USER coder:coder
21+
1722
ENTRYPOINT [ "/opt/coder", "server" ]

agent/agent_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,12 @@ func TestAgent(t *testing.T) {
120120
localPort := tcpAddr.Port
121121
done := make(chan struct{})
122122
go func() {
123+
defer close(done)
123124
conn, err := local.Accept()
124-
assert.NoError(t, err)
125+
if !assert.NoError(t, err) {
126+
return
127+
}
125128
_ = conn.Close()
126-
close(done)
127129
}()
128130

129131
err = setupSSHCommand(t, []string{"-L", fmt.Sprintf("%d:127.0.0.1:%d", randomPort, localPort)}, []string{"echo", "test"}).Start()
@@ -399,15 +401,18 @@ func setupSSHCommand(t *testing.T, beforeArgs []string, afterArgs []string) *exe
399401
listener, err := net.Listen("tcp", "127.0.0.1:0")
400402
require.NoError(t, err)
401403
go func() {
404+
defer listener.Close()
402405
for {
403406
conn, err := listener.Accept()
404407
if err != nil {
405408
return
406409
}
407410
ssh, err := agentConn.SSH()
408-
assert.NoError(t, err)
409-
go io.Copy(conn, ssh)
410-
go io.Copy(ssh, conn)
411+
if !assert.NoError(t, err) {
412+
_ = conn.Close()
413+
return
414+
}
415+
go agent.Bicopy(context.Background(), conn, ssh)
411416
}
412417
}()
413418
t.Cleanup(func() {

cli/root.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cli
22

33
import (
4+
"flag"
45
"fmt"
56
"net/url"
67
"os"
@@ -175,6 +176,10 @@ func versionCmd() *cobra.Command {
175176
}
176177
}
177178

179+
func isTest() bool {
180+
return flag.Lookup("test.v") != nil
181+
}
182+
178183
// createClient returns a new client from the command context.
179184
// It reads from global configuration files if flags are not set.
180185
func createClient(cmd *cobra.Command) (*codersdk.Client, error) {
@@ -471,8 +476,8 @@ download the server version with: 'curl -L https://coder.com/install.sh | sh -s
471476
if !buildinfo.VersionsMatch(clientVersion, info.Version) {
472477
warn := cliui.Styles.Warn.Copy().Align(lipgloss.Left)
473478
// Trim the leading 'v', our install.sh script does not handle this case well.
474-
_, _ = fmt.Fprintf(cmd.OutOrStdout(), warn.Render(fmtWarningText), clientVersion, info.Version, strings.TrimPrefix(info.CanonicalVersion(), "v"))
475-
_, _ = fmt.Fprintln(cmd.OutOrStdout())
479+
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), warn.Render(fmtWarningText), clientVersion, info.Version, strings.TrimPrefix(info.CanonicalVersion(), "v"))
480+
_, _ = fmt.Fprintln(cmd.ErrOrStderr())
476481
}
477482

478483
return nil

cli/root_internal_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cli
22

33
import (
4+
"os"
45
"testing"
56

67
"github.com/stretchr/testify/require"
@@ -64,3 +65,9 @@ func Test_formatExamples(t *testing.T) {
6465
})
6566
}
6667
}
68+
69+
func TestMain(m *testing.M) {
70+
// Replace with goleak.VerifyTestMain(m) when we enable goleak.
71+
os.Exit(m.Run())
72+
// goleak.VerifyTestMain(m)
73+
}

0 commit comments

Comments
 (0)