Skip to content

Commit 8b2f6c4

Browse files
committed
Merge branch 'main' into devurls
2 parents bdfa61a + 7bb7c6c commit 8b2f6c4

File tree

227 files changed

+6757
-1974
lines changed

Some content is hidden

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

227 files changed

+6757
-1974
lines changed

.github/ISSUE_TEMPLATE/bug-report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Bug report
33
about: Report a bug
44
title: "Bug: "
5-
labels: "bug :bug:"
5+
labels: ["bug :bug:", "needs grooming :razor:"]
66
---
77

88
## OS Information

.github/ISSUE_TEMPLATE/doc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Documentation improvement
33
about: Suggest a documentation improvement
44
title: "Docs: "
5-
labels: "documentation :memo:"
5+
labels: ["documentation :memo:", "needs grooming :razor:"]
66
---
77

88
## What is your suggestion?

.github/ISSUE_TEMPLATE/feature.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Feature request
33
about: Suggest an idea to improve coder
44
title: "Feat: "
5-
labels: "new feature :sparkles:"
5+
labels: ["new feature :sparkles:", "needs grooming :razor:"]
66
---
77

88
## What is your suggestion?

.github/codecov.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
codecov:
2+
require_ci_to_pass: false
3+
4+
comment: false
5+
6+
github_checks:
7+
annotations: false
8+
9+
coverage:
10+
status:
11+
patch:
12+
default:
13+
informational: yes
14+
project:
15+
default:
16+
target: 70%
17+
informational: yes
18+
19+
ignore:
20+
# This is generated code.
21+
- coderd/database/models.go
22+
- coderd/database/query.sql.go
23+
- coderd/database/databasefake
24+
# These are generated or don't require tests.
25+
- cmd
26+
- coderd/tunnel
27+
- coderd/database/dump
28+
- coderd/database/postgres
29+
- peerbroker/proto
30+
- provisionerd/proto
31+
- provisionersdk/proto
32+
- scripts/datadog-cireport
33+
- site/.storybook
34+
- rules.go

.github/workflows/coder.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
- name: golangci-lint
4343
uses: golangci/golangci-lint-action@v3.1.0
4444
with:
45-
version: v1.45.2
45+
version: v1.46.0
4646

4747
style-lint-typescript:
4848
name: "style/lint/typescript"

.github/workflows/release.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,32 @@ on:
33
push:
44
tags:
55
- "v*"
6+
workflow_dispatch:
7+
68
jobs:
79
goreleaser:
810
runs-on: macos-latest
11+
env:
12+
# Necessary for Docker manifest
13+
DOCKER_CLI_EXPERIMENTAL: "enabled"
914
steps:
15+
# Docker is not included on macos-latest
16+
- uses: docker-practice/actions-setup-docker@v1.0.8
17+
1018
- uses: actions/checkout@v3
1119
with:
1220
fetch-depth: 0
21+
22+
- name: Set up QEMU
23+
uses: docker/setup-qemu-action@v1
24+
25+
- name: Docker Login
26+
uses: docker/login-action@v1
27+
with:
28+
registry: ghcr.io
29+
username: ${{ github.repository_owner }}
30+
password: ${{ secrets.GITHUB_TOKEN }}
31+
1332
- uses: actions/setup-go@v3
1433
with:
1534
go-version: "~1.18"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ site/out/
3737
.terraform/
3838

3939
.vscode/*.log
40+
**/*.swp

.golangci.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ linters-settings:
7777
# - sloppyReassign
7878
- sloppyTypeAssert
7979
- sortSlice
80-
# - sprintfQuotedString
80+
- sprintfQuotedString
8181
- sqlQuery
8282
# - stringConcatSimplify
8383
# - stringXbytes
@@ -105,6 +105,13 @@ linters-settings:
105105
failOn: all
106106
rules: rules.go
107107

108+
staticcheck:
109+
# https://staticcheck.io/docs/options#checks
110+
# We disable SA1019 because it gets angry about our usage of xerrors. We
111+
# intentionally xerrors because stack frame support didn't make it into the
112+
# stdlib port.
113+
checks: ["all", "-SA1019"]
114+
108115
goimports:
109116
local-prefixes: coder.com,cdr.dev,go.coder.com,github.com/cdr,github.com/coder
110117

@@ -235,7 +242,7 @@ linters:
235242
# without testing any exported functions. This is enabled to promote
236243
# decomposing a package before testing it's internals. A function caller
237244
# should be able to test most of the functionality from exported functions.
238-
#
245+
#
239246
# There are edge-cases to this rule, but they should be carefully considered
240247
# to avoid structural inconsistency.
241248
- testpackage

