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

Skip to content

Commit 4d610e1

Browse files
committed
Merge branch 'main' into bq/add-version-message
2 parents 4fff5e2 + f8f4ae8 commit 4d610e1

File tree

107 files changed

+2714
-1966
lines changed

Some content is hidden

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

107 files changed

+2714
-1966
lines changed

.devcontainer/Dockerfile

Lines changed: 0 additions & 83 deletions
This file was deleted.

.devcontainer/devcontainer.json

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
1-
// For format details, see https://aka.ms/devcontainer.json
21
{
32
"name": "Development environments on your infrastructure",
4-
5-
// Sets the run context to one level up instead of the .devcontainer folder.
6-
"context": ".",
7-
8-
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
9-
"dockerFile": "Dockerfile",
10-
11-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
12-
// "forwardPorts": [],
13-
14-
"postStartCommand": "dockerd",
15-
16-
// privileged is required by GitHub codespaces - https://github.com/microsoft/vscode-dev-containers/issues/727
17-
"runArgs": [
18-
"--cap-add=SYS_PTRACE",
19-
"--security-opt",
20-
"seccomp=unconfined",
21-
"--privileged",
22-
"--init"
23-
]
3+
"image": "codercom/oss-dogfood:latest",
4+
5+
"features": {
6+
// See all possible options here https://github.com/devcontainers/features/tree/main/src/docker-in-docker
7+
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
8+
},
9+
// SYS_PTRACE to enable go debugging
10+
// without --priviliged the Github Codespace build fails (not required otherwise)
11+
"runArgs": ["--cap-add=SYS_PTRACE", "--privileged"]
2412
}

.github/actions/setup-go/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: |
44
inputs:
55
version:
66
description: "The Go version to use."
7-
default: "1.20.5"
7+
default: "1.20.6"
88
runs:
99
using: "composite"
1010
steps:

.github/dependabot.yaml

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,23 +92,36 @@ updates:
9292
- dependency-name: "@types/node"
9393
update-types:
9494
- version-update:semver-major
95-
96-
- package-ecosystem: "terraform"
97-
directory: "/examples/templates"
98-
schedule:
99-
interval: "monthly"
100-
time: "06:00"
101-
timezone: "America/Chicago"
102-
commit-message:
103-
prefix: "chore"
104-
labels: []
105-
ignore:
106-
# We likely want to update this ourselves.
107-
- dependency-name: "coder/coder"
10895
groups:
109-
examples-terraform:
96+
npm-react:
11097
patterns:
111-
- "*"
98+
- "react*"
99+
- "@types/react*"
100+
npm-xterm:
101+
patterns:
102+
- "xterm*"
103+
npm-xstate:
104+
patterns:
105+
- "xstate"
106+
- "@xstate*"
107+
npm-mui:
108+
patterns:
109+
- "@mui*"
110+
npm-storybook:
111+
patterns:
112+
- "@storybook*"
113+
- "storybook*"
114+
npm-eslint:
115+
patterns:
116+
- "eslint*"
117+
- "@eslint*"
118+
- "@typescript-eslint/eslint-plugin"
119+
- "@typescript-eslint/parser"
120+
npm-jest:
121+
patterns:
122+
- "jest*"
123+
- "@swc/jest"
124+
- "@types/jest"
112125

113126
# Update dogfood.
114127
- package-ecosystem: "docker"

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ jobs:
122122
123123
# Check for any typos
124124
- name: Check for typos
125-
uses: crate-ci/typos@v1.14.12
125+
uses: crate-ci/typos@v1.16.0
126126
with:
127127
config: .github/workflows/typos.toml
128128

@@ -198,7 +198,7 @@ jobs:
198198
with:
199199
# This doesn't need caching. It's super fast anyways!
200200
cache: false
201-
go-version: 1.20.5
201+
go-version: 1.20.6
202202

203203
- name: Install prettier
204204
# We only need prettier for fmt, so do not install all dependencies.

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ env:
3131
# For some reason, setup-go won't actually pick up a new patch version if
3232
# it has an old one cached. We need to manually specify the versions so we
3333
# can get the latest release. Never use "~1.xx" here!
34-
CODER_GO_VERSION: "1.20.5"
34+
CODER_GO_VERSION: "1.20.6"
3535

3636
jobs:
3737
release:

.github/workflows/security.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ concurrency:
2222
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
2323

2424
env:
25-
CODER_GO_VERSION: "1.20.5"
25+
CODER_GO_VERSION: "1.20.6"
2626

