Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7c260f8

Browse files
authored
feat: Create provisioner abstraction (#12)
* feat: Create provisioner abstraction Creates a provisioner abstraction that takes prior art from the Terraform plugin system. It's safe to assume this code will change a lot when it becomes integrated with provisionerd. Closes #10. * Ignore generated files in diff view * Check for unstaged file changes * Install protoc-gen-go * Use proper drpc plugin version * Fix serve closed pipe * Install sqlc with curl for speed * Fix install command * Format CI action * Add linguist-generated and closed pipe test * Cleanup code from comments * Add dRPC comment * Add Terraform installer for cross-platform * Build provisioner tests on Linux only
1 parent 2769f4c commit 7c260f8

20 files changed

+1877
-14
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Generated files
2+
provisionersdk/proto/*.go linguist-generated=true

.github/workflows/coder.yaml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,28 @@ jobs:
3838
with:
3939
version: latest
4040

41+
gen:
42+
name: "style/gen"
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v2
46+
- name: Install Protoc
47+
uses: arduino/setup-protoc@v1
48+
with:
49+
version: "3.6.1"
50+
- uses: actions/setup-go@v2
51+
with:
52+
go-version: "^1.17"
53+
- run:
54+
curl -sSL
55+
https://github.com/kyleconroy/sqlc/releases/download/v1.11.0/sqlc_1.11.0_linux_amd64.tar.gz
56+
| sudo tar -C /usr/bin -xz sqlc
57+
58+
- run: go install google.golang.org/protobuf/cmd/[email protected]
59+
- run: go install storj.io/drpc/cmd/[email protected]
60+
- run: "make --output-sync -j gen"
61+
- run: ./scripts/check_unstaged.sh
62+
4163
style:
4264
name: "style/${{ matrix.style }}"
4365
runs-on: ubuntu-latest
@@ -95,7 +117,7 @@ jobs:
95117

96118
- run:
97119
gotestsum --jsonfile="gotests.json" --packages="./..." --
98-
-covermode=atomic -coverprofile="gotests.coverage"
120+
-covermode=atomic -coverprofile="gotests.coverage" -timeout=1m
99121

100122
- uses: codecov/codecov-action@v2
101123
with:

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"files.exclude": {
3+
"**/node_modules": true
4+
},
25
"go.lintTool": "golangci-lint",
36
"go.lintFlags": ["--fast"],
47
"go.lintOnSave": "package",

Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ database/dump.sql: $(wildcard database/migrations/*.sql)
33
go run database/dump/main.go
44

55
# Generates Go code for querying the database.
6-
.PHONY: database/generate
76
database/generate: database/dump.sql database/query.sql
87
cd database && sqlc generate && rm db_tmp.go
98
cd database && gofmt -w -r 'Querier -> querier' *.go
109
cd database && gofmt -w -r 'Queries -> sqlQuerier' *.go
10+
.PHONY: database/generate
1111

1212
fmt/prettier:
1313
@echo "--- prettier"
@@ -21,3 +21,16 @@ endif
2121

2222
fmt: fmt/prettier
2323
.PHONY: fmt
24+
25+
gen: database/generate provisionersdk/proto
26+
.PHONY: gen
27+
28+
# Generates the protocol files.
29+
provisionersdk/proto: provisionersdk/proto/provisioner.proto
30+
cd provisionersdk/proto && protoc \
31+
--go_out=. \
32+
--go_opt=paths=source_relative \
33+
--go-drpc_out=. \
34+
--go-drpc_opt=paths=source_relative \
35+
./provisioner.proto
36+
.PHONY: provisionersdk/proto

codecov.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,9 @@ coverage:
1616
status:
1717
project:
1818
default:
19-
target: 80%
19+
target: 75%
2020
informational: yes
21+
22+
ignore:
23+
# This is generated code.
24+
- provisionersdk/proto

go.mod

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@ module github.com/coder/coder
22

33
go 1.17
44

5+
// Required until https://github.com/hashicorp/terraform-config-inspect/pull/74 is merged.
6+
replace github.com/hashicorp/terraform-config-inspect => github.com/kylecarbs/terraform-config-inspect v0.0.0-20211215004401-bbc517866b88
7+
58
require (
69
cdr.dev/slog v1.4.1
710
github.com/golang-migrate/migrate/v4 v4.15.1
11+
github.com/google/uuid v1.3.0
12+
github.com/hashicorp/go-version v1.3.0
13+
github.com/hashicorp/hc-install v0.3.1
14+
github.com/hashicorp/terraform-config-inspect v0.0.0-20211115214459-90acf1ca460f
15+
github.com/hashicorp/terraform-exec v0.15.0
816
github.com/lib/pq v1.10.4
917
github.com/ory/dockertest/v3 v3.8.1
1018
github.com/pion/datachannel v1.5.2
@@ -15,13 +23,20 @@ require (
1523
go.uber.org/atomic v1.7.0
1624
go.uber.org/goleak v1.1.12
1725
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
26+
google.golang.org/protobuf v1.27.1
27+
storj.io/drpc v0.0.26
1828
)
1929

2030
require (
31+
cloud.google.com/go v0.92.3 // indirect
32+
cloud.google.com/go/storage v1.14.0 // indirect
2133
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
2234
github.com/Microsoft/go-winio v0.5.1 // indirect
2335
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
36+
github.com/agext/levenshtein v1.2.2 // indirect
2437
github.com/alecthomas/chroma v0.9.1 // indirect
38+
github.com/apparentlymart/go-textseg v1.0.0 // indirect
39+
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
2540
github.com/cenkalti/backoff/v4 v4.1.2 // indirect
2641
github.com/containerd/continuity v0.1.0 // indirect
2742
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect
@@ -35,13 +50,18 @@ require (
3550
github.com/fatih/color v1.12.0 // indirect
3651
github.com/gogo/protobuf v1.3.2 // indirect
3752
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
53+
github.com/google/go-cmp v0.5.6 // indirect
3854
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
39-
github.com/google/uuid v1.3.0 // indirect
4055
github.com/hashicorp/errwrap v1.0.0 // indirect
41-
github.com/hashicorp/go-multierror v1.1.0 // indirect
56+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
57+
github.com/hashicorp/go-multierror v1.1.1 // indirect
58+
github.com/hashicorp/hcl v1.0.0 // indirect
59+
github.com/hashicorp/hcl/v2 v2.0.0 // indirect
60+
github.com/hashicorp/terraform-json v0.13.0 // indirect
4261
github.com/imdario/mergo v0.3.12 // indirect
4362
github.com/mattn/go-colorable v0.1.8 // indirect
44-
github.com/mattn/go-isatty v0.0.12 // indirect
63+
github.com/mattn/go-isatty v0.0.13 // indirect
64+
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
4565
github.com/mitchellh/mapstructure v1.4.1 // indirect
4666
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
4767
github.com/opencontainers/go-digest v1.0.0 // indirect
@@ -66,11 +86,15 @@ require (
6686
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
6787
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
6888
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
89+
github.com/zclconf/go-cty v1.9.1 // indirect
90+
github.com/zeebo/errs v1.2.2 // indirect
6991
go.opencensus.io v0.23.0 // indirect
7092
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 // indirect
7193
golang.org/x/net v0.0.0-20211215060638-4ddde0e984e9 // indirect
7294
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c // indirect
73-
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
95+
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
96+
golang.org/x/text v0.3.7 // indirect
97+
google.golang.org/grpc v1.43.0 // indirect
7498
gopkg.in/yaml.v2 v2.4.0 // indirect
7599
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
76100
)

0 commit comments

Comments
 (0)