.goreleaser.yaml

Lines changed: 64 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,46 +28,50 @@ before:
2828
builds:
2929
- id: coder-slim
3030
dir: cmd/coder
31-
ldflags:
32-
["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"]
31+
ldflags: ["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"]
3332
env: [CGO_ENABLED=0]
3433
goos: [darwin, linux, windows]
35-
goarch: [amd64]
34+
goarch: [amd64, arm, arm64]
35+
goarm: ["7"]
36+
# Only build arm 7 for Linux
37+
ignore:
38+
- goos: windows
39+
goarm: "7"
40+
- goos: darwin
41+
goarm: "7"
3642
hooks:
3743
# The "trimprefix" appends ".exe" on Windows.
3844
post: |
39-
cp {{.Path}} site/out/bin/coder-{{ .Os }}-{{ .Arch }}{{ trimprefix .Name "coder" }}
45+
cp {{.Path}} site/out/bin/coder-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ trimprefix .Name "coder" }}
4046
4147
- id: coder-linux
4248
dir: cmd/coder
4349
flags: [-tags=embed]
44-
ldflags:
45-
["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"]
50+
ldflags: ["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"]
4651
env: [CGO_ENABLED=0]
4752
goos: [linux]
48-
goarch: [amd64, arm64]
53+
goarch: [amd64, arm, arm64]
54+
goarm: ["7"]
4955

5056
- id: coder-windows
5157
dir: cmd/coder
5258
flags: [-tags=embed]
53-
ldflags:
54-
["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"]
59+
ldflags: ["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"]
5560
env: [CGO_ENABLED=0]
5661
goos: [windows]
5762
goarch: [amd64, arm64]
5863

5964
- id: coder-darwin
6065
dir: cmd/coder
6166
flags: [-tags=embed]
62-
ldflags:
63-
["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"]
67+
ldflags: ["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"]
6468
env: [CGO_ENABLED=0]
6569
goos: [darwin]
6670
goarch: [amd64, arm64]
6771
hooks:
6872
# This signs the binary that will be located inside the zip.
6973
# MacOS requires the binary to be signed for notarization.
70-
#
74+
#
7175
# If it doesn't successfully sign, the zip sign step will error.
7276
post: |
7377
sh -c 'codesign -s {{.Env.AC_APPLICATION_IDENTITY}} -f -v --timestamp --options runtime {{.Path}} || true'
@@ -99,6 +103,54 @@ nfpms:
99103
- src: coder.service
100104
dst: /usr/lib/systemd/system/coder.service
101105

106+
dockers:
107+
- image_templates: ["ghcr.io/coder/coder:{{ .Tag }}-amd64"]
108+
id: coder-linux
109+
dockerfile: Dockerfile
110+
use: buildx
111+
build_flag_templates:
112+
- --platform=linux/amd64
113+
- --label=org.opencontainers.image.title=Coder
114+
- --label=org.opencontainers.image.description=A tool for provisioning self-hosted development environments with Terraform.
115+
- --label=org.opencontainers.image.url=https://github.com/coder/coder
116+
- --label=org.opencontainers.image.source=https://github.com/coder/coder
117+
- --label=org.opencontainers.image.version={{ .Version }}
118+
- --label=org.opencontainers.image.revision={{ .FullCommit }}
119+
- --label=org.opencontainers.image.licenses=AGPL-3.0
120+
- image_templates: ["ghcr.io/coder/coder:{{ .Tag }}-arm64"]
121+
goarch: arm64
122+
dockerfile: Dockerfile
123+
use: buildx
124+
build_flag_templates:
125+
- --platform=linux/arm64/v8
126+
- --label=org.opencontainers.image.title=coder
127+
- --label=org.opencontainers.image.description=A tool for provisioning self-hosted development environments with Terraform.
128+
- --label=org.opencontainers.image.url=https://github.com/coder/coder
129+
- --label=org.opencontainers.image.source=https://github.com/coder/coder
130+
- --label=org.opencontainers.image.version={{ .Tag }}
131+
- --label=org.opencontainers.image.revision={{ .FullCommit }}
132+
- --label=org.opencontainers.image.licenses=AGPL-3.0
133+
- image_templates: ["ghcr.io/coder/coder:{{ .Tag }}-armv7"]
134+
goarch: arm
135+
goarm: "7"
136+
dockerfile: Dockerfile
137+
use: buildx
138+
build_flag_templates:
139+
- --platform=linux/arm/v7
140+
- --label=org.opencontainers.image.title=Coder
141+
- --label=org.opencontainers.image.description=A tool for provisioning self-hosted development environments with Terraform.
142+
- --label=org.opencontainers.image.url=https://github.com/coder/coder
143+
- --label=org.opencontainers.image.source=https://github.com/coder/coder
144+
- --label=org.opencontainers.image.version={{ .Tag }}
145+
- --label=org.opencontainers.image.revision={{ .FullCommit }}
146+
- --label=org.opencontainers.image.licenses=AGPL-3.0
147+
docker_manifests:
148+
- name_template: ghcr.io/coder/coder:{{ .Tag }}
149+
image_templates:
150+
- ghcr.io/coder/coder:{{ .Tag }}-amd64
151+
- ghcr.io/coder/coder:{{ .Tag }}-arm64
152+
- ghcr.io/coder/coder:{{ .Tag }}-armv7
153+
102154
release:
103155
ids: [coder-linux, coder-darwin, coder-windows, packages]
104156

