Skip to content

Commit cbab7f2

Browse files
committed
Merge branch 'main' into templateeditor
2 parents 5368132 + 6c90701 commit cbab7f2

File tree

205 files changed

+6413
-2139
lines changed

Some content is hidden

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

205 files changed

+6413
-2139
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ RUN mkdir -p /etc/apt/keyrings \
5757
&& echo '{"cgroup-parent":"/actions_job","storage-driver":"vfs"}' >> /etc/docker/daemon.json
5858

5959
# install golang and language tooling
60-
ENV GO_VERSION=1.19
60+
ENV GO_VERSION=1.20
6161
ENV GOPATH=$HOME/go-packages
6262
ENV GOROOT=$HOME/go
6363
ENV PATH=$GOROOT/bin:$GOPATH/bin:$PATH

.github/workflows/ci.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ concurrency:
2929

3030
jobs:
3131
lint:
32-
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
32+
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-8-cores' || 'ubuntu-latest' }}
3333
steps:
3434
- name: Checkout
3535
uses: actions/checkout@v3
3636

3737
# Install Go!
3838
- uses: actions/setup-go@v3
3939
with:
40-
go-version: "~1.19"
40+
go-version: "~1.20"
4141

4242
# Check for any typos!
4343
- name: Check for typos
@@ -55,10 +55,10 @@ jobs:
5555
- name: Lint Go
5656
uses: golangci/golangci-lint-action@v3.3.1
5757
with:
58-
version: v1.48.0
58+
version: v1.51.0
5959

6060
- name: Lint shell scripts
61-
uses: ludeeus/action-shellcheck@1.1.0
61+
uses: ludeeus/action-shellcheck@2.0.0
6262
env:
6363
SHELLCHECK_OPTS: --external-sources
6464
with:
@@ -129,7 +129,7 @@ jobs:
129129
130130
gen:
131131
timeout-minutes: 8
132-
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
132+
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-8-cores' || 'ubuntu-latest' }}
133133
needs: changes
134134
if: needs.changes.outputs.docs-only == 'false'
135135
steps:
@@ -151,7 +151,7 @@ jobs:
151151

152152
- uses: actions/setup-go@v3
153153
with:
154-
go-version: "~1.19"
154+
go-version: "~1.20"
155155

156156
- name: Echo Go Cache Paths
157157
id: go-cache-paths
@@ -237,7 +237,7 @@ jobs:
237237
run: ./scripts/check_unstaged.sh
238238

239239
test-go:
240-
runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'windows-latest-8-cores'|| matrix.os }}
240+
runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'ubuntu-latest-8-cores' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'windows-latest-8-cores'|| matrix.os }}
241241
timeout-minutes: 20
242242
strategy:
243243
matrix:
@@ -250,7 +250,7 @@ jobs:
250250

251251
- uses: actions/setup-go@v3
252252
with:
253-
go-version: "~1.19"
253+
go-version: "~1.20"
254254

255255
# Sadly the new "set output" syntax (of writing env vars to
256256
# $GITHUB_OUTPUT) does not work on both powershell and bash so we use the
@@ -322,7 +322,7 @@ jobs:
322322
flags: unittest-go-${{ matrix.os }}
323323

324324
test-go-psql:
325-
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
325+
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-8-cores' || 'ubuntu-latest' }}
326326
# This timeout must be greater than the timeout set by `go test` in
327327
# `make test-postgres` to ensure we receive a trace of running
328328
# goroutines. Setting this to the timeout +5m should work quite well
@@ -333,7 +333,7 @@ jobs:
333333

334334
- uses: actions/setup-go@v3
335335
with:
336-
go-version: "~1.19"
336+
go-version: "~1.20"
337337

338338
- name: Echo Go Cache Paths
339339
id: go-cache-paths
@@ -391,7 +391,7 @@ jobs:
391391

