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

Skip to content

Commit d661e66

Browse files
committed
Merge branch 'main' into 3522-document-more-methods-3
2 parents e0c3ccf + cfd02d9 commit d661e66

File tree

84 files changed

+6819
-718
lines changed

Some content is hidden

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

84 files changed

+6819
-718
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ build/coder-slim_$(VERSION).tar: build/coder-slim_$(VERSION)_checksums.sha1 $(CO
121121
tar cf "../../../build/$(@F)" coder-*
122122
popd
123123

124+
# delete the uncompressed binaries from the embedded dir
125+
rm -f site/out/bin/coder-*
126+
124127
site/out/bin/coder.tar.zst: build/coder-slim_$(VERSION).tar.zst
125128
cp "$<" "$@"
126129

@@ -132,9 +135,6 @@ build/coder-slim_$(VERSION).tar.zst: build/coder-slim_$(VERSION).tar
132135
-o "build/coder-slim_$(VERSION).tar.zst" \
133136
"build/coder-slim_$(VERSION).tar"
134137

135-
# delete the uncompressed binaries from the embedded dir
136-
rm site/out/bin/coder-*
137-
138138
# Redirect from version-less targets to the versioned ones. There is a similar
139139
# target for slim binaries below.
140140
#

coderd/apidoc/docs.go

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,8 +720,8 @@ const docTemplate = `{
720720
"tags": [
721721
"Templates"
722722
],
723-
"summary": "Update template metadata by ID",
724-
"operationId": "update-template-metadata",
723+
"summary": "Get template metadata by ID",
724+
"operationId": "get-template-metadata-by-id",
725725
"parameters": [
726726
{
727727
"type": "string",
@@ -773,6 +773,39 @@ const docTemplate = `{
773773
}
774774
}
775775
}
776+
},
777+
"patch": {
778+
"security": [
779+
{
780+
"CoderSessionToken": []
781+
}
782+
],
783+
"produces": [
784+
"application/json"
785+
],
786+
"tags": [
787+
"Templates"
788+
],
789+
"summary": "Update template metadata by ID",
790+
"operationId": "update-template-metadata",
791+
"parameters": [
792+
{
793+
"type": "string",
794+
"format": "uuid",
795+
"description": "Template ID",
796+
"name": "id",
797+
"in": "path",
798+
"required": true
799+
}
800+
],
801+
"responses": {
802+
"200": {
803+
"description": "OK",
804+
"schema": {
805+
"$ref": "#/definitions/codersdk.Template"
806+
}
807+
}
808+
}
776809
}
777810
},
778811
"/updatecheck": {

coderd/apidoc/swagger.json

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,8 @@
618618
],
619619
"produces": ["application/json"],
620620
"tags": ["Templates"],
621-
"summary": "Update template metadata by ID",
622-
"operationId": "update-template-metadata",
621+
"summary": "Get template metadata by ID",
622+
"operationId": "get-template-metadata-by-id",
623623
"parameters": [
624624
{
625625
"type": "string",
@@ -667,6 +667,35 @@
667667
}
668668
}
669669
}
670+
},
671+
"patch": {
672+
"security": [
673+
{
674+
"CoderSessionToken": []
675+
}
676+
],
677+
"produces": ["application/json"],
678+
"tags": ["Templates"],
679+
"summary": "Update template metadata by ID",
680+
"operationId": "update-template-metadata",
681+
"parameters": [
682+
{
683+
"type": "string",
684+
"format": "uuid",
685+
"description": "Template ID",
686+
"name": "id",
687+
"in": "path",
688+
"required": true
689+
}
690+
],
691+
"responses": {
692+
"200": {
693+
"description": "OK",
694+
"schema": {
695+
"$ref": "#/definitions/codersdk.Template"
696+
}
697+
}
698+
}
670699
}
671700
},
672701
"/updatecheck": {

coderd/templates.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ func (api *API) templateByOrganizationAndName(rw http.ResponseWriter, r *http.Re
478478
// @Tags Templates
479479
// @Param id path string true "Template ID" format(uuid)
480480
// @Success 200 {object} codersdk.Template
481-
// @Router /templates/{id} [get]
481+
// @Router /templates/{id} [patch]
482482
func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
483483
var (
484484
ctx = r.Context()

coderd/templateversions.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,12 +1069,12 @@ func (api *API) postTemplateVersionsByOrganization(rw http.ResponseWriter, r *ht
10691069

10701070
// templateVersionResources returns the workspace agent resources associated
10711071
// with a template version. A template can specify more than one resource to be
1072-
// provisioned, each resource can have an agent that dials back to coderd.
1073-
// The agents returned are informative of the template version, and do not
1074-
// return agents associated with any particular workspace.
1072+
// provisioned, each resource can have an agent that dials back to coderd. The
1073+
// agents returned are informative of the template version, and do not return
1074+
// agents associated with any particular workspace.
10751075
func (api *API) templateVersionResources(rw http.ResponseWriter, r *http.Request) {
1076-
ctx := r.Context()
10771076
var (
1077+
ctx = r.Context()
10781078
templateVersion = httpmw.TemplateVersionParam(r)
10791079
template = httpmw.TemplateParam(r)
10801080
)
@@ -1100,8 +1100,8 @@ func (api *API) templateVersionResources(rw http.ResponseWriter, r *http.Request
11001100
// and not any build logs for a workspace.
11011101
// Eg: Logs returned from 'terraform plan' when uploading a new terraform file.
11021102
func (api *API) templateVersionLogs(rw http.ResponseWriter, r *http.Request) {
1103-
ctx := r.Context()
11041103
var (
1104+
ctx = r.Context()
11051105
templateVersion = httpmw.TemplateVersionParam(r)
11061106
template = httpmw.TemplateParam(r)
11071107
)

docs/admin/high-availability.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ and other cloud vendors offer fully-managed HA Postgres services that pair
77
nicely with Coder.
88

99
For Coder to operate correctly, every node must be within 10ms of each other
10-
and Postgres. We make a best-effort attempt to warn the user when inter-coder
10+
and Postgres. We make a best-effort attempt to warn the user when inter-Coder
1111
latency is too high, but if requests start dropping, this is one metric to investigate.
12-
Note that this latency requirement applies _only_ to coder services. Coder will
12+
Note that this latency requirement applies _only_ to Coder services. Coder will
1313
operate correctly even with few seconds of latency on
14-
workspace <-> coder and user <-> coder connections.
14+
workspace <-> Coder and user <-> Coder connections.
1515

1616
## Setup
1717

docs/api/templates.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/templat
244244

245245
To perform this operation, you must be authenticated by means of one of the following methods: **CoderSessionToken**.
246246

247-
## Update template metadata by ID
247+
## Get template metadata by ID
248248

249249
### Code samples
250250

@@ -349,3 +349,65 @@ curl -X DELETE http://coder-server:8080/api/v2/templates/{id} \
349349
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.Response](schemas.md#codersdkresponse) |
350350

351351
To perform this operation, you must be authenticated by means of one of the following methods: **CoderSessionToken**.
352+
353+
## Update template metadata by ID
354+
355+
### Code samples
356+
357+
```shell
358+
# Example request using curl
359+
curl -X PATCH http://coder-server:8080/api/v2/templates/{id} \
360+
-H 'Accept: application/json' \
361+
-H 'Coder-Session-Token: API_KEY'
362+
```
363+
364+
`PATCH /templates/{id}`
365+
366+
### Parameters
367+
368+
| Name | In | Type | Required | Description |
369+
| ---- | ---- | ------------ | -------- | ----------- |
370+
| `id` | path | string(uuid) | true | Template ID |
371+
372+
### Example responses
373+
374+
> 200 Response
375+
376+
```json
377+
{
378+
"active_user_count": 0,
379+
"active_version_id": "string",
380+
"allow_user_cancel_workspace_jobs": true,
381+
"build_time_stats": {
382+
"property1": {
383+
"p50": 123,
384+
"p95": 146
385+
},
386+
"property2": {
387+
"p50": 123,
388+
"p95": 146
389+
}
390+
},
391+
"created_at": "2019-08-24T14:15:22Z",
392+
"created_by_id": "9377d689-01fb-4abf-8450-3368d2c1924f",
393+
"created_by_name": "string",
394+
"default_ttl_ms": 0,
395+
"description": "string",
396+
"display_name": "string",
397+
"icon": "string",
398+
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
399+
"name": "string",
400+
"organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
401+
"provisioner": "string",
402+
"updated_at": "2019-08-24T14:15:22Z",
403+
"workspace_owner_count": 0
404+
}
405+
```
406+
407+
### Responses
408+
409+
| Status | Meaning | Description | Schema |
410+
| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------ |
411+
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.Template](schemas.md#codersdktemplate) |
412+
413+
To perform this operation, you must be authenticated by means of one of the following methods: **CoderSessionToken**.

provisioner/terraform/executor.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"encoding/json"
88
"fmt"
99
"io"
10-
"io/ioutil"
1110
"os"
1211
"os/exec"
1312
"path/filepath"
@@ -270,7 +269,7 @@ func (e *executor) graph(ctx, killCtx context.Context) (string, error) {
270269
return "", ctx.Err()
271270
}
272271

273-
var out bytes.Buffer
272+
var out strings.Builder
274273
cmd := exec.CommandContext(killCtx, e.binaryPath, "graph") // #nosec
275274
cmd.Stdout = &out
276275
cmd.Dir = e.workdir
@@ -289,14 +288,13 @@ func (e *executor) graph(ctx, killCtx context.Context) (string, error) {
289288
return out.String(), nil
290289
}
291290

292-
// revive:disable-next-line:flag-parameter
293291
func (e *executor) apply(
294292
ctx, killCtx context.Context, plan []byte, env []string, logr logSink,
295293
) (*proto.Provision_Response, error) {
296294
e.mut.Lock()
297295
defer e.mut.Unlock()
298296

299-
planFile, err := ioutil.TempFile("", "coder-terrafrom-plan")
297+
planFile, err := os.CreateTemp("", "coder-terrafrom-plan")
300298
if err != nil {
301299
return nil, xerrors.Errorf("create plan file: %w", err)
302300
}

0 commit comments

Comments
 (0)