Skip to content

Commit 913d141

Browse files
committed
Merge remote-tracking branch 'origin/main' into stevenmasley/rbac
2 parents 5a2834a + 4dd3c57 commit 913d141

File tree

113 files changed

+4404
-3262
lines changed

Some content is hidden

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

113 files changed

+4404
-3262
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ updates:
2727
- package-ecosystem: "gomod"
2828
directory: "/"
2929
schedule:
30-
interval: "daily"
30+
interval: "weekly"
3131
time: "06:00"
3232
timezone: "America/Chicago"
3333
commit-message:
@@ -36,7 +36,7 @@ updates:
3636
- package-ecosystem: "npm"
3737
directory: "/site/"
3838
schedule:
39-
interval: "daily"
39+
interval: "weekly"
4040
time: "06:00"
4141
timezone: "America/Chicago"
4242
commit-message:

.github/semantic.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
# https://www.notion.so/coderhq/Conventional-commits-1d51287f58b64026bb29393f277734ed
88
###############################################################################
99

10+
# We have no valid scopes right now.
11+
# A scope should be added when commits aren't aligning with associated change anymore.
12+
scopes:
13+
1014
# We only check that the PR title is semantic. The PR title is automatically
1115
# applied to the "Squash & Merge" flow as the suggested commit message, so this
1216
# should suffice unless someone drastically alters the message in that flow.

.github/workflows/coder.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ jobs:
8989

9090
- run: go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
9191
- run: go install storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.26
92+
- run: go install golang.org/x/tools/cmd/goimports@latest
9293
- run: "make --output-sync -j gen"
9394
- run: ./scripts/check_unstaged.sh
9495

@@ -323,6 +324,17 @@ jobs:
323324
with:
324325
install-only: true
325326

327+
- name: Cache Node
328+
id: cache-node
329+
uses: actions/cache@v3
330+
with:
331+
path: |
332+
**/node_modules
333+
.eslintcache
334+
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
335+
restore-keys: |
336+
js-${{ runner.os }}-
337+
326338
- name: Build Release
327339
run: make release
328340

.github/workflows/release.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,38 @@ jobs:
1414
with:
1515
go-version: "~1.18"
1616

17+
- name: Echo Go Cache Paths
18+
id: go-cache-paths
19+
run: |
20+
echo "::set-output name=go-build::$(go env GOCACHE)"
21+
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
22+
23+
- name: Go Build Cache
24+
uses: actions/cache@v3
25+
with:
26+
path: ${{ steps.go-cache-paths.outputs.go-build }}
27+
key: ${{ runner.os }}-release-go-build-${{ hashFiles('**/go.sum') }}
28+
29+
- name: Go Mod Cache
30+
uses: actions/cache@v3
31+
with:
32+
path: ${{ steps.go-cache-paths.outputs.go-mod }}
33+
key: ${{ runner.os }}-release-go-mod-${{ hashFiles('**/go.sum') }}
34+
35+
- name: Cache Node
36+
id: cache-node
37+
uses: actions/cache@v3
38+
with:
39+
path: |
40+
**/node_modules
41+
.eslintcache
42+
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
43+
restore-keys: |
44+
js-${{ runner.os }}-
45+
46+
- name: Build Site
47+
run: make site/out
48+
1749
- name: Run GoReleaser
1850
uses: goreleaser/goreleaser-action@v2.9.1
1951
with:

.golangci.yml

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -177,26 +177,6 @@ linters-settings:
177177
- name: var-declaration
178178
- name: var-naming
179179
- name: waitgroup-by-value
180-
varnamelen:
181-
ignore-names:
182-
- err
183-
- rw
184-
- r
185-
- i
186-
- db
187-
- t
188-
- id
189-
- wg
190-
# Optional list of variable declarations that should be ignored completely. (defaults to empty list)
191-
# Entries must be in the form of "<variable name> <type>" or "<variable name> *<type>" for
192-
# variables, or "const <name>" for constants.
193-
ignore-decls:
194-
- rw http.ResponseWriter
195-
- r *http.Request
196-
- t testing.T
197-
- t testing.TB
198-
- ok bool
199-
- wg sync.WaitGroup
200180

201181
issues:
202182
# Rules listed here: https://github.com/securego/gosec#available-rules
@@ -251,11 +231,17 @@ linters:
251231
- staticcheck
252232
- structcheck
253233
- tenv
234+
# In Go, it's possible for a package to test it's internal functionality
235+
# without testing any exported functions. This is enabled to promote
236+
# decomposing a package before testing it's internals. A function caller
237+
# should be able to test most of the functionality from exported functions.
238+
#
239+
# There are edge-cases to this rule, but they should be carefully considered
240+
# to avoid structural inconsistency.
254241
- testpackage
255242
- tparallel
256243
- typecheck
257244
- unconvert
258245
- unused
259246
- varcheck
260-
- varnamelen
261247
- wastedassign