.vscode/extensions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"emeraldwalk.runonsave",
88
"zxh404.vscode-proto3",
99
"redhat.vscode-yaml",
10-
"streetsidesoftware.code-spell-checker"
10+
"streetsidesoftware.code-spell-checker",
11+
"dbaeumer.vscode-eslint"
1112
]
1213
}

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM alpine
2+
3+
# Generated by goreleaser on `goreleaser release`
4+
ADD coder /opt/coder
5+
6+
ENTRYPOINT [ "/opt/coder", "server" ]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ site/out/index.html: $(shell find ./site -not -path './site/node_modules/*' -typ
8383
# Restores GITKEEP files!
8484
git checkout HEAD site/out
8585

86-
site/src/api/typesGenerated.ts: $(shell find codersdk -type f -name '*.go')
86+
site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find codersdk -type f -name '*.go')
8787
go run scripts/apitypings/main.go > site/src/api/typesGenerated.ts
8888
cd site && yarn run format:types
8989

cli/autostart.go

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
"github.com/spf13/cobra"
99

10-
"github.com/coder/coder/coderd/autostart/schedule"
10+
"github.com/coder/coder/coderd/autobuild/schedule"
1111
"github.com/coder/coder/codersdk"
1212
)
1313

@@ -18,19 +18,59 @@ The default schedule is at 09:00 in your local timezone (TZ env, UTC by default)
1818

1919
func autostart() *cobra.Command {
2020
autostartCmd := &cobra.Command{
21-
Use: "autostart enable <workspace>",
22-
Short: "schedule a workspace to automatically start at a regular time",
23-
Long: autostartDescriptionLong,
24-
Example: "coder autostart enable my-workspace --minute 30 --hour 9 --days 1-5 --tz Europe/Dublin",
25-
Hidden: true,
21+
Annotations: workspaceCommand,
22+
Use: "autostart enable <workspace>",
23+
Short: "schedule a workspace to automatically start at a regular time",
24+
Long: autostartDescriptionLong,
25+
Example: "coder autostart enable my-workspace --minute 30 --hour 9 --days 1-5 --tz Europe/Dublin",
2626
}
2727

28+
autostartCmd.AddCommand(autostartShow())
2829
autostartCmd.AddCommand(autostartEnable())
2930
autostartCmd.AddCommand(autostartDisable())
3031

3132
return autostartCmd
3233
}
3334

35+
func autostartShow() *cobra.Command {
36+
cmd := &cobra.Command{
37+
Use: "show <workspace_name>",
38+
Args: cobra.ExactArgs(1),
39+
RunE: func(cmd *cobra.Command, args []string) error {
40+
client, err := createClient(cmd)
41+
if err != nil {
42+
return err
43+
}
44+
organization, err := currentOrganization(cmd, client)
45+
if err != nil {
46+
return err
47+
}
48+
49+
workspace, err := client.WorkspaceByOwnerAndName(cmd.Context(), organization.ID, codersdk.Me, args[0])
50+
if err != nil {
51+
return err
52+
}
53+
54+
if workspace.AutostartSchedule == "" {
55+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "not enabled\n")
56+
return nil
57+
}
58+
59+
validSchedule, err := schedule.Weekly(workspace.AutostartSchedule)
60+
if err != nil {
61+
// This should never happen.
62+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "invalid autostart schedule %q for workspace %s: %s\n", workspace.AutostartSchedule, workspace.Name, err.Error())
63+
return nil
64+
}
65+
66+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "schedule: %s\nnext: %s\n", workspace.AutostartSchedule, validSchedule.Next(time.Now()))
67+
68+
return nil
69+
},
70+
}
71+
return cmd
72+
}
73+
3474
func autostartEnable() *cobra.Command {
3575
// yes some of these are technically numbers but the cron library will do that work
3676
var autostartMinute string

0 commit comments

Comments
 (0)