Skip to content

Commit 5c6344f

Browse files
committed
Merge branch 'main' into resource_acl_list
2 parents ba32928 + 7fe7ffe commit 5c6344f

File tree

200 files changed

+4755
-1932
lines changed

Some content is hidden

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

200 files changed

+4755
-1932
lines changed

.devcontainer/Dockerfile

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
FROM ubuntu
2+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
3+
4+
ENV EDITOR=vim
5+
6+
RUN apt-get update && apt-get upgrade
7+
8+
RUN apt-get install --yes \
9+
ca-certificates \
10+
bash-completion \
11+
build-essential \
12+
curl \
13+
cmake \
14+
direnv \
15+
emacs-nox \
16+
gnupg \
17+
htop \
18+
jq \
19+
less \
20+
lsb-release \
21+
lsof \
22+
man-db \
23+
nano \
24+
neovim \
25+
ssl-cert \
26+
sudo \
27+
unzip \
28+
xz-utils \
29+
zip
30+
31+
# configure locales to UTF8
32+
RUN apt-get install locales && locale-gen en_US.UTF-8
33+
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
34+
35+
# configure direnv
36+
RUN direnv hook bash >> $HOME/.bashrc
37+
38+
# install nix
39+
RUN sh <(curl -L https://nixos.org/nix/install) --daemon
40+
41+
RUN mkdir -p $HOME/.config/nix $HOME/.config/nixpkgs \
42+
&& echo 'sandbox = false' >> $HOME/.config/nix/nix.conf \
43+
&& echo '{ allowUnfree = true; }' >> $HOME/.config/nixpkgs/config.nix \
44+
&& echo '. $HOME/.nix-profile/etc/profile.d/nix.sh' >> $HOME/.bashrc
45+
46+
47+
# install docker and configure daemon to use vfs as GitHub codespaces requires vfs
48+
# https://github.com/moby/moby/issues/13742#issuecomment-725197223
49+
RUN mkdir -p /etc/apt/keyrings \
50+
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg \
51+
&& echo \
52+
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
53+
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null \
54+
&& apt-get update \
55+
&& apt-get install --yes docker-ce docker-ce-cli containerd.io docker-compose-plugin \
56+
&& mkdir -p /etc/docker \
57+
&& echo '{"cgroup-parent":"/actions_job","storage-driver":"vfs"}' >> /etc/docker/daemon.json
58+
59+
# install golang and language tooling
60+
ENV GO_VERSION=1.19
61+
ENV GOPATH=$HOME/go-packages
62+
ENV GOROOT=$HOME/go
63+
ENV PATH=$GOROOT/bin:$GOPATH/bin:$PATH
64+
RUN curl -fsSL https://dl.google.com/go/go$GO_VERSION.linux-amd64.tar.gz | tar xzs
65+
RUN echo 'export PATH=$GOPATH/bin:$PATH' >> $HOME/.bashrc
66+
67+
RUN bash -c ". $HOME/.bashrc \
68+
go install -v golang.org/x/tools/gopls@latest \
69+
&& go install -v mvdan.cc/sh/v3/cmd/shfmt@latest \
70+
"
71+
72+
# install nodejs
73+
RUN bash -c "$(curl -fsSL https://deb.nodesource.com/setup_14.x)" \
74+
&& apt-get install -y nodejs
75+
76+
# install zstd
77+
RUN bash -c "$(curl -fsSL https://raw.githubusercontent.com/horta/zstd.install/main/install)"
78+
79+
# install nfpm
80+
RUN echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list \
81+
&& apt update \
82+
&& apt install nfpm
83+

.devcontainer/devcontainer.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// For format details, see https://aka.ms/devcontainer.json
2+
{
3+
"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": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined", "--privileged", "--init" ]
18+
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ vendor
1515
yarn-error.log
1616
gotests.coverage
1717
.idea
18+
.gitpod.yml
1819
.DS_Store
1920

2021
# Front-end ignore

.vscode/settings.json

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"circbuf",
99
"cliflag",
1010
"cliui",
11+
"codecov",
12+
"Codespaces",
1113
"coderd",
1214
"coderdtest",
1315
"codersdk",
@@ -80,6 +82,7 @@
8082
"ptty",
8183
"ptys",
8284
"ptytest",
85+
"quickstart",
8386
"reconfig",
8487
"retrier",
8588
"rpty",
@@ -117,10 +120,12 @@
117120
"tstun",
118121
"turnconn",
119122
"typegen",
123+
"typesafe",
120124
"unconvert",
121125
"Untar",
122126
"Userspace",
123127
"VMID",
128+
"walkthrough",
124129
"weblinks",
125130
"webrtc",
126131
"wgcfg",
@@ -140,6 +145,10 @@
140145
"xstate",
141146
"yamux"
142147
],
148+
"cSpell.ignorePaths": [
149+
"site/package.json",
150+
".vscode/settings.json"
151+
],
143152
"emeraldwalk.runonsave": {
144153
"commands": [
145154
{

Makefile

+8-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ GOARCH := $(shell go env GOARCH)
3737
GOOS_BIN_EXT := $(if $(filter windows, $(GOOS)),.exe,)
3838
VERSION := $(shell ./scripts/version.sh)
3939

40+
# Use the highest ZSTD compression level in CI.
41+
ifdef CI
42+
ZSTDFLAGS := -22 --ultra
43+
else
44+
ZSTDFLAGS := -6
45+
endif
46+
4047
# All ${OS}_${ARCH} combos we build for. Windows binaries have the .exe suffix.
4148
OS_ARCHES := \
4249
linux_amd64 linux_arm64 linux_armv7 \
@@ -102,9 +109,8 @@ build/coder-slim_$(VERSION).tar: build/coder-slim_$(VERSION)_checksums.sha1 $(CO
102109
popd
103110

104111
build/coder-slim_$(VERSION).tar.zst site/out/bin/coder.tar.zst: build/coder-slim_$(VERSION).tar
105-
zstd -6 \
112+
zstd $(ZSTDFLAGS) \
106113
--force \
107-
--ultra \
108114
--long \
109115
--no-progress \
110116
-o "build/coder-slim_$(VERSION).tar.zst" \

agent/agent_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ func TestAgent(t *testing.T) {
559559
DERPMap: derpMap,
560560
}, 0)
561561
defer conn.Close()
562-
res, err := conn.Speedtest(speedtest.Upload, speedtest.MinDuration)
562+
res, err := conn.Speedtest(speedtest.Upload, 250*time.Millisecond)
563563
require.NoError(t, err)
564564
t.Logf("%.2f MBits/s", res[len(res)-1].MBitsPerSecond())
565565
})

cli/agent_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func TestWorkspaceAgent(t *testing.T) {
4747
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
4848
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
4949

50-
cmd, _ := clitest.New(t, "agent", "--auth", "azure-instance-identity", "--agent-url", client.URL.String(), "--wireguard=false")
50+
cmd, _ := clitest.New(t, "agent", "--auth", "azure-instance-identity", "--agent-url", client.URL.String())
5151
ctx, cancelFunc := context.WithCancel(context.Background())
5252
defer cancelFunc()
5353
errC := make(chan error)
@@ -105,7 +105,7 @@ func TestWorkspaceAgent(t *testing.T) {
105105
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
106106
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
107107

108-
cmd, _ := clitest.New(t, "agent", "--auth", "aws-instance-identity", "--agent-url", client.URL.String(), "--wireguard=false")
108+
cmd, _ := clitest.New(t, "agent", "--auth", "aws-instance-identity", "--agent-url", client.URL.String())
109109
ctx, cancelFunc := context.WithCancel(context.Background())
110110
defer cancelFunc()
111111
errC := make(chan error)
@@ -163,7 +163,7 @@ func TestWorkspaceAgent(t *testing.T) {
163163
workspace := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
164164
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
165165

166-
cmd, _ := clitest.New(t, "agent", "--auth", "google-instance-identity", "--agent-url", client.URL.String(), "--wireguard=false")
166+
cmd, _ := clitest.New(t, "agent", "--auth", "google-instance-identity", "--agent-url", client.URL.String())
167167
ctx, cancelFunc := context.WithCancel(context.Background())
168168
defer cancelFunc()
169169
errC := make(chan error)

cli/cliflag/cliflag.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import (
1818

1919
"github.com/spf13/cobra"
2020
"github.com/spf13/pflag"
21+
22+
"github.com/coder/coder/cli/cliui"
2123
)
2224

2325
// IsSetBool returns the value of the boolean flag if it is set.
@@ -176,7 +178,7 @@ func fmtUsage(u string, env string) string {
176178
if strings.HasSuffix(u, ".") {
177179
dot = ""
178180
}
179-
u = fmt.Sprintf("%s%s\nConsumes $%s", u, dot, env)
181+
u = fmt.Sprintf("%s%s\n"+cliui.Styles.Placeholder.Render("Consumes $%s"), u, dot, env)
180182
}
181183

182184
return u

cli/cliui/cliui.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var Styles = struct {
4848
Field: defaultStyles.Code.Copy().Foreground(lipgloss.AdaptiveColor{Light: "#000000", Dark: "#FFFFFF"}),
4949
Keyword: defaultStyles.Keyword,
5050
Paragraph: defaultStyles.Paragraph,
51-
Placeholder: lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "#585858", Dark: "#005fff"}),
51+
Placeholder: lipgloss.NewStyle().Foreground(lipgloss.AdaptiveColor{Light: "#585858", Dark: "#4d46b3"}),
5252
Prompt: defaultStyles.Prompt.Foreground(lipgloss.AdaptiveColor{Light: "#9B9B9B", Dark: "#5C5C5C"}),
5353
FocusedPrompt: defaultStyles.FocusedPrompt.Foreground(lipgloss.Color("#651fff")),
5454
Fuchsia: defaultStyles.SelectedMenuItem.Copy(),

cli/configssh.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func configSSH() *cobra.Command {
144144
cmd := &cobra.Command{
145145
Annotations: workspaceCommand,
146146
Use: "config-ssh",
147-
Short: "Populate your SSH config with Host entries for all of your workspaces",
147+
Short: "Add an SSH Host entry for your workspaces \"ssh coder.workspace\"",
148148
Example: formatExamples(
149149
example{
150150
Description: "You can use -o (or --ssh-option) so set SSH options to be used for all your workspaces",
@@ -374,7 +374,7 @@ func configSSH() *cobra.Command {
374374
cmd.Flags().BoolVarP(&skipProxyCommand, "skip-proxy-command", "", false, "Specifies whether the ProxyCommand option should be skipped. Useful for testing.")
375375
_ = cmd.Flags().MarkHidden("skip-proxy-command")
376376
cliflag.BoolVarP(cmd.Flags(), &usePreviousOpts, "use-previous-options", "", "CODER_SSH_USE_PREVIOUS_OPTIONS", false, "Specifies whether or not to keep options from previous run of config-ssh.")
377-
cliflag.BoolVarP(cmd.Flags(), &wireguard, "wireguard", "", "CODER_CONFIG_SSH_WIREGUARD", false, "Whether to use Wireguard for SSH tunneling.")
377+
cliflag.BoolVarP(cmd.Flags(), &wireguard, "wireguard", "", "CODER_CONFIG_SSH_WIREGUARD", true, "Whether to use Wireguard for SSH tunneling.")
378378
_ = cmd.Flags().MarkHidden("wireguard")
379379

380380
cliui.AllowSkipPrompt(cmd)

cli/create.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func create() *cobra.Command {
2525
cmd := &cobra.Command{
2626
Annotations: workspaceCommand,
2727
Use: "create [name]",
28-
Short: "Create a workspace from a template",
28+
Short: "Create a workspace",
2929
RunE: func(cmd *cobra.Command, args []string) error {
3030
client, err := CreateClient(cmd)
3131
if err != nil {

cli/dotfiles.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func dotfiles() *cobra.Command {
2222
cmd := &cobra.Command{
2323
Use: "dotfiles [git_repo_url]",
2424
Args: cobra.ExactArgs(1),
25-
Short: "Check out and install a dotfiles repository.",
25+
Short: "Checkout and install a dotfiles repository from a Git URL",
2626
Example: formatExamples(
2727
example{
2828
Description: "Check out and install a dotfiles repository without prompts",

cli/features.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
func features() *cobra.Command {
1717
cmd := &cobra.Command{
18-
Short: "List features",
18+
Short: "List Enterprise features",
1919
Use: "features",
2020
Aliases: []string{"feature"},
2121
}

cli/list.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func list() *cobra.Command {
6666
cmd := &cobra.Command{
6767
Annotations: workspaceCommand,
6868
Use: "list",
69-
Short: "List all workspaces",
69+
Short: "List workspaces",
7070
Aliases: []string{"ls"},
7171
Args: cobra.ExactArgs(0),
7272
RunE: func(cmd *cobra.Command, args []string) error {

cli/login.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func login() *cobra.Command {
4545
)
4646
cmd := &cobra.Command{
4747
Use: "login <url>",
48-
Short: "Authenticate with a Coder deployment",
48+
Short: "Authenticate with Coder deployment",
4949
Args: cobra.ExactArgs(1),
5050
RunE: func(cmd *cobra.Command, args []string) error {
5151
rawURL := args[0]
@@ -83,7 +83,7 @@ func login() *cobra.Command {
8383

8484
hasInitialUser, err := client.HasFirstUser(cmd.Context())
8585
if err != nil {
86-
return xerrors.Errorf("has initial user: %w", err)
86+
return xerrors.Errorf("Failed to check server %q for first user, is the URL correct and is coder accessible from your browser? Error - has initial user: %w", serverURL.String(), err)
8787
}
8888
if !hasInitialUser {
8989
_, _ = fmt.Fprintf(cmd.OutOrStdout(), caret+"Your Coder deployment hasn't been set up!\n")

cli/login_test.go

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cli_test
22

33
import (
44
"context"
5+
"fmt"
56
"testing"
67

78
"github.com/stretchr/testify/assert"
@@ -23,6 +24,15 @@ func TestLogin(t *testing.T) {
2324
require.Error(t, err)
2425
})
2526

27+
t.Run("InitialUserBadLoginURL", func(t *testing.T) {
28+
t.Parallel()
29+
badLoginURL := "https://fcca2077f06e68aaf9"
30+
root, _ := clitest.New(t, "login", badLoginURL)
31+
err := root.Execute()
32+
errMsg := fmt.Sprintf("Failed to check server %q for first user, is the URL correct and is coder accessible from your browser?", badLoginURL)
33+
require.ErrorContains(t, err, errMsg)
34+
})
35+
2636
t.Run("InitialUserTTY", func(t *testing.T) {
2737
t.Parallel()
2838
client := coderdtest.New(t, nil)

cli/logout.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
func logout() *cobra.Command {
1515
cmd := &cobra.Command{
1616
Use: "logout",
17-
Short: "Remove the local authenticated session",
17+
Short: "Unauthenticate your local session",
1818
RunE: func(cmd *cobra.Command, args []string) error {
1919
client, err := CreateClient(cmd)
2020
if err != nil {

0 commit comments

Comments
 (0)