Skip to content

Commit

Permalink
feat: Create provisioner abstraction (#12)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
kylecarbs committed Jan 8, 2022
1 parent 2769f4c commit 7c260f8
Show file tree
Hide file tree
Showing 20 changed files with 1,877 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Generated files
provisionersdk/proto/*.go linguist-generated=true
24 changes: 23 additions & 1 deletion .github/workflows/coder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,28 @@ jobs:
with:
version: latest

gen:
name: "style/gen"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
version: "3.6.1"
- uses: actions/setup-go@v2
with:
go-version: "^1.17"
- run:
curl -sSL
https://github.com/kyleconroy/sqlc/releases/download/v1.11.0/sqlc_1.11.0_linux_amd64.tar.gz
| sudo tar -C /usr/bin -xz sqlc

- run: go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
- run: go install storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.26
- run: "make --output-sync -j gen"
- run: ./scripts/check_unstaged.sh

style:
name: "style/${{ matrix.style }}"
runs-on: ubuntu-latest
Expand Down Expand Up @@ -95,7 +117,7 @@ jobs:

- run:
gotestsum --jsonfile="gotests.json" --packages="./..." --
-covermode=atomic -coverprofile="gotests.coverage"
-covermode=atomic -coverprofile="gotests.coverage" -timeout=1m

- uses: codecov/codecov-action@v2
with:
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"files.exclude": {
"**/node_modules": true
},
"go.lintTool": "golangci-lint",
"go.lintFlags": ["--fast"],
"go.lintOnSave": "package",
Expand Down
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ database/dump.sql: $(wildcard database/migrations/*.sql)
go run database/dump/main.go

# Generates Go code for querying the database.
.PHONY: database/generate
database/generate: database/dump.sql database/query.sql
cd database && sqlc generate && rm db_tmp.go
cd database && gofmt -w -r 'Querier -> querier' *.go
cd database && gofmt -w -r 'Queries -> sqlQuerier' *.go
.PHONY: database/generate

fmt/prettier:
@echo "--- prettier"
Expand All @@ -21,3 +21,16 @@ endif

fmt: fmt/prettier
.PHONY: fmt

gen: database/generate provisionersdk/proto
.PHONY: gen

# Generates the protocol files.
provisionersdk/proto: provisionersdk/proto/provisioner.proto
cd provisionersdk/proto && protoc \
--go_out=. \
--go_opt=paths=source_relative \
--go-drpc_out=. \
--go-drpc_opt=paths=source_relative \
./provisioner.proto
.PHONY: provisionersdk/proto
6 changes: 5 additions & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@ coverage:
status:
project:
default:
target: 80%
target: 75%
informational: yes

ignore:
# This is generated code.
- provisionersdk/proto
32 changes: 28 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@ module github.com/coder/coder

go 1.17

// Required until https://github.com/hashicorp/terraform-config-inspect/pull/74 is merged.
replace github.com/hashicorp/terraform-config-inspect => github.com/kylecarbs/terraform-config-inspect v0.0.0-20211215004401-bbc517866b88

require (
cdr.dev/slog v1.4.1
github.com/golang-migrate/migrate/v4 v4.15.1
github.com/google/uuid v1.3.0
github.com/hashicorp/go-version v1.3.0
github.com/hashicorp/hc-install v0.3.1
github.com/hashicorp/terraform-config-inspect v0.0.0-20211115214459-90acf1ca460f
github.com/hashicorp/terraform-exec v0.15.0
github.com/lib/pq v1.10.4
github.com/ory/dockertest/v3 v3.8.1
github.com/pion/datachannel v1.5.2
Expand All @@ -15,13 +23,20 @@ require (
go.uber.org/atomic v1.7.0
go.uber.org/goleak v1.1.12
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
google.golang.org/protobuf v1.27.1
storj.io/drpc v0.0.26
)

require (
cloud.google.com/go v0.92.3 // indirect
cloud.google.com/go/storage v1.14.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.5.1 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/alecthomas/chroma v0.9.1 // indirect
github.com/apparentlymart/go-textseg v1.0.0 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/cenkalti/backoff/v4 v4.1.2 // indirect
github.com/containerd/continuity v0.1.0 // indirect
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect
Expand All @@ -35,13 +50,18 @@ require (
github.com/fatih/color v1.12.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/hcl/v2 v2.0.0 // indirect
github.com/hashicorp/terraform-json v0.13.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mattn/go-isatty v0.0.13 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
Expand All @@ -66,11 +86,15 @@ require (
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/zclconf/go-cty v1.9.1 // indirect
github.com/zeebo/errs v1.2.2 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 // indirect
golang.org/x/net v0.0.0-20211215060638-4ddde0e984e9 // indirect
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c // indirect
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/grpc v1.43.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

0 comments on commit 7c260f8

Please sign in to comment.