392392
deploy:
393393
name: "deploy"
394-
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
394+
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-8-cores' || 'ubuntu-latest' }}
395395
timeout-minutes: 30
396396
needs: changes
397397
if: |
@@ -416,7 +416,7 @@ jobs:
416416

417417
- uses: actions/setup-go@v3
418418
with:
419-
go-version: "~1.19"
419+
go-version: "~1.20"
420420

421421
- name: Echo Go Cache Paths
422422
id: go-cache-paths
@@ -487,7 +487,7 @@ jobs:
487487
retention-days: 7
488488

489489
test-js:
490-
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
490+
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-8-cores' || 'ubuntu-latest' }}
491491
timeout-minutes: 20
492492
steps:
493493
- uses: actions/checkout@v3
@@ -529,7 +529,7 @@ jobs:
529529
needs:
530530
- changes
531531
if: needs.changes.outputs.docs-only == 'false'
532-
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
532+
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-8-cores' || 'ubuntu-latest' }}
533533
timeout-minutes: 20
534534
steps:
535535
- uses: actions/checkout@v3
@@ -545,7 +545,7 @@ jobs:
545545

546546
- uses: actions/setup-go@v3
547547
with:
548-
go-version: "~1.19"
548+
go-version: "~1.20"
549549

550550
- uses: hashicorp/setup-terraform@v2
551551
with:

.github/workflows/dogfood.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
password: ${{ secrets.DOCKERHUB_PASSWORD }}
4141

4242
- name: Build and push
43-
uses: docker/build-push-action@v3
43+
uses: docker/build-push-action@v4
4444
with:
4545
context: "{{defaultContext}}:dogfood"
4646
push: true

.github/workflows/release.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ env:
3232
jobs:
3333
release:
3434
name: Build and publish
35-
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
35+
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-8-cores' || 'ubuntu-latest' }}
3636
env:
3737
# Necessary for Docker manifest
3838
DOCKER_CLI_EXPERIMENTAL: "enabled"
@@ -91,7 +91,7 @@ jobs:
9191

9292
- uses: actions/setup-go@v3
9393
with:
94-
go-version: "~1.19"
94+
go-version: "~1.20"
9595

