Skip to content

Commit b85dcf1

Browse files
committed
Merge main
2 parents c0ca05c + 7e72eb9 commit b85dcf1

Some content is hidden

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

53 files changed

+3355
-1340
lines changed

.github/workflows/coder.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ jobs:
3838
runs-on: ubuntu-latest
3939
steps:
4040
- uses: actions/checkout@v2
41+
- uses: actions/setup-go@v2
42+
with:
43+
go-version: "^1.17"
4144
- name: golangci-lint
42-
uses: golangci/golangci-lint-action@v2
45+
uses: golangci/golangci-lint-action@v3.1.0
4346
with:
4447
version: v1.43.0
4548

@@ -208,7 +211,7 @@ jobs:
208211
- name: Configure Docker for Google Artifact Registry
209212
run: gcloud auth configure-docker us-docker.pkg.dev
210213

211-
- uses: actions/setup-node@v2
214+
- uses: actions/setup-node@v3
212215
with:
213216
node-version: "14"
214217

@@ -246,7 +249,7 @@ jobs:
246249
with:
247250
go-version: "^1.17"
248251

249-
- uses: actions/setup-node@v2
252+
- uses: actions/setup-node@v3
250253
with:
251254
node-version: "14"
252255

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"ntqry",
5151
"oneof",
5252
"parameterscopeid",
53+
"pqtype",
5354
"promptui",
5455
"protobuf",
5556
"provisionerd",

Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
INSTALL_DIR=$(shell go env GOPATH)/bin
2+
GOOS=$(shell go env GOOS)
3+
GOARCH=$(shell go env GOARCH)
24

35
bin/coder:
46
mkdir -p bin
5-
go build -o bin/coder cmd/coder/main.go
7+
GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o bin/coder-$(GOOS)-$(GOARCH) cmd/coder/main.go
68
.PHONY: bin/coder
79

810
bin/coderd:
911
mkdir -p bin
1012
go build -o bin/coderd cmd/coderd/main.go
1113
.PHONY: bin/coderd
1214

13-
build: site/out bin/coder bin/coderd
15+
bin/terraform-provider-coder:
16+
mkdir -p bin
17+
go build -o bin/terraform-provider-coder cmd/terraform-provider-coder/main.go
18+
.PHONY: bin/terraform-provider-coder
19+
20+
build: site/out bin/coder bin/coderd bin/terraform-provider-coder
1421
.PHONY: build
1522

1623
# Runs migrations to output a dump of the database.
@@ -59,6 +66,11 @@ install:
5966
@echo "-- CLI available at $(shell ls $(INSTALL_DIR)/coder*)"
6067
.PHONY: install
6168

69+
install/terraform-provider-coder: bin/terraform-provider-coder
70+
$(eval OS_ARCH := $(shell go env GOOS)_$(shell go env GOARCH))
71+
mkdir -p ~/.terraform.d/plugins/coder.com/internal/coder/0.2/$(OS_ARCH)
72+
cp bin/terraform-provider-coder ~/.terraform.d/plugins/coder.com/internal/coder/0.2/$(OS_ARCH)
73+
6274
peerbroker/proto: peerbroker/proto/peerbroker.proto
6375
protoc \
6476
--go_out=. \

cli/projectcreate.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"golang.org/x/xerrors"
1919

