10000 Merge branch 'main' into users-count/presleyp · coder/coder@72d4657 · GitHub
[go: up one dir, main page]

Skip to content

Commit 72d4657

Browse files
committed
Merge branch 'main' into users-count/presleyp
2 parents f083580 + b1c400a commit 72d4657

File tree

71 files changed

+1153
-841
lines changed

Some content is hidden

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

71 files changed

+1153
-841
lines changed

.github/workflows/coder.yaml

Lines changed: 7 additions & 7 deletions
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.8
37+
uses: crate-ci/typos@v1.12.12
3838
with:
3939
config: .github/workflows/typos.toml
4040
- name: Fix Helper
@@ -89,14 +89,14 @@ jobs:
8989
style-lint-golangci:
9090
name: style/lint/golangci
9191
timeout-minutes: 5
92-
runs-on: ubuntu-latest
92+
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
9393
steps:
9494
- uses: actions/checkout@v3
9595
- uses: actions/setup-go@v3
9696
with:
9797
go-version: "~1.19"
9898
- name: golangci-lint
99-
uses: golangci/golangci-lint-action@v3.2.0
99+
uses: golangci/golangci-lint-action@v3.3.0
100100
with:
101101
version: v1.48.0
102102

@@ -171,7 +171,7 @@ jobs:
171171
gen:
172172
name: "style/gen"
173173
timeout-minutes: 8
174-
runs-on: ubuntu-latest
174+
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
175175
needs: changes
176176
if: needs.changes.outputs.docs-only == 'false'
177177
steps:
@@ -276,7 +276,7 @@ jobs:
276276
277277
test-go:
278278
name: "test/go"
279-
runs-on: ${{ matrix.os }}
279+
runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || matrix.os }}
280280
timeout-minutes: 20
281281
strategy:
282282
matrix:
@@ -356,7 +356,7 @@ jobs:
356356

357357
test-go-postgres:
358358
name: "test/go/postgres"
359-
runs-on: ubuntu-latest
359+
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
360360
# This timeout must be greater than the timeout set by `go test` in
361361
# `make test-postgres` to ensure we receive a trace of running
362362
# goroutines. Setting this to the timeout +5m should work quite well
@@ -417,7 +417,7 @@ jobs:
417417

418418
deploy:
419419
name: "deploy"
420-
runs-on: ubuntu-latest
420+
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
421421
timeout-minutes: 30
422422
needs: changes
423423
if: |

.github/workflows/dogfood.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
steps:
1818
- name: Get branch name
1919
id: branch-name
20-
uses: tj-actions/branch-names@v6.1
20+
uses: tj-actions/branch-names@v6.2
2121

2222
- name: "Branch name to Docker tag name"
2323
id F438 : docker-tag-name

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ env:
2626

2727
jobs:
2828
release:
29-
runs-on: ubuntu-latest
29+
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
3030
env:
3131
# Necessary for Docker manifest
3232
DOCKER_CLI_EXPERIMENTAL: "enabled"