2727
jobs:
2828
codeql:

.github/workflows/typos.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Jetbrains = "JetBrains"
44
IST = "IST"
55
MacOS = "macOS"
66
AKS = "AKS"
7+
O_WRONLY = "O_WRONLY"
78

89
[default.extend-words]
910
AKS = "AKS"
@@ -25,4 +26,6 @@ extend-exclude = [
2526
"**XService**.ts",
2627
"**identity.go",
2728
"scripts/ci-report/testdata/**",
29+
"**/*_test.go",
30+
"**/*.test.tsx"
2831
]

agent/usershell/usershell_darwin.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
package usershell
22

3-
import "os"
3+
import (
4+
"os"
5+
"os/exec"
6+
"path/filepath"
7+
"strings"
8+
9+
"golang.org/x/xerrors"
10+
)
411

512
// Get returns the $SHELL environment variable.
6-
func Get(_ string) (string, error) {
7-
return os.Getenv("SHELL"), nil
13+
func Get(username string) (string, error) {
14+
// This command will output "UserShell: /bin/zsh" if successful, we
15+
// can ignore the error since we have fallback behavior.
16+
out, _ := exec.Command("dscl", ".", "-read", filepath.Join("/Users", username), "UserShell").Output()
17+
s, ok := strings.CutPrefix(string(out), "UserShell: ")
18+
if ok {
19+
return strings.TrimSpace(s), nil
20+
}
21+
if s = os.Getenv("SHELL"); s != "" {
22+
return s, nil
23+
}
24+
return "", xerrors.Errorf("shell for user %q not found via dscl or in $SHELL", username)
825
}

agent/usershell/usershell_other.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,8 @@ func Get(username string) (string, error) {
2727
}
2828
return parts[6], nil
2929
}
30-
return "", xerrors.Errorf("user %q not found in /etc/passwd", username)
30+
if s := os.Getenv("SHELL"); s != "" {
31+
return s, nil
32+
}
33+
return "", xerrors.Errorf("shell for user %q not found in /etc/passwd or $SHELL", username)
3134
}

agent/usershell/usershell_other_test.go

Lines changed: 0 additions & 27 deletions
This file was deleted.

agent/usershell/usershell_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package usershell_test
2+
3+
import (
4+
"os/user"
5+
"runtime"
6+
"testing"
7+
8+
"github.com/stretchr/testify/require"
9+
10+
"github.com/coder/coder/agent/usershell"
11+
)
12+
13+
//nolint:paralleltest,tparallel // This test sets an environment variable.
14+
func TestGet(t *testing.T) {
15+
if runtime.GOOS == "windows" {
16+
t.SkipNow()
17+
}
18+
19+
t.Run("Fallback", func(t *testing.T) {
20+
t.Setenv("SHELL", "/bin/sh")
21+
22+
t.Run("NonExistentUser", func(t *testing.T) {
23+
shell, err := usershell.Get("notauser")
24+
require.NoError(t, err)
25+
require.Equal(t, "/bin/sh", shell)
26+
})
27+
})
28+
29+
t.Run("NoFallback", func(t *testing.T) {
30+
// Disable env fallback for these tests.
31+
t.Setenv("SHELL", "")
32+
33+
t.Run("NotFound", func(t *testing.T) {
34+
_, err := usershell.Get("notauser")
35+
require.Error(t, err)
36+
})
37+
38+
t.Run("User", func(t *testing.T) {
39+
u, err := user.Current()
40+
require.NoError(t, err)
41+
shell, err := usershell.Get(u.Username)
42+
require.NoError(t, err)
43+
require.NotEmpty(t, shell)
44+
})
45+
})
46+
}

cli/clibase/cmd.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,18 @@ func (inv *Invocation) run(state *runState) error {
333333
)
334334
}
335335

336+
// All options should be set. Check all required options have sources,
337+
// meaning they were set by the user in some way (env, flag, etc).
338+
var missing []string
339+
for _, opt := range inv.Command.Options {
340+
if opt.Required && opt.ValueSource == ValueSourceNone {
341+
missing = append(missing, opt.Flag)
342+
}
343+
}
344+
if len(missing) > 0 {
345+
return xerrors.Errorf("Missing values for the required flags: %s", strings.Join(missing, ", "))
346+
}
347+
336348
if inv.Command.RawArgs {
337349
// If we're at the root command, then the name is omitted
338350
// from the arguments, so we can just use the entire slice.

0 commit comments

Comments
 (0)