Skip to content

Commit ea55740

Browse files
committed
Merge branch 'main' into tailnet
2 parents 66f33ad + 4fde536 commit ea55740

File tree

211 files changed

+3654
-1764
lines changed

Some content is hidden

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

211 files changed

+3654
-1764
lines changed

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
site/ @coder/frontend
2+
docs/ @ammario

.github/stale.yaml

-12
This file was deleted.

.github/workflows/stale.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Stale Issue Cron
2+
on:
3+
schedule:
4+
# Every day at midnight
5+
- cron: "0 0 * * *"
6+
workflow_dispatch:
7+
jobs:
8+
stale:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
issues: write
12+
pull-requests: write
13+
steps:
14+
- uses: actions/stale@v5.1.0
15+
stale-issue-label: stale
16+
stale-pr-label: stale

agent/agent.go

+2-11
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,8 @@ type Options struct {
5757
}
5858

5959
type Metadata struct {
60-
IPAddresses []netaddr.IP `json:"ip_addresses"`
61-
DERPMap *tailcfg.DERPMap `json:"derpmap"`
62-
63-
OwnerEmail string `json:"owner_email"`
64-
OwnerUsername string `json:"owner_username"`
60+
IPAddresses []netaddr.IP `json:"ip_addresses"`
61+
DERPMap *tailcfg.DERPMap `json:"derpmap"`
6562
EnvironmentVariables map[string]string `json:"environment_variables"`
6663
StartupScript string `json:"startup_script"`
6764
Directory string `json:"directory"`
@@ -501,12 +498,6 @@ func (a *agent) createCommand(ctx context.Context, rawCommand string, env []stri
501498
// If using backslashes, it's unable to find the executable.
502499
unixExecutablePath := strings.ReplaceAll(executablePath, "\\", "/")
503500
cmd.Env = append(cmd.Env, fmt.Sprintf(`GIT_SSH_COMMAND=%s gitssh --`, unixExecutablePath))
504-
// These prevent the user from having to specify _anything_ to successfully commit.
505-
// Both author and committer must be set!
506-
cmd.Env = append(cmd.Env, fmt.Sprintf(`GIT_AUTHOR_EMAIL=%s`, metadata.OwnerEmail))
507-
cmd.Env = append(cmd.Env, fmt.Sprintf(`GIT_COMMITTER_EMAIL=%s`, metadata.OwnerEmail))
508-
cmd.Env = append(cmd.Env, fmt.Sprintf(`GIT_AUTHOR_NAME=%s`, metadata.OwnerUsername))
509-
cmd.Env = append(cmd.Env, fmt.Sprintf(`GIT_COMMITTER_NAME=%s`, metadata.OwnerUsername))
510501

511502
// Load environment variables passed via the agent.
512503
// These should override all variables we manually specify.

cli/cliui/parameter.go

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func ParameterSchema(cmd *cobra.Command, parameterSchema codersdk.ParameterSchem
4747
value, err = Prompt(cmd, PromptOptions{
4848
Text: Styles.Bold.Render(text),
4949
})
50+
value = strings.TrimSpace(value)
5051
}
5152
if err != nil {
5253
return "", err

cli/cliui/prompt.go

+22-6
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,41 @@ type PromptOptions struct {
2424
Validate func(string) error
2525
}
2626

27+
const skipPromptFlag = "yes"
28+
2729
func AllowSkipPrompt(cmd *cobra.Command) {
28-
cmd.Flags().BoolP("yes", "y", false, "Bypass prompts")
30+
cmd.Flags().BoolP(skipPromptFlag, "y", false, "Bypass prompts")
2931
}
3032

33+
const (
34+
ConfirmYes = "yes"
35+
ConfirmNo = "no"
36+
)
37+
3138
// Prompt asks the user for input.
3239
func Prompt(cmd *cobra.Command, opts PromptOptions) (string, error) {
3340
// If the cmd has a "yes" flag for skipping confirm prompts, honor it.
3441
// If it's not a "Confirm" prompt, then don't skip. As the default value of
3542
// "yes" makes no sense.
36-
if opts.IsConfirm && cmd.Flags().Lookup("yes") != nil {
37-
if skip, _ := cmd.Flags().GetBool("yes"); skip {
38-
return "yes", nil
43+
if opts.IsConfirm && cmd.Flags().Lookup(skipPromptFlag) != nil {
44+
if skip, _ := cmd.Flags().GetBool(skipPromptFlag); skip {
45+
return ConfirmYes, nil
3946
}
4047
}
4148

4249
_, _ = fmt.Fprint(cmd.OutOrStdout(), Styles.FocusedPrompt.String()+opts.Text+" ")
4350
if opts.IsConfirm {
44-
opts.Default = "yes"
45-
_, _ = fmt.Fprint(cmd.OutOrStdout(), Styles.Placeholder.Render("("+Styles.Bold.Render("yes")+Styles.Placeholder.Render("/no) ")))
51+
if len(opts.Default) == 0 {
52+
opts.Default = ConfirmYes
53+
}
54+
renderedYes := Styles.Placeholder.Render(ConfirmYes)
55+
renderedNo := Styles.Placeholder.Render(ConfirmNo)
56+
if opts.Default == ConfirmYes {
57+
renderedYes = Styles.Bold.Render(ConfirmYes)
58+
} else {
59+
renderedNo = Styles.Bold.Render(ConfirmNo)
60+
}
61+
_, _ = fmt.Fprint(cmd.OutOrStdout(), Styles.Placeholder.Render("("+renderedYes+Styles.Placeholder.Render("/"+renderedNo+Styles.Placeholder.Render(") "))))
4662
} else if opts.Default != "" {
4763
_, _ = fmt.Fprint(cmd.OutOrStdout(), Styles.Placeholder.Render("("+opts.Default+") "))
4864
}

cli/configssh.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,16 @@ func configSSH() *cobra.Command {
141141
Annotations: workspaceCommand,
142142
Use: "config-ssh",
143143
Short: "Populate your SSH config with Host entries for all of your workspaces",
144-
Example: `
145-
- You can use -o (or --ssh-option) so set SSH options to be used for all your
146-
workspaces.
147-
148-
` + cliui.Styles.Code.Render("$ coder config-ssh -o ForwardAgent=yes") + `
149-
150-
- You can use --dry-run (or -n) to see the changes that would be made.
151-
152-
` + cliui.Styles.Code.Render("$ coder config-ssh --dry-run"),
144+
Example: formatExamples(
145+
example{
146+
Description: "You can use -o (or --ssh-option) so set SSH options to be used for all your workspaces",
147+
Command: "coder config-ssh -o ForwardAgent=yes",
148+
},
149+
example{
150+
Description: "You can use --dry-run (or -n) to see the changes that would be made",
151+
Command: "coder config-ssh --dry-run",
152+
},
153+
),
153154
RunE: func(cmd *cobra.Command, args []string) error {
154155
client, err := createClient(cmd)
155156
if err != nil {

cli/delete.go

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func deleteWorkspace() *cobra.Command {
2222
_, err := cliui.Prompt(cmd, cliui.PromptOptions{
2323
Text: "Confirm delete workspace?",
2424
IsConfirm: true,
25+
Default: cliui.ConfirmNo,
2526
})
2627
if err != nil {
2728
return err

cli/dotfiles.go

+10-7
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ import (
1818
)
1919

2020
func dotfiles() *cobra.Command {
21-
var (
22-
symlinkDir string
23-
)
21+
var symlinkDir string
2422
cmd := &cobra.Command{
25-
Use: "dotfiles [git_repo_url]",
26-
Args: cobra.ExactArgs(1),
27-
Short: "Check out and install a dotfiles repository.",
28-
Example: "coder dotfiles [-y] git@github.com:example/dotfiles.git",
23+
Use: "dotfiles [git_repo_url]",
24+
Args: cobra.ExactArgs(1),
25+
Short: "Check out and install a dotfiles repository.",
26+
Example: formatExamples(
27+
example{
28+
Description: "Check out and install a dotfiles repository without prompts",
29+
Command: "coder dotfiles --yes git@github.com:example/dotfiles.git",
30+
},
31+
),
2932
RunE: func(cmd *cobra.Command, args []string) error {
3033
var (
3134
dotfilesRepoDir = "dotfiles"

cli/login.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func login() *cobra.Command {
8989
}
9090
_, err := cliui.Prompt(cmd, cliui.PromptOptions{
9191
Text: "Would you like to create the first user?",
92-
Default: "yes",
92+
Default: cliui.ConfirmYes,
9393
IsConfirm: true,
9494
})
9595
if errors.Is(err, cliui.Canceled) {

cli/logout.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func logout() *cobra.Command {
2828
_, err = cliui.Prompt(cmd, cliui.PromptOptions{
2929
Text: "Are you sure you want to log out?",
3030
IsConfirm: true,
31-
Default: "yes",
31+
Default: cliui.ConfirmYes,
3232
})
3333
if err != nil {
3434
return err

cli/parameters.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ import (
1010

1111
func parameters() *cobra.Command {
1212
cmd := &cobra.Command{
13-
Short: "List parameters for a given scope",
14-
Example: "coder parameters list workspace my-workspace",
15-
Use: "parameters",
13+
Short: "List parameters for a given scope",
14+
Example: formatExamples(
15+
example{
16+
Command: "coder parameters list workspace my-workspace",
17+
},
18+
),
19+
Use: "parameters",
1620
// Currently hidden as this shows parameter values, not parameter
1721
// schemes. Until we have a good way to distinguish the two, it's better
1822
// not to add confusion or lock ourselves into a certain api.

cli/portforward.go

+22-22
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,28 @@ func portForward() *cobra.Command {
3232
Short: "Forward one or more ports from the local machine to the remote workspace",
3333
Aliases: []string{"tunnel"},
3434
Args: cobra.ExactArgs(1),
35-
Example: `
36-
- Port forward a single TCP port from 1234 in the workspace to port 5678 on
37-
your local machine
38-
39-
` + cliui.Styles.Code.Render("$ coder port-forward <workspace> --tcp 5678:1234") + `
40-
41-
- Port forward a single UDP port from port 9000 to port 9000 on your local
42-
machine
43-
44-
` + cliui.Styles.Code.Render("$ coder port-forward <workspace> --udp 9000") + `
45-
46-
- Forward a Unix socket in the workspace to a local Unix socket
47-
48-
` + cliui.Styles.Code.Render("$ coder port-forward <workspace> --unix ./local.sock:~/remote.sock") + `
49-
50-
- Forward a Unix socket in the workspace to a local TCP port
51-
52-
` + cliui.Styles.Code.Render("$ coder port-forward <workspace> --unix 8080:~/remote.sock") + `
53-
54-
- Port forward multiple TCP ports and a UDP port
55-
56-
` + cliui.Styles.Code.Render("$ coder port-forward <workspace> --tcp 8080:8080 --tcp 9000:3000 --udp 5353:53"),
35+
Example: formatExamples(
36+
example{
37+
Description: "Port forward a single TCP port from 1234 in the workspace to port 5678 on your local machine",
38+
Command: "coder port-forward <workspace> --tcp 5678:1234",
39+
},
40+
example{
41+
Description: "Port forward a single UDP port from port 9000 to port 9000 on your local machine",
42+
Command: "coder port-forward <workspace> --udp 9000",
43+
},
44+
example{
45+
Description: "Forward a Unix socket in the workspace to a local Unix socket",
46+
Command: "coder port-forward <workspace> --unix ./local.sock:~/remote.sock",
47+
},
48+
example{
49+
Description: "Forward a Unix socket in the workspace to a local TCP port",
50+
Command: "coder port-forward <workspace> --unix 8080:~/remote.sock",
51+
},
52+
example{
53+
Description: "Port forward multiple TCP ports and a UDP port",
54+
Command: "coder port-forward <workspace> --tcp 8080:8080 --tcp 9000:3000 --udp 5353:53",
55+
},
56+
),
5757
RunE: func(cmd *cobra.Command, args []string) error {
5858
specs, err := parsePortForwards(tcpForwards, udpForwards, unixForwards)
5959
if err != nil {

0 commit comments

Comments
 (0)