Skip to content

Commit dad9287

Browse files
Merge branch 'coder:main' into feat/coder-login-secret
2 parents 1afcb47 + 3d7740b commit dad9287

File tree

112 files changed

+2783
-784
lines changed

Some content is hidden

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

112 files changed

+2783
-784
lines changed

.github/workflows/ci.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ jobs:
640640
- test-e2e
641641
- offlinedocs
642642
- sqlc-vet
643+
- dependency-license-review
643644
# Allow this job to run even if the needed jobs fail, are skipped or
644645
# cancelled.
645646
if: always()
@@ -656,6 +657,7 @@ jobs:
656657
echo "- test-js: ${{ needs.test-js.result }}"
657658
echo "- test-e2e: ${{ needs.test-e2e.result }}"
658659
echo "- offlinedocs: ${{ needs.offlinedocs.result }}"
660+
echo "- dependency-license-review: ${{ needs.dependency-license-review.result }}"
659661
echo
660662
661663
# We allow skipped jobs to pass, but not failed or cancelled jobs.
@@ -896,3 +898,42 @@ jobs:
896898
- name: Setup and run sqlc vet
897899
run: |
898900
make sqlc-vet
901+
902+
# dependency-license-review checks that no license-incompatible dependencies have been introduced.
903+
# This action is not intended to do a vulnerability check since that is handled by a separate action.
904+
dependency-license-review:
905+
runs-on: ubuntu-latest
906+
if: github.ref != 'refs/heads/main'
907+
steps:
908+
- name: "Checkout Repository"
909+
uses: actions/checkout@v4
910+
- name: "Dependency Review"
911+
id: review
912+
uses: actions/dependency-review-action@v4
913+
with:
914+
allow-licenses: Apache-2.0, BSD-2-Clause, BSD-3-Clause, CC0-1.0, ISC, MIT, MIT-0, MPL-2.0
915+
license-check: true
916+
vulnerability-check: false
917+
- name: "Report"
918+
# make sure this step runs even if the previous failed
919+
if: always()
920+
shell: bash
921+
env:
922+
VULNERABLE_CHANGES: ${{ steps.review.outputs.invalid-license-changes }}
923+
run: |
924+
fields=( "unlicensed" "unresolved" "forbidden" )
925+
926+
# This is unfortunate that we have to do this but the action does not support failing on
927+
# an unknown license. The unknown dependency could easily have a GPL license which
928+
# would be problematic for us.
929+
# Track https://github.com/actions/dependency-review-action/issues/672 for when
930+
# we can remove this brittle workaround.
931+
for field in "${fields[@]}"; do
932+
# Use jq to check if the array is not empty
933+
if [[ $(echo "$VULNERABLE_CHANGES" | jq ".${field} | length") -ne 0 ]]; then
934+
echo "Invalid or unknown licenses detected, contact @sreya to ensure your added dependency falls under one of our allowed licenses."
935+
echo "$VULNERABLE_CHANGES" | jq
936+
exit 1
937+
fi
938+
done
939+
echo "No incompatible licenses detected"

cli/ssh.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,18 @@ import (
2525
"golang.org/x/xerrors"
2626
"gvisor.dev/gvisor/pkg/tcpip/adapters/gonet"
2727

28-
"github.com/coder/retry"
29-
"github.com/coder/serpent"
30-
3128
"cdr.dev/slog"
3229
"cdr.dev/slog/sloggers/sloghuman"
33-
3430
"github.com/coder/coder/v2/cli/cliui"
3531
"github.com/coder/coder/v2/cli/cliutil"
3632
"github.com/coder/coder/v2/coderd/autobuild/notify"
3733
"github.com/coder/coder/v2/coderd/util/ptr"
3834
"github.com/coder/coder/v2/codersdk"
3935
"github.com/coder/coder/v2/codersdk/workspacesdk"
4036
"github.com/coder/coder/v2/cryptorand"
37+
"github.com/coder/coder/v2/pty"
38+
"github.com/coder/retry"
39+
"github.com/coder/serpent"
4140
)
4241

4342
var (
@@ -341,15 +340,22 @@ func (r *RootCmd) ssh() *serpent.Command {
341340
}
342341
}
343342