.goreleaser.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ archives:
44
- coder
55
files:
66
- README.md
7+
format_overrides:
8+
- goos: windows
9+
format: zip
710

811
before:
912
hooks:

Makefile

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ build: site/out bin
1212
# Runs migrations to output a dump of the database.
1313
coderd/database/dump.sql: $(wildcard coderd/database/migrations/*.sql)
1414
go run coderd/database/dump/main.go
15+
.PHONY: coderd/database/dump.sql
1516

1617
# Generates Go code for querying the database.
17-
coderd/database/generate: fmt/sql coderd/database/dump.sql coderd/database/query.sql
18-
cd coderd/database && sqlc generate && rm db_tmp.go
19-
cd coderd/database && gofmt -w -r 'Querier -> querier' *.go
20-
cd coderd/database && gofmt -w -r 'Queries -> sqlQuerier' *.go
18+
coderd/database/generate: fmt/sql coderd/database/dump.sql $(wildcard coderd/database/queries/*.sql)
19+
coderd/database/generate.sh
2120
.PHONY: coderd/database/generate
2221

2322
fmt/prettier:
@@ -30,13 +29,18 @@ else
3029
endif
3130
.PHONY: fmt/prettier
3231

33-
fmt/sql: ./coderd/database/query.sql
34-
npx sql-formatter \
35-
--language postgresql \
36-
--lines-between-queries 2 \
37-
./coderd/database/query.sql \
38-
--output ./coderd/database/query.sql
39-
sed -i 's/@ /@/g' ./coderd/database/query.sql
32+
fmt/sql: $(wildcard coderd/database/queries/*.sql)
33+
# TODO: this is slightly slow
34+
for fi in coderd/database/queries/*.sql; do \
35+
npx sql-formatter \
36+
--language postgresql \
37+
--lines-between-queries 2 \
38+
--tab-indent \
39+
$$fi \
40+
--output $$fi; \
41+
done
42+
43+
sed -i 's/@ /@/g' ./coderd/database/queries/*.sql
4044

4145
fmt: fmt/prettier fmt/sql
4246
.PHONY: fmt

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ $ coder workspaces create my-first-workspace
5151
$ coder ssh my-first-workspace
5252
```
5353

54+
### Working with Projects
55+
56+
You can edit the Terraform from a sample project:
57+
58+
```sh
59+
$ coder projects init
60+
$ cd gcp-linux/
61+
$ vim main.tf
62+
$ coder projects update gcp-linux
63+
```
64+
5465
## Development
5566

5667
The code structure is inspired by [Basics of Unix Philosophy](https://homepage.cs.uri.edu/~thenry/resources/unix_art/ch01s06.html) and [Effective Go](https://go.dev/doc/effective_go).

cli/cliui/cliui_darwin.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//go:build darwin
2+
// +build darwin
3+
4+
package cliui
5+
6+
import (
7+
"golang.org/x/sys/unix"
8+
9+
"golang.org/x/xerrors"
10+
)
11+
12+
func removeLineLengthLimit(inputFD int) (func(), error) {
13+
termios, err := unix.IoctlGetTermios(inputFD, unix.TIOCGETA)
14+
if err != nil {
15+
return nil, xerrors.Errorf("get termios: %w", err)
16+
}
17+
newState := *termios
18+
// MacOS has a default line limit of 1024. See:
19+
// https://unix.stackexchange.com/questions/204815/terminal-does-not-accept-pasted-or-typed-lines-of-more-than-1024-characters
20+
//
21+
// This removes canonical input processing, so deletes will not function
22+
// as expected. This _seems_ fine for most use-cases, but is unfortunate.
23+
newState.Lflag &^= unix.ICANON
24+
err = unix.IoctlSetTermios(inputFD, unix.TIOCSETA, &newState)
25+
if err != nil {
26+
return nil, xerrors.Errorf("set termios: %w", err)
27+
}
28+
return func() {
29+
_ = unix.IoctlSetTermios(inputFD, unix.TIOCSETA, termios)
30+
}, nil
31+
}

cli/cliui/cliui_other.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//go:build !darwin
2+
// +build !darwin
3+
4+
package cliui
5+
6+
import "golang.org/x/xerrors"
7+
8+
func removeLineLengthLimit(_ int) (func(), error) {
9+
return nil, xerrors.New("not implemented")
10+
}

0 commit comments

Comments
 (0)