9696
- name: Cache Node
9797
id: cache-node
@@ -214,7 +214,7 @@ jobs:
214214
./build/*.rpm
215215
env:
216216
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
217-
CODER_GPG_RELEASE_KEY_BASE64: ${{ secrets.CODER_GPG_RELEASE_KEY_BASE64 }}
217+
CODER_GPG_RELEASE_KEY_BASE64: ${{ secrets.GPG_RELEASE_KEY_BASE64 }}
218218

219219
- name: Authenticate to Google Cloud
220220
uses: google-github-actions/auth@v1
@@ -333,3 +333,11 @@ jobs:
333333
# For gh CLI. We need a real token since we're commenting on a PR in a
334334
# different repo.
335335
GH_TOKEN: ${{ secrets.CDRCI_GITHUB_TOKEN }}
336+
337+
- name: Start Packer builds
338+
uses: peter-evans/repository-dispatch@v2
339+
with:
340+
token: ${{ secrets.CDRCI_GITHUB_TOKEN }}
341+
repository: coder/packages
342+
event-type: coder-release
343+
client-payload: '{"coder_version": "${{ needs.release.outputs.version }}"}'

.github/workflows/security.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ concurrency:
2626

2727
jobs:
2828
codeql:
29-
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
29+
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-8-cores' || 'ubuntu-latest' }}
3030
steps:
3131
- uses: actions/checkout@v3
3232

@@ -38,7 +38,7 @@ jobs:
3838
- name: Setup Go
3939
uses: actions/setup-go@v3
4040
with:
41-
go-version: "~1.19"
41+
go-version: "~1.20"
4242

4343
- name: Go Cache Paths
4444
id: go-cache-paths
@@ -60,15 +60,15 @@ jobs:
6060
uses: github/codeql-action/analyze@v2
6161

6262
trivy:
63-
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }}
63+
runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-8-cores' || 'ubuntu-latest' }}
6464
steps:
6565
- uses: actions/checkout@v3
6666
with:
6767
fetch-depth: 0
6868

6969
- uses: actions/setup-go@v3
7070
with:
71-
go-version: "~1.19"
71+
go-version: "~1.20"
7272

7373
- name: Go Cache Paths
7474
id: go-cache-paths
@@ -101,7 +101,7 @@ jobs:
101101
echo "image=$(cat "$image_job")" >> $GITHUB_OUTPUT
102102
103103
- name: Run Trivy vulnerability scanner
104-
uses: aquasecurity/trivy-action@7b7aa264d83dc58691451798b4d117d53d21edfe
104+
uses: aquasecurity/trivy-action@9ab158e8597f3b310480b9a69402b419bc03dbd5
105105
with:
106106
image-ref: ${{ steps.build.outputs.image }}
107107
format: sarif

.github/workflows/typos.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ MacOS = "macOS"
66
AKS = "AKS"
77

88
[default.extend-words]
9+
AKS = "AKS"
910
# do as sudo replacement
1011
doas = "doas"
1112
darcula = "darcula"

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
<div align="center">
2-
<img src="./docs/images/logo.png" style="width: 128px">
2+
<a href="https://coder.com#gh-light-mode-only">
3+
<img src="./docs/images/logo-black.png" style="width: 128px">
4+
</a>
5+
<a href="https://coder.com#gh-dark-mode-only">
6+
<img src="./docs/images/logo-white.png" style="width: 128px">
7+
</a>
38

49
<h1>
510
Self-Hosted Remote Development Environments
611
</h1>
712

8-
<img src="./docs/images/banner.png" style="width: 650px">
13+
<a href="https://coder.com#gh-light-mode-only">
14+
<img src="./docs/images/banner-black.png" style="width: 650px">
15+
</a>
16+
<a href="https://coder.com#gh-dark-mode-only">
17+
<img src="./docs/images/banner-white.png" style="width: 650px">
18+
</a>
919

1020
<br>
1121
<br>
@@ -14,7 +24,7 @@
1424

1525
[![discord](https://img.shields.io/discord/747933592273027093?label=discord)](https://discord.gg/coder)
1626
[![codecov](https://codecov.io/gh/coder/coder/branch/main/graph/badge.svg?token=TNLW3OAP6G)](https://codecov.io/gh/coder/coder)
17-
[![release](https://img.shields.io/github/v/release/coder/coder)](https://github.com/coder/coder/releases)
27+
[![release](https://img.shields.io/github/v/release/coder/coder)](https://github.com/coder/coder/releases/latest)
1828
[![godoc](https://pkg.go.dev/badge/github.com/coder/coder.svg)](https://pkg.go.dev/github.com/coder/coder)
1929
[![Go Report Card](https://goreportcard.com/badge/github.com/coder/coder)](https://goreportcard.com/report/github.com/coder/coder)
2030
[![license](https://img.shields.io/github/license/coder/coder)](./LICENSE)

agent/agent.go

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const (
6060

6161
type Options struct {
6262
Filesystem afero.Fs
63+
LogDir string
6364
TempDir string
6465
ExchangeToken func(ctx context.Context) (string, error)
6566
Client Client
@@ -87,6 +88,12 @@ func New(options Options) io.Closer {
8788
if options.TempDir == "" {
8889
options.TempDir = os.TempDir()
8990
}
91+
if options.LogDir == "" {
92+
if options.TempDir != os.TempDir() {
93+
options.Logger.Debug(context.Background(), "log dir not set, using temp dir", slog.F("temp_dir", options.TempDir))
94+
}
95+
options.LogDir = options.TempDir
96+
}
9097
if options.ExchangeToken == nil {
9198
options.ExchangeToken = func(ctx context.Context) (string, error) {
9299
return "", nil
@@ -102,6 +109,7 @@ func New(options Options) io.Closer {
102109
client: options.Client,
103110
exchangeToken: options.ExchangeToken,
104111
filesystem: options.Filesystem,
112+
logDir: options.LogDir,
105113
tempDir: options.TempDir,
106114
lifecycleUpdate: make(chan struct{}, 1),
107115
}
@@ -114,6 +122,7 @@ type agent struct {
114122
client Client
115123
exchangeToken func(ctx context.Context) (string, error)
116124
filesystem afero.Fs
125+
logDir string
117126
tempDir string
118127

119128
reconnectingPTYs sync.Map
@@ -517,23 +526,23 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (_
517526
return nil, err
518527
}
519528

520-
statisticsListener, err := network.Listen("tcp", ":"+strconv.Itoa(codersdk.WorkspaceAgentStatisticsPort))
529+
apiListener, err := network.Listen("tcp", ":"+strconv.Itoa(codersdk.WorkspaceAgentHTTPAPIServerPort))
521530
if err != nil {
522-
return nil, xerrors.Errorf("listen for statistics: %w", err)
531+
return nil, xerrors.Errorf("api listener: %w", err)
523532
}
524533
defer func() {
525534
if err != nil {
526-
_ = statisticsListener.Close()
535+
_ = apiListener.Close()
527536
}
528537
}()
529538
if err = a.trackConnGoroutine(func() {
530-
defer statisticsListener.Close()
539+
defer apiListener.Close()
531540
server := &http.Server{
532-
Handler: a.statisticsHandler(),
541+
Handler: a.apiHandler(),
533542
ReadTimeout: 20 * time.Second,
534543
ReadHeaderTimeout: 20 * time.Second,
535544
WriteTimeout: 20 * time.Second,
536-
ErrorLog: slog.Stdlib(ctx, a.logger.Named("statistics_http_server"), slog.LevelInfo),
545+
ErrorLog: slog.Stdlib(ctx, a.logger.Named("http_api_server"), slog.LevelInfo),
537546
}
538547
go func() {
539548
select {
@@ -543,9 +552,9 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (_
543552
_ = server.Close()
544553
}()
545554

546-
err := server.Serve(statisticsListener)
555+
err := server.Serve(apiListener)
547556
if err != nil && !xerrors.Is(err, http.ErrServerClosed) && !strings.Contains(err.Error(), "use of closed network connection") {
548-
a.logger.Critical(ctx, "serve statistics HTTP server", slog.Error(err))
557+
a.logger.Critical(ctx, "serve HTTP API server", slog.Error(err))
549558
}
550559
}); err != nil {
551560
return nil, err
@@ -582,7 +591,7 @@ func (a *agent) runStartupScript(ctx context.Context, script string) error {
582591
}
583592

584593
a.logger.Info(ctx, "running startup script", slog.F("script", script))
585-
writer, err := a.filesystem.OpenFile(filepath.Join(a.tempDir, "coder-startup-script.log"), os.O_CREATE|os.O_RDWR, 0o600)
594+
writer, err := a.filesystem.OpenFile(filepath.Join(a.logDir, "coder-startup-script.log"), os.O_CREATE|os.O_RDWR, 0o600)
586595
if err != nil {
587596
return xerrors.Errorf("open startup script log file: %w", err)
588597
}

agent/statsendpoint.go renamed to agent/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/coder/coder/codersdk"
1212
)
1313

14-
func (*agent) statisticsHandler() http.Handler {
14+
func (*agent) apiHandler() http.Handler {
1515
r := chi.NewRouter()
1616
r.Get("/", func(rw http.ResponseWriter, r *http.Request) {
1717
httpapi.Write(r.Context(), rw, http.StatusOK, codersdk.Response{

0 commit comments

Comments
 (0)