344-
stdoutFile, validOut := inv.Stdout.(*os.File)
345343
stdinFile, validIn := inv.Stdin.(*os.File)
346-
if validOut && validIn && isatty.IsTerminal(stdoutFile.Fd()) {
347-
state, err := term.MakeRaw(int(stdinFile.Fd()))
344+
stdoutFile, validOut := inv.Stdout.(*os.File)
345+
if validIn && validOut && isatty.IsTerminal(stdinFile.Fd()) && isatty.IsTerminal(stdoutFile.Fd()) {
346+
inState, err := pty.MakeInputRaw(stdinFile.Fd())
347+
if err != nil {
348+
return err
349+
}
350+
defer func() {
351+
_ = pty.RestoreTerminal(stdinFile.Fd(), inState)
352+
}()
353+
outState, err := pty.MakeOutputRaw(stdoutFile.Fd())
348354
if err != nil {
349355
return err
350356
}
351357
defer func() {
352-
_ = term.Restore(int(stdinFile.Fd()), state)
358+
_ = pty.RestoreTerminal(stdoutFile.Fd(), outState)
353359
}()
354360

355361
windowChange := listenWindowSize(ctx)

cli/support.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (r *RootCmd) supportBundle() *serpent.Command {
101101

102102
// Check if we're running inside a workspace
103103
if val, found := os.LookupEnv("CODER"); found && val == "true" {
104-
_, _ = fmt.Fprintln(inv.Stderr, "Running inside Coder workspace; this can affect results!")
104+
cliui.Warn(inv.Stderr, "Running inside Coder workspace; this can affect results!")
105105
cliLog.Debug(inv.Context(), "running inside coder workspace")
106106
}
107107

@@ -122,7 +122,7 @@ func (r *RootCmd) supportBundle() *serpent.Command {
122122

123123
if len(inv.Args) == 0 {
124124
cliLog.Warn(inv.Context(), "no workspace specified")
125-
_, _ = fmt.Fprintln(inv.Stderr, "Warning: no workspace specified. This will result in incomplete information.")
125+
cliui.Warn(inv.Stderr, "No workspace specified. This will result in incomplete information.")
126126
} else {
127127
ws, err := namedWorkspace(inv.Context(), client, inv.Args[0])
128128
if err != nil {
@@ -184,13 +184,24 @@ func (r *RootCmd) supportBundle() *serpent.Command {
184184
_ = os.Remove(outputPath) // best effort
185185
return xerrors.Errorf("create support bundle: %w", err)
186186
}
187+
docsURL := bun.Deployment.Config.Values.DocsURL.String()
188+
deployHealthSummary := bun.Deployment.HealthReport.Summarize(docsURL)
189+
if len(deployHealthSummary) > 0 {
190+
cliui.Warn(inv.Stdout, "Deployment health issues detected:", deployHealthSummary...)
191+
}
192+
clientNetcheckSummary := bun.Network.Netcheck.Summarize("Client netcheck:", docsURL)
193+
if len(clientNetcheckSummary) > 0 {
194+
cliui.Warn(inv.Stdout, "Networking issues detected:", deployHealthSummary...)
195+
}
196+
187197
bun.CLILogs = cliLogBuf.Bytes()
188198

189199
if err := writeBundle(bun, zwr); err != nil {
190200
_ = os.Remove(outputPath) // best effort
191201
return xerrors.Errorf("write support bundle to %s: %w", outputPath, err)
192202
}
193203
_, _ = fmt.Fprintln(inv.Stderr, "Wrote support bundle to "+outputPath)
204+
194205
return nil
195206
},
196207
}

coderd/apidoc/docs.go

Lines changed: 22 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 14 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/azureidentity/azureidentity_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"crypto/x509"
66
"encoding/pem"
7+
"runtime"
78
"testing"
89
"time"
910

@@ -14,6 +15,11 @@ import (
1415

1516
func TestValidate(t *testing.T) {
1617
t.Parallel()
18+
if runtime.GOOS == "darwin" {
19+
// This test fails on MacOS for some reason. See https://github.com/coder/coder/issues/12978
20+
t.Skip()
21+
}
22+
1723
mustTime := func(layout string, value string) time.Time {
1824
ti, err := time.Parse(layout, value)
1925
require.NoError(t, err)

coderd/database/db.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func (q *sqlQuerier) InTx(function func(Store) error, txOpts *sql.TxOptions) err
103103
// Transaction succeeded.
104104
return nil
105105
}
106-
if err != nil && !IsSerializedError(err) {
106+
if !IsSerializedError(err) {
107107
// We should only retry if the error is a serialization error.
108108
return err
109109
}

coderd/database/dbmem/dbmem.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9089,7 +9089,6 @@ func (q *FakeQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg database.
90899089
params = append(params, param)
90909090
}
90919091

9092-
var innerErr error
90939092
index := slices.IndexFunc(params, func(buildParam database.WorkspaceBuildParameter) bool {
90949093
// If hasParam matches, then we are done. This is a good match.
90959094
if slices.ContainsFunc(arg.HasParam, func(name string) bool {
@@ -9116,9 +9115,6 @@ func (q *FakeQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg database.
91169115

91179116
return match
91189117
})
9119-
if innerErr != nil {
9120-
return nil, xerrors.Errorf("error searching workspace build params: %w", innerErr)
9121-
}
91229118
if index < 0 {
91239119
continue
91249120
}

coderd/database/dbmetrics/dbmetrics.go

Lines changed: 24 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/migrations/000196_external_auth_providers_jsonb.down.sql

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ CREATE OR REPLACE FUNCTION revert_migrate_external_auth_providers_to_jsonb(jsonb
1111
DECLARE
1212
result text[];
1313
BEGIN
14-
SELECT
15-
array_agg(id::text) INTO result
16-
FROM (
17-
SELECT
18-
jsonb_array_elements($1) ->> 'id' AS id) AS external_auth_provider_ids;
14+
IF jsonb_typeof($1) = 'null' THEN
15+
result := '{}';
16+
ELSE
17+
SELECT
18+
array_agg(id::text) INTO result
19+
FROM (
20+
SELECT
21+
jsonb_array_elements($1) ->> 'id' AS id) AS external_auth_provider_ids;
22+
END IF;
1923
RETURN result;
2024
END;
2125
$$;

0 commit comments

Comments
 (0)