Skip to content

Commit cece1a5

Browse files
committed
Merge branch 'main' into vscodeext
2 parents b959fb1 + 85a6d14 commit cece1a5

Some content is hidden

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

69 files changed

+776
-557
lines changed

.github/workflows/coder.yaml

+15-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Checkout
3535
uses: actions/checkout@v2
3636
- name: typos-action
37-
uses: crate-ci/typos@v1.12.12
37+
uses: crate-ci/typos@v1.13.3
3838
with:
3939
config: .github/workflows/typos.toml
4040
- name: Fix Helper
@@ -674,6 +674,19 @@ jobs:
674674
runs-on: ubuntu-latest
675675
steps:
676676
- uses: actions/checkout@master
677-
- uses: gaurav-nelson/github-action-markdown-link-check@v1
677+
# For the main branch:
678+
- if: github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
679+
uses: gaurav-nelson/github-action-markdown-link-check@v1
678680
with:
681+
use-quiet-mode: yes
682+
use-verbose-mode: yes
683+
config-file: .github/workflows/mlc_config.json
684+
# For pull requests:
685+
- if: github.ref != 'refs/heads/main' || github.event.pull_request.head.repo.fork
686+
uses: gaurav-nelson/github-action-markdown-link-check@v1
687+
with:
688+
use-quiet-mode: yes
689+
use-verbose-mode: yes
690+
check-modified-files-only: yes
691+
base-branch: main
679692
config-file: .github/workflows/mlc_config.json

.github/workflows/typos.toml

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ doas = "doas"
1010
darcula = "darcula"
1111
Hashi = "Hashi"
1212
trialer = "trialer"
13+
encrypter = "encrypter"
1314

1415
[files]
1516
extend-exclude = [

ADOPTERS.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Adopters
1+
# Adopters
2+
23
[!["Join us on
34
Discord"](https://img.shields.io/badge/join-us%20on%20Discord-gray.svg?longCache=true&logo=discord&colorB=green)](https://coder.com/chat?utm_source=github.com/coder/coder&utm_medium=github&utm_campaign=adopters.md) [![Twitter
45
Follow](https://img.shields.io/twitter/follow/coderhq?label=%40coderhq&style=social)](https://twitter.com/coderhq)
@@ -7,6 +8,6 @@ Follow](https://img.shields.io/twitter/follow/coderhq?label=%40coderhq&style=soc
78

89
> 👋 _If you are considering using Coder in your organization please introduce yourself via https://coder.com/demo_ 🙇🏻‍♂️
910
10-
| Organization | Contact | Description of Use |
11-
| --------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
12-
| [Coder](https://www.coder.com) | [@coderhq](https://twitter.com/coderhq) | Coder builds coder with Coder. |
11+
| Organization | Contact | Description of Use |
12+
| ------------------------------ | --------------------------------------- | ------------------------------ |
13+
| [Coder](https://www.coder.com) | [@coderhq](https://twitter.com/coderhq) | Coder builds coder with Coder. |

Makefile

+3-7
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,9 @@ fmt/prettier:
359359
cd site
360360
# Avoid writing files in CI to reduce file write activity
361361
ifdef CI
362-
yarn run format:check
362+
yarn run format:check . ../*.md ../docs
363363
else
364-
yarn run format:write
364+
yarn run format:write . ../*.md ../docs
365365
endif
366366
.PHONY: fmt/prettier
367367

@@ -452,11 +452,7 @@ site/src/api/typesGenerated.ts: scripts/apitypings/main.go $(shell find codersdk
452452
docs/admin/prometheus.md: scripts/metricsdocgen/main.go scripts/metricsdocgen/metrics
453453
go run scripts/metricsdocgen/main.go
454454
cd site
455-
ifdef CI
456-
yarn run format:check
457-
else
458-
yarn run format:write
459-
endif
455+
yarn run format:write ../docs/admin/prometheus.md
460456

461457
update-golden-files: cli/testdata/.gen-golden
462458
.PHONY: update-golden-files

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Software development on your infrastructure. Offload your team's development fro
1111

1212
> "By leveraging Terraform, Coder lets developers run any IDE on any compute platform including on-prem, AWS, Azure, GCP, DigitalOcean, Kubernetes, Docker, and more, with workspaces running on Linux, Windows, or Mac." - **Kevin Fishner Chief of Staff at [HashiCorp](https://hashicorp.com/)**
1313
14-
1514
<p align="center">
1615
<img src="./docs/images/hero-image.png">
1716
</p>
@@ -83,6 +82,10 @@ Use `coder --help` to get a complete list of flags and environment variables. Us
8382

8483
Visit our docs [here](https://coder.com/docs/coder-oss).
8584

85+
## Templates
86+
87+
Find our templates [here](./examples/templates).
88+
8689
## Comparison
8790

8891
Please file [an issue](https://github.com/coder/coder/issues/new) if any information is out of date. Also refer to: [What Coder is not](https://coder.com/docs/coder-oss/latest/index#what-coder-is-not).
@@ -92,7 +95,7 @@ Please file [an issue](https://github.com/coder/coder/issues/new) if any informa
9295
| [Coder](https://github.com/coder/coder) | Platform | OSS + Self-Managed | Pay your cloud | All [Terraform](https://www.terraform.io/registry/providers) resources, all clouds, multi-architecture: Linux, Mac, Windows, containers, VMs, amd64, arm64 |
9396
| [code-server](https://github.com/cdr/code-server) | Web IDE | OSS + Self-Managed | Pay your cloud | Linux, Mac, Windows, containers, VMs, amd64, arm64 |
9497
| [Coder (Classic)](https://coder.com/docs) | Platform | Self-Managed | Pay your cloud + license fees | Kubernetes Linux Containers |
95-
| [GitHub Codespaces](https://github.com/features/codespaces) | Platform | SaaS | 2x Azure Compute | Linux Virtual Machines |
98+
| [GitHub Codespaces](https://github.com/features/codespaces) | Platform | SaaS | 2x Azure Compute | Linux Virtual Machines |
9699

97100
---
98101

agent/agent.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,13 @@ func (a *agent) trackConnGoroutine(fn func()) error {
245245
return nil
246246
}
247247

248-
func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (network *tailnet.Conn, err error) {
248+
func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (_ *tailnet.Conn, err error) {
249249
a.closeMutex.Lock()
250250
if a.isClosed() {
251251
a.closeMutex.Unlock()
252252
return nil, xerrors.New("closed")
253253
}
254-
network, err = tailnet.NewConn(&tailnet.Options{
254+
network, err := tailnet.NewConn(&tailnet.Options{
255255
Addresses: []netip.Prefix{netip.PrefixFrom(codersdk.TailnetIP, 128)},
256256
DERPMap: derpMap,
257257
Logger: a.logger.Named("tailnet"),
@@ -266,7 +266,6 @@ func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap) (ne
266266
network.Close()
267267
}
268268
}()
269-
a.network = network
270269
a.closeMutex.Unlock()
271270

272271
sshListener, err := network.Listen("tcp", ":"+strconv.Itoa(codersdk.TailnetSSHPort))

cli/deployment/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ func newConfig() *codersdk.DeploymentConfig {
216216
Flag: "oidc-client-secret",
217217
Secret: true,
218218
},
219-
EmailDomain: &codersdk.DeploymentConfigField[string]{
219+
EmailDomain: &codersdk.DeploymentConfigField[[]string]{
220220
Name: "OIDC Email Domain",
221-
Usage: "Email domain that clients logging in with OIDC must match.",
221+
Usage: "Email domains that clients logging in with OIDC must match.",
222222
Flag: "oidc-email-domain",
223223
},
224224
IssuerURL: &codersdk.DeploymentConfigField[string]{

cli/deployment/config_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func TestConfig(t *testing.T) {
154154
},
155155
Valid: func(config *codersdk.DeploymentConfig) {
156156
require.Equal(t, config.OIDC.IssuerURL.Value, "https://accounts.google.com")
157-
require.Equal(t, config.OIDC.EmailDomain.Value, "coder.com")
157+
require.Equal(t, config.OIDC.EmailDomain.Value, []string{"coder.com"})
158158
require.Equal(t, config.OIDC.ClientID.Value, "client")
159159
require.Equal(t, config.OIDC.ClientSecret.Value, "secret")
160160
require.False(t, config.OIDC.AllowSignups.Value)

cli/list.go

+4
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func list() *cobra.Command {
7777
if err != nil {
7878
return err
7979
}
80+
8081
filter := codersdk.WorkspaceFilter{
8182
FilterQuery: searchQuery,
8283
}
@@ -91,6 +92,7 @@ func list() *cobra.Command {
9192
}
9293
filter.Owner = myUser.Username
9394
}
95+
9496
res, err := client.Workspaces(cmd.Context(), filter)
9597
if err != nil {
9698
return err
@@ -102,10 +104,12 @@ func list() *cobra.Command {
102104
_, _ = fmt.Fprintln(cmd.ErrOrStderr())
103105
return nil
104106
}
107+
105108
userRes, err := client.Users(cmd.Context(), codersdk.UsersRequest{})
106109
if err != nil {
107110
return err
108111
}
112+
109113
usersByID := map[uuid.UUID]codersdk.User{}
110114
for _, user := range userRes.Users {
111115
usersByID[user.ID] = user

cli/root.go

+31-47
Original file line numberDiff line numberDiff line change
@@ -137,53 +137,6 @@ func Root(subcommands []*cobra.Command) *cobra.Command {
137137
}
138138
return cmd.Help()
139139
},
140-
PersistentPreRun: func(cmd *cobra.Command, args []string) {
141-
if cliflag.IsSetBool(cmd, varNoVersionCheck) &&
142-
cliflag.IsSetBool(cmd, varNoFeatureWarning) {
143-
return
144-
}
145-
146-
// login handles checking the versions itself since it has a handle
147-
// to an unauthenticated client.
148-
//
149-
// server is skipped for obvious reasons.
150-
//
151-
// agent is skipped because these checks use the global coder config
152-
// and not the agent URL and token from the environment.
153-
//
154-
// gitssh is skipped because it's usually not called by users
155-
// directly.
156-
if cmd.Name() == "login" || cmd.Name() == "server" || cmd.Name() == "agent" || cmd.Name() == "gitssh" {
157-
return
158-
}
159-
if isGitAskpass {
160-
return
161-
}
162-
163-
client, err := CreateClient(cmd)
164-
// If we are unable to create a client, presumably the subcommand will fail as well
165-
// so we can bail out here.
166-
if err != nil {
167-
return
168-
}
169-
170-
err = checkVersions(cmd, client)
171-
if err != nil {
172-
// Just log the error here. We never want to fail a command
173-
// due to a pre-run.
174-
_, _ = fmt.Fprintf(cmd.ErrOrStderr(),
175-
cliui.Styles.Warn.Render("check versions error: %s"), err)
176-
_, _ = fmt.Fprintln(cmd.ErrOrStderr())
177-
}
178-
179-
err = checkWarnings(cmd, client)
180-
if err != nil {
181-
// Same as above
182-
_, _ = fmt.Fprintf(cmd.ErrOrStderr(),
183-
cliui.Styles.Warn.Render("check entitlement warnings error: %s"), err)
184-
_, _ = fmt.Fprintln(cmd.ErrOrStderr())
185-
}
186-
},
187140
Example: formatExamples(
188141
example{
189142
Description: "Start a Coder server",
@@ -308,6 +261,37 @@ func CreateClient(cmd *cobra.Command) (*codersdk.Client, error) {
308261
return nil, err
309262
}
310263
client.SetSessionToken(token)
264+
265+
// We send these requests in parallel to minimize latency.
266+
var (
267+
versionErr = make(chan error)
268+
warningErr = make(chan error)
269+
)
270+
go func() {
271+
versionErr <- checkVersions(cmd, client)
272+
close(versionErr)
273+
}()
274+
275+
go func() {
276+
warningErr <- checkWarnings(cmd, client)
277+
close(warningErr)
278+
}()
279+
280+
if err = <-versionErr; err != nil {
281+
// Just log the error here. We never want to fail a command
282+
// due to a pre-run.
283+
_, _ = fmt.Fprintf(cmd.ErrOrStderr(),
284+
cliui.Styles.Warn.Render("check versions error: %s"), err)
285+
_, _ = fmt.Fprintln(cmd.ErrOrStderr())
286+
}
287+
288+
if err = <-warningErr; err != nil {
289+
// Same as above
290+
_, _ = fmt.Fprintf(cmd.ErrOrStderr(),
291+
cliui.Styles.Warn.Render("check entitlement warnings error: %s"), err)
292+
_, _ = fmt.Fprintln(cmd.ErrOrStderr())
293+
}
294+
311295
return client, nil
312296
}
313297

cli/testdata/coder_server_--help.golden

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ Flags:
9595
Consumes $CODER_OIDC_CLIENT_ID
9696
--oidc-client-secret string Client secret to use for Login with OIDC.
9797
Consumes $CODER_OIDC_CLIENT_SECRET
98-
--oidc-email-domain string Email domain that clients logging in with
99-
OIDC must match.
98+
--oidc-email-domain strings Email domains that clients logging in
99+
with OIDC must match.
100100
Consumes $CODER_OIDC_EMAIL_DOMAIN
101101
--oidc-ignore-email-verified Ignore the email_verified claim from the
102102
upstream provider.

cli/vscodeipc/vscodeipc.go

-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ func (api *api) execute(w http.ResponseWriter, r *http.Request) {
198198
api.sshClient, api.sshClientErr = api.agentConn.SSHClient(context.Background())
199199
})
200200
if api.sshClientErr != nil {
201-
fmt.Printf("WE GOT TO BEGIN ERR! %s\n", api.sshClientErr)
202201
httpapi.Write(r.Context(), w, http.StatusInternalServerError, codersdk.Response{
203202
Message: "Failed to create SSH client.",
204203
Detail: api.sshClientErr.Error(),

coderd/client_test.go

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package coderd_test
2+
3+
import (
4+
"context"
5+
"net/http"
6+
7+
"github.com/stretchr/testify/require"
8+
9+
"github.com/coder/coder/codersdk"
10+
"github.com/coder/coder/testutil"
11+
)
12+
13+
// Issue: https://github.com/coder/coder/issues/5249
14+
// While running tests in parallel, the web server seems to be overloaded and responds with HTTP 502.
15+
// require.Eventually expects correct HTTP responses.
16+
17+
func doWithRetries(t require.TestingT, client *codersdk.Client, req *http.Request) (*http.Response, error) {
18+
var resp *http.Response
19+
var err error
20+
require.Eventually(t, func() bool {
21+
// nolint // only requests which are not passed upstream have a body closed
22+
resp, err = client.HTTPClient.Do(req)
23+
if resp != nil && resp.StatusCode == http.StatusBadGateway {
24+
if resp.Body != nil {
25+
resp.Body.Close()
26+
}
27+
return false
28+
}
29+
return true
30+
}, testutil.WaitLong, testutil.IntervalFast)
31+
return resp, err
32+
}
33+
34+
func requestWithRetries(ctx context.Context, t require.TestingT, client *codersdk.Client, method, path string, body interface{}, opts ...codersdk.RequestOption) (*http.Response, error) {
35+
var resp *http.Response
36+
var err error
37+
require.Eventually(t, func() bool {
38+
// nolint // only requests which are not passed upstream have a body closed
39+
resp, err = client.Request(ctx, method, path, body, opts...)
40+
if resp != nil && resp.StatusCode == http.StatusBadGateway {
41+
if resp.Body != nil {
42+
resp.Body.Close()
43+
}
44+
return false
45+
}
46+
return true
47+
}, testutil.WaitLong, testutil.IntervalFast)
48+
return resp, err
49+
}

coderd/coderd.go

+1
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ func New(options *Options) *API {
349349
r.Route("/templateversions", func(r chi.Router) {
350350
r.Post("/", api.postTemplateVersionsByOrganization)
351351
r.Get("/{templateversionname}", api.templateVersionByOrganizationAndName)
352+
r.Get("/{templateversionname}/previous", api.previousTemplateVersionByOrganizationAndName)
352353
})
353354
r.Route("/templates", func(r chi.Router) {
354355
r.Post("/", api.postTemplateByOrganization)

coderd/coderdtest/authorize.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,12 @@ func AGPLRoutes(a *AuthTester) (map[string]string, map[string]RouteCheck) {
236236
"GET:/api/v2/applications/auth-redirect": {AssertAction: rbac.ActionCreate, AssertObject: rbac.ResourceAPIKey},
237237

238238
// These endpoints need payloads to get to the auth part. Payloads will be required
239-
"PUT:/api/v2/users/{user}/roles": {StatusCode: http.StatusBadRequest, NoAuthorize: true},
240-
"PUT:/api/v2/organizations/{organization}/members/{user}/roles": {NoAuthorize: true},
241-
"POST:/api/v2/workspaces/{workspace}/builds": {StatusCode: http.StatusBadRequest, NoAuthorize: true},
242-
"POST:/api/v2/organizations/{organization}/templateversions": {StatusCode: http.StatusBadRequest, NoAuthorize: true},
243-
"GET:/api/v2/organizations/{organization}/templateversions/{templateversionname}": {StatusCode: http.StatusBadRequest, NoAuthorize: true},
239+
"PUT:/api/v2/users/{user}/roles": {StatusCode: http.StatusBadRequest, NoAuthorize: true},
240+
"PUT:/api/v2/organizations/{organization}/members/{user}/roles": {NoAuthorize: true},
241+
"POST:/api/v2/workspaces/{workspace}/builds": {StatusCode: http.StatusBadRequest, NoAuthorize: true},
242+
"POST:/api/v2/organizations/{organization}/templateversions": {StatusCode: http.StatusBadRequest, NoAuthorize: true},
243+
"GET:/api/v2/organizations/{organization}/templateversions/{templateversionname}": {StatusCode: http.StatusBadRequest, NoAuthorize: true},
244+
"GET:/api/v2/organizations/{organization}/templateversions/{templateversionname}/previous": {StatusCode: http.StatusBadRequest, NoAuthorize: true},
244245

245246
// Endpoints that use the SQLQuery filter.
246247
"GET:/api/v2/workspaces/": {

0 commit comments

Comments
 (0)