2020
"github.com/coder/coder/coderd"
21-
"github.com/coder/coder/coderd/parameter"
2221
"github.com/coder/coder/codersdk"
2322
"github.com/coder/coder/database"
2423
"github.com/coder/coder/provisionerd"
@@ -187,9 +186,6 @@ func validateProjectVersionSource(cmd *cobra.Command, client *codersdk.Client, o
187186
if ok {
188187
continue
189188
}
190-
if parameterSchema.Name == parameter.CoderWorkspaceTransition {
191-
continue
192-
}
193189
value, err := prompt(cmd, &promptui.Prompt{
194190
Label: fmt.Sprintf("Enter value for %s:", color.HiCyanString(parameterSchema.Name)),
195191
})

cli/projectcreate_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func TestProjectCreate(t *testing.T) {
8686
matches := []string{
8787
"organization?", "y",
8888
"name?", "test-project",
89-
"somevar:", "value",
89+
"somevar", "value",
9090
"project?", "y",
9191
"created!", "n",
9292
}

cli/projects.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func projects() *cobra.Command {
4040
return cmd
4141
}
4242

43-
func displayProjectImportInfo(cmd *cobra.Command, parameterSchemas []coderd.ParameterSchema, parameterValues []coderd.ComputedParameterValue, resources []coderd.ProjectImportJobResource) error {
43+
func displayProjectImportInfo(cmd *cobra.Command, parameterSchemas []coderd.ParameterSchema, parameterValues []coderd.ComputedParameterValue, resources []coderd.ProvisionerJobResource) error {
4444
schemaByID := map[string]coderd.ParameterSchema{}
4545
for _, schema := range parameterSchemas {
4646
schemaByID[schema.ID.String()] = schema

cmd/terraform-provider-coder/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package main
2+
3+
import (
4+
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
5+
6+
"github.com/coder/coder/provisioner/terraform/provider"
7+
)
8+
9+
func main() {
10+
plugin.Serve(&plugin.ServeOpts{
11+
ProviderFunc: provider.New,
12+
})
13+
}

coderd/cmd/root.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,15 @@ func Root() *cobra.Command {
3333
Use: "coderd",
3434
RunE: func(cmd *cobra.Command, args []string) error {
3535
logger := slog.Make(sloghuman.Sink(os.Stderr))
36+
accessURL := &url.URL{
37+
Scheme: "http",
38+
Host: address,
39+
}
3640
handler, closeCoderd := coderd.New(&coderd.Options{
37-
Logger: logger,
38-
Database: databasefake.New(),
39-
Pubsub: database.NewPubsubInMemory(),
41+
AccessURL: accessURL,
42+
Logger: logger,
43+
Database: databasefake.New(),
44+
Pubsub: database.NewPubsubInMemory(),
4045
})
4146

4247
listener, err := net.Listen("tcp", address)
@@ -45,10 +50,7 @@ func Root() *cobra.Command {
4550
}
4651
defer listener.Close()
4752

48-
client := codersdk.New(&url.URL{
49-
Scheme: "http",
50-
Host: address,
51-
})
53+
client := codersdk.New(accessURL)
5254
daemonClose, err := newProvisionerDaemon(cmd.Context(), client, logger)
5355
if err != nil {
5456
return xerrors.Errorf("create provisioner daemon: %w", err)

coderd/coderd.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package coderd
22

33
import (
44
"net/http"
5+
"net/url"
56
"sync"
67

78
"github.com/go-chi/chi/v5"
@@ -16,9 +17,10 @@ import (
1617

1718
// Options are requires parameters for Coder to start.
1819
type Options struct {
19-
Logger slog.Logger
20-
Database database.Store
21-
Pubsub database.Pubsub
20+
AccessURL *url.URL
21+
Logger slog.Logger
22+
Database database.Store
23+
Pubsub database.Pubsub
2224

2325
GoogleTokenValidator *idtoken.Validator
2426
}
@@ -116,9 +118,9 @@ func New(options *Options) (http.Handler, func()) {
116118
})
117119
})
118120

119-
r.Route("/files", func(r chi.Router) {
121+
r.Route("/upload", func(r chi.Router) {
120122
r.Use(httpmw.ExtractAPIKey(options.Database, nil))
121-
r.Post("/", api.postFiles)
123+
r.Post("/", api.postUpload)
122124
})
123125

124126
r.Route("/projectimport/{organization}", func(r chi.Router) {

coderd/coderdtest/coderdtest.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,7 @@ func New(t *testing.T, options *Options) *codersdk.Client {
8080
})
8181
}
8282

83-
handler, closeWait := coderd.New(&coderd.Options{
84-
Logger: slogtest.Make(t, nil).Leveled(slog.LevelDebug),
85-
Database: db,
86-
Pubsub: pubsub,
87-
88-
GoogleTokenValidator: options.GoogleTokenValidator,
89-
})
90-
srv := httptest.NewUnstartedServer(handler)
83+
srv := httptest.NewUnstartedServer(nil)
9184
srv.Config.BaseContext = func(_ net.Listener) context.Context {
9285
ctx, cancelFunc := context.WithCancel(context.Background())
9386
t.Cleanup(cancelFunc)
@@ -96,6 +89,16 @@ func New(t *testing.T, options *Options) *codersdk.Client {
9689
srv.Start()
9790
serverURL, err := url.Parse(srv.URL)
9891
require.NoError(t, err)
92+
var closeWait func()
93+
// We set the handler after server creation for the access URL.
94+
srv.Config.Handler, closeWait = coderd.New(&coderd.Options{
95+
AccessURL: serverURL,
96+
Logger: slogtest.Make(t, nil).Leveled(slog.LevelDebug),
97+
Database: db,
98+
Pubsub: pubsub,
99+
100+
GoogleTokenValidator: options.GoogleTokenValidator,
101+
})
99102
t.Cleanup(func() {
100103
srv.Close()
101104
closeWait()

coderd/files.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type UploadFileResponse struct {
1818
Hash string `json:"hash"`
1919
}
2020

21-
func (api *api) postFiles(rw http.ResponseWriter, r *http.Request) {
21+
func (api *api) postUpload(rw http.ResponseWriter, r *http.Request) {
2222
apiKey := httpmw.APIKey(r)
2323
contentType := r.Header.Get("Content-Type")
2424

coderd/files_test.go

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

13-
func TestPostFiles(t *testing.T) {
13+
func TestPostUpload(t *testing.T) {
1414
t.Parallel()
1515
t.Run("BadContentType", func(t *testing.T) {
1616
t.Parallel()

coderd/parameter/compute.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ import (
1111
"github.com/coder/coder/database"
1212
)
1313

14-
const (
15-
CoderUsername = "coder_username"
16-
CoderWorkspaceTransition = "coder_workspace_transition"
17-
)
18-
1914
// ComputeScope targets identifiers to pull parameters from.
2015
type ComputeScope struct {
2116
ProjectImportJobID uuid.UUID

coderd/projectimport.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ type ParameterSchema database.ParameterSchema
2121
// ComputedParameterValue represents a computed parameter value.
2222
type ComputedParameterValue parameter.ComputedValue
2323

24-
// ProjectImportJobResource is a resource created by a project import job.
25-
type ProjectImportJobResource database.ProjectImportJobResource
26-
2724
// CreateProjectImportJobRequest provides options to create a project import job.
2825
type CreateProjectImportJobRequest struct {
2926
StorageMethod database.ProvisionerStorageMethod `json:"storage_method" validate:"oneof=file,required"`
@@ -167,7 +164,7 @@ func (api *api) projectImportJobResourcesByID(rw http.ResponseWriter, r *http.Re
167164
})
168165
return
169166
}
170-
resources, err := api.Database.GetProjectImportJobResourcesByJobID(r.Context(), job.ID)
167+
resources, err := api.Database.GetProvisionerJobResourcesByJobID(r.Context(), job.ID)
171168
if errors.Is(err, sql.ErrNoRows) {
172169
err = nil
173170
}
@@ -178,7 +175,7 @@ func (api *api) projectImportJobResourcesByID(rw http.ResponseWriter, r *http.Re
178175
return
179176
}
180177
if resources == nil {
181-
resources = []database.ProjectImportJobResource{}
178+
resources = []database.ProvisionerJobResource{}
182179
}
183180
render.Status(r, http.StatusOK)
184181
render.JSON(rw, r, resources)

0 commit comments

Comments
 (0)