cli/deployment/config.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func newConfig() *codersdk.DeploymentConfig {
132132
ProxyTrustedHeaders: &codersdk.DeploymentConfigField[[]string]{
133133
Name: "Proxy Trusted Headers",
134134
Flag: "proxy-trusted-headers",
135-
Usage: "Headers to trust for forwarding IP addresses. e.g. Cf-Connecting-IP True-Client-Ip, X-Forwarded-for",
135+
Usage: "Headers to trust for forwarding IP addresses. e.g. Cf-Connecting-Ip, True-Client-Ip, X-Forwarded-For",
136136
},
137137
ProxyTrustedOrigins: &codersdk.DeploymentConfigField[[]string]{
138138
Name: "Proxy Trusted Origins",
@@ -289,10 +289,18 @@ func newConfig() *codersdk.DeploymentConfig {
289289
Default: "tls12",
290290
},
291291
},
292-
TraceEnable: &codersdk.DeploymentConfigField[bool]{
293-
Name: "Trace Enable",
294-
Usage: "Whether application tracing data is collected.",
295-
Flag: "trace",
292+
Trace: &codersdk.TraceConfig{
293+
Enable: &codersdk.DeploymentConfigField[bool]{
294+
Name: "Trace Enable",
295+
Usage: "Whether application tracing data is collected. It exports to a backend configured by environment variables. See: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md",
296+
Flag: "trace",
297+
},
298+
HoneycombAPIKey: &codersdk.DeploymentConfigField[string]{
299+
Name: "Trace Honeycomb API Key",
300+
Usage: "Enables trace exporting to Honeycomb.io using the provided API Key.",
301+
Flag: "trace-honeycomb-api-key",
302+
Secret: true,
303+
},
296304
},
297305
SecureAuthCookie: &codersdk.DeploymentConfigField[bool]{
298306
Name: "Secure Auth Cookie",

cli/deployment/config_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ func TestConfig(t *testing.T) {
114114
require.Equal(t, config.TLS.Enable.Value, true)
115115
require.Equal(t, config.TLS.MinVersion.Value, "tls10")
116116
},
117+
}, {
118+
Name: "Trace",
119+
Env: map[string]string{
120+
"CODER_TRACE_ENABLE": "true",
121+
"CODER_TRACE_HONEYCOMB_API_KEY": "my-honeycomb-key",
122+
},
123+
Valid: func(config *codersdk.DeploymentConfig) {
124+
require.Equal(t, config.Trace.Enable.Value, true)
125+
require.Equal(t, config.Trace.HoneycombAPIKey.Value, "my-honeycomb-key")
126+
},
117127
}, {
118128
Name: "OIDC",
119129
Env: map[string]string{
@@ -192,6 +202,7 @@ func TestConfig(t *testing.T) {
192202
}} {
193203
tc := tc
194204
t.Run(tc.Name, func(t *testing.T) {
205+
t.Helper()
195206
for key, value := range tc.Env {
196207
t.Setenv(key, value)
197208
}

cli/resetpassword_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestResetPassword(t *testing.T) {
4141
serverCmd, cfg := clitest.New(t,
4242
"server",
4343
"--address", ":0",
44-
"--access-url", "example.com",
44+
"--access-url", "http://example.com",
4545
"--postgres-url", connectionURL,
4646
"--cache-dir", t.TempDir(),
4747
)

cli/server.go

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
125125
shouldCoderTrace = cfg.Telemetry.Trace.Value
126126
}
127127

128-
if cfg.TraceEnable.Value || shouldCoderTrace {
128+
if cfg.Trace.Enable.Value || shouldCoderTrace {
129129
sdkTracerProvider, closeTracing, err := tracing.TracerProvider(ctx, "coderd", tracing.TracerOpts{
130-
Default: cfg.TraceEnable.Value,
130+
Default: cfg.Trace.Enable.Value,
131131
Coder: shouldCoderTrace,
132132
})
133133
if err != nil {
@@ -225,7 +225,7 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
225225
cfg.AccessURL.Value = tunnel.URL
226226

227227
if cfg.WildcardAccessURL.Value == "" {
228-
u, err := parseURL(ctx, tunnel.URL)
228+
u, err := parseURL(tunnel.URL)
229229
if err != nil {
230230
return xerrors.Errorf("parse tunnel url: %w", err)
231231
}
@@ -235,7 +235,7 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
235235
}
236236
}
237237

238-
accessURLParsed, err := parseURL(ctx, cfg.AccessURL.Value)
238+
accessURLParsed, err := parseURL(cfg.AccessURL.Value)
239239
if err != nil {
240240
return xerrors.Errorf("parse URL: %w", err)
241241
}
@@ -469,7 +469,7 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
469469
}
470470

471471
// Parse the raw telemetry URL!
472-
telemetryURL, err := parseURL(ctx, cfg.Telemetry.URL.Value)
472+
telemetryURL, err := parseURL(cfg.Telemetry.URL.Value)
473473
if err != nil {
474474
return xerrors.Errorf("parse telemetry url: %w", err)
475475
}
@@ -779,34 +779,21 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
779779
return root
780780
}
781781

782-
// parseURL parses a string into a URL. It works around some technically correct
783-
// but undesired behavior of url.Parse by prepending a scheme if one does not
784-
// exist so that the URL does not get parsed improperly.
785-
func parseURL(ctx context.Context, u string) (*url.URL, error) {
782+
// parseURL parses a string into a URL.
783+
func parseURL(u string) (*url.URL, error) {
786784
var (
787785
hasScheme = strings.HasPrefix(u, "http:") || strings.HasPrefix(u, "https:")
788786
)
789787

790788
if !hasScheme {
791-
// Append a scheme if it doesn't have one. Otherwise the hostname
792-
// will likely get parsed as the scheme and cause methods like Hostname()
793-
// to return an empty string, largely obviating the purpose of this
794-
// function.
795-
u = "https://" + u
789+
return nil, xerrors.Errorf("URL %q must have a scheme of either http or https", u)
796790
}
797791

798792
parsed, err := url.Parse(u)
799793
if err != nil {
800794
return nil, err
801795
}
802796

803-
// If the specified url is a loopback device and no scheme has been
804-
// specified, prefer http over https. It's unlikely anyone intends to use
805-
// https on a loopback and if they do they can specify a scheme.
806-
if local, _ := isLocalURL(ctx, parsed); local && !hasScheme {
807-
parsed.Scheme = "http"
808-
}
809-
810797
return parsed, nil
811798
}
812799

0 commit comments

Comments
 (0)
0