Skip to content

Commit c73cf94

Browse files
committed
Merge branch 'main' into workspace-story/presleyp/1675
2 parents abe0eb3 + 98c89f8 commit c73cf94

22 files changed

+302
-124
lines changed

.github/workflows/coder.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,15 @@ jobs:
361361

362362
- uses: actions/upload-artifact@v3
363363
with:
364-
name: coder_linux_amd64.deb
365-
path: ./dist/coder_*_linux_amd64.deb
364+
name: coder_windows_amd64.zip
365+
path: ./dist/coder_*_windows_amd64.zip
366+
retention-days: 7
367+
368+
- uses: actions/upload-artifact@v3
369+
with:
370+
name: coder_linux_amd64.tar.gz
371+
path: ./dist/coder_*_linux_amd64.tar.gz
372+
retention-days: 7
366373

367374
- name: Install Release
368375
run: |

README.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ You can set up a temporary deployment, a production deployment, or a system serv
5959
> Use `coder --help` to get a complete list of flags and environment
6060
> variables.
6161
62+
See the [installation guide](install.md) for additional ways to deploy Coder.
63+
6264
## Creating your first template and workspace
6365

6466
In a new terminal window, run the following to copy a sample template:
@@ -118,13 +120,4 @@ Read the [contributing docs](./docs/CONTRIBUTING.md).
118120

119121
## Contributors
120122

121-
<!--- Add your row by date (mm/dd/yyyy), most recent date at end of list --->
122-
123-
| Name | Start Date | First PR Date | Organization | GitHub User Link |
124-
| ------------------- | :--------: | :-----------: | :-------------------------------: | --------------------------------------------: |
125-
| Grey Barkans | 01/13/2020 | 03/13/2022 | [Coder](https://github.com/coder) | [vapurrmaid](https://github.com/vapurrmaid) |
126-
| Ben Potter | 08/10/2020 | 03/31/2022 | [Coder](https://github.com/coder) | [bpmct](https://github.com/bpmct) |
127-
| Mathias Fredriksson | 04/25/2022 | 04/25/2022 | [Coder](https://github.com/coder) | [mafredri](https://github.com/mafredri) |
128-
| Spike Curtis | 05/02/2022 | 05/06/2022 | [Coder](https://github.com/coder) | [spikecurtis](https://github.com/spikecurtis) |
129-
| Kira Pilot | 05/09/2022 | 05/09/2022 | [Coder](https://github.com/coder) | [Kira-Pilot](https://github.com/Kira-Pilot) |
130-
| David Wahler | 05/09/2022 | 04/05/2022 | [Coder](https://github.com/coder) | [dwahler](https://github.com/dwahler) |
123+
Find our list of contributors [here](./CONTRIBUTORS.md).

cli/agent_test.go

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,12 @@ func TestWorkspaceAgent(t *testing.T) {
4949
cmd, _ := clitest.New(t, "agent", "--auth", "azure-instance-identity", "--agent-url", client.URL.String())
5050
ctx, cancelFunc := context.WithCancel(context.Background())
5151
defer cancelFunc()
52+
errC := make(chan error)
5253
go func() {
53-
// A linting error occurs for weakly typing the context value here,
54-
// but it seems reasonable for a one-off test.
55-
// nolint
56-
ctx = context.WithValue(ctx, "azure-client", metadataClient)
57-
err := cmd.ExecuteContext(ctx)
58-
require.NoError(t, err)
54+
// A linting error occurs for weakly typing the context value here.
55+
//nolint // The above seems reasonable for a one-off test.
56+
ctx := context.WithValue(ctx, "azure-client", metadataClient)
57+
errC <- cmd.ExecuteContext(ctx)
5958
}()
6059
coderdtest.AwaitWorkspaceAgents(t, client, workspace.LatestBuild.ID)
6160
resources, err := client.WorkspaceResourcesByBuild(ctx, workspace.LatestBuild.ID)
@@ -66,6 +65,8 @@ func TestWorkspaceAgent(t *testing.T) {
6665
_, err = dialer.Ping()
6766
require.NoError(t, err)
6867
cancelFunc()
68+
err = <-errC
69+
require.NoError(t, err)
6970
})
7071

7172
t.Run("AWS", func(t *testing.T) {
@@ -103,13 +104,12 @@ func TestWorkspaceAgent(t *testing.T) {
103104
cmd, _ := clitest.New(t, "agent", "--auth", "aws-instance-identity", "--agent-url", client.URL.String())
104105
ctx, cancelFunc := context.WithCancel(context.Background())
105106
defer cancelFunc()
107+
errC := make(chan error)
106108
go func() {
107-
// A linting error occurs for weakly typing the context value here,
108-
// but it seems reasonable for a one-off test.
109-
// nolint
110-
ctx = context.WithValue(ctx, "aws-client", metadataClient)
111-
err := cmd.ExecuteContext(ctx)
112-
require.NoError(t, err)
109+
// A linting error occurs for weakly typing the context value here.
110+
//nolint // The above seems reasonable for a one-off test.
111+
ctx := context.WithValue(ctx, "aws-client", metadataClient)
112+
errC <- cmd.ExecuteContext(ctx)
113113
}()
114114
coderdtest.AwaitWorkspaceAgents(t, client, workspace.LatestBuild.ID)
115115
resources, err := client.WorkspaceResourcesByBuild(ctx, workspace.LatestBuild.ID)
@@ -120,6 +120,8 @@ func TestWorkspaceAgent(t *testing.T) {
120120
_, err = dialer.Ping()
121121
require.NoError(t, err)
122122
cancelFunc()
123+
err = <-errC
124+
require.NoError(t, err)
123125
})
124126

125127
t.Run("GoogleCloud", func(t *testing.T) {
@@ -157,13 +159,12 @@ func TestWorkspaceAgent(t *testing.T) {
157159
cmd, _ := clitest.New(t, "agent", "--auth", "google-instance-identity", "--agent-url", client.URL.String())
158160
ctx, cancelFunc := context.WithCancel(context.Background())
159161
defer cancelFunc()
162+
errC := make(chan error)
160163
go func() {
161-
// A linting error occurs for weakly typing the context value here,
162-
// but it seems reasonable for a one-off test.
163-
// nolint
164-
ctx = context.WithValue(ctx, "gcp-client", metadata)
165-
err := cmd.ExecuteContext(ctx)
166-
require.NoError(t, err)
164+
// A linting error occurs for weakly typing the context value here.
165+
//nolint // The above seems reasonable for a one-off test.
166+
ctx := context.WithValue(ctx, "gcp-client", metadata)
167+
errC <- cmd.ExecuteContext(ctx)
167168
}()
168169
coderdtest.AwaitWorkspaceAgents(t, client, workspace.LatestBuild.ID)
169170
resources, err := client.WorkspaceResourcesByBuild(ctx, workspace.LatestBuild.ID)
@@ -174,5 +175,7 @@ func TestWorkspaceAgent(t *testing.T) {
174175
_, err = dialer.Ping()
175176
require.NoError(t, err)
176177
cancelFunc()
178+
err = <-errC
179+
require.NoError(t, err)
177180
})
178181
}

cli/clitest/clitest_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package clitest_test
33
import (
44
"testing"
55

6-
"github.com/stretchr/testify/require"
76
"go.uber.org/goleak"
87

98
"github.com/coder/coder/cli/clitest"
@@ -25,8 +24,7 @@ func TestCli(t *testing.T) {
2524
cmd.SetIn(pty.Input())
2625
cmd.SetOut(pty.Output())
2726
go func() {
28-
err := cmd.Execute()
29-
require.NoError(t, err)
27+
_ = cmd.Execute()
3028
}()
3129
pty.ExpectMatch("coder")
3230
}

cli/gitssh_test.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ func TestGitSSH(t *testing.T) {
6363
clitest.SetupConfig(t, agentClient, root)
6464
ctx, cancelFunc := context.WithCancel(context.Background())
6565
defer cancelFunc()
66+
agentErrC := make(chan error)
6667
go func() {
67-
err := cmd.ExecuteContext(ctx)
68-
require.NoError(t, err)
68+
agentErrC <- cmd.ExecuteContext(ctx)
6969
}()
7070

7171
coderdtest.AwaitWorkspaceAgents(t, client, workspace.LatestBuild.ID)
@@ -85,23 +85,30 @@ func TestGitSSH(t *testing.T) {
8585
return ssh.KeysEqual(publicKey, key)
8686
})
8787
var inc int64
88+
sshErrC := make(chan error)
8889
go func() {
8990
// as long as we get a successful session we don't care if the server errors
9091
_ = ssh.Serve(l, func(s ssh.Session) {
9192
atomic.AddInt64(&inc, 1)
9293
t.Log("got authenticated session")
93-
err := s.Exit(0)
94-
require.NoError(t, err)
94+
sshErrC <- s.Exit(0)
9595
}, publicKeyOption)
9696
}()
9797

9898
// start ssh session
9999
addr, ok := l.Addr().(*net.TCPAddr)
100100
require.True(t, ok)
101101
// set to agent config dir
102-
cmd, _ = clitest.New(t, "gitssh", "--agent-url", agentClient.URL.String(), "--agent-token", agentToken, "--", fmt.Sprintf("-p%d", addr.Port), "-o", "StrictHostKeyChecking=no", "127.0.0.1")
103-
err = cmd.ExecuteContext(context.Background())
102+
gitsshCmd, _ := clitest.New(t, "gitssh", "--agent-url", agentClient.URL.String(), "--agent-token", agentToken, "--", fmt.Sprintf("-p%d", addr.Port), "-o", "StrictHostKeyChecking=no", "-o", "IdentitiesOnly=yes", "127.0.0.1")
103+
err = gitsshCmd.ExecuteContext(context.Background())
104104
require.NoError(t, err)
105105
require.EqualValues(t, 1, inc)
106+
107+
err = <-sshErrC
108+
require.NoError(t, err, "error in ssh session exit")
109+
110+
cancelFunc()
111+
err = <-agentErrC
112+
require.NoError(t, err, "error in agent execute")
106113
})
107114
}

cli/list_test.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package cli_test
22

33
import (
4+
"context"
45
"testing"
6+
"time"
57

68
"github.com/stretchr/testify/require"
79

@@ -14,6 +16,8 @@ func TestList(t *testing.T) {
1416
t.Parallel()
1517
t.Run("Single", func(t *testing.T) {
1618
t.Parallel()
19+
ctx, cancelFunc := context.WithTimeout(context.Background(), 5*time.Second)
20+
defer cancelFunc()
1721
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerD: true})
1822
user := coderdtest.CreateFirstUser(t, client)
1923
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
@@ -23,17 +27,16 @@ func TestList(t *testing.T) {
2327
coderdtest.AwaitWorkspaceBuildJob(t, client, workspace.LatestBuild.ID)
2428
cmd, root := clitest.New(t, "ls")
2529
clitest.SetupConfig(t, client, root)
26-
doneChan := make(chan struct{})
2730
pty := ptytest.New(t)
2831
cmd.SetIn(pty.Input())
2932
cmd.SetOut(pty.Output())
33+
errC := make(chan error)
3034
go func() {
31-
defer close(doneChan)
32-
err := cmd.Execute()
33-
require.NoError(t, err)
35+
errC <- cmd.ExecuteContext(ctx)
3436
}()
3537
pty.ExpectMatch(workspace.Name)
3638
pty.ExpectMatch("Running")
37-
<-doneChan
39+
cancelFunc()
40+
require.NoError(t, <-errC)
3841
})
3942
}

cli/root.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import (
44
"fmt"
55
"net/url"
66
"os"
7+
"strings"
78
"time"
89

10+
"golang.org/x/xerrors"
11+
912
"github.com/kirsle/configdir"
1013
"github.com/mattn/go-isatty"
1114
"github.com/spf13/cobra"
@@ -112,22 +115,30 @@ func createClient(cmd *cobra.Command) (*codersdk.Client, error) {
112115
if err != nil || rawURL == "" {
113116
rawURL, err = root.URL().Read()
114117
if err != nil {
118+
// If the configuration files are absent, the user is logged out
119+
if os.IsNotExist(err) {
120+
return nil, xerrors.New("You are not logged in. Try logging in using 'coder login <url>'.")
121+
}
115122
return nil, err
116123
}
117124
}
118-
serverURL, err := url.Parse(rawURL)
125+
serverURL, err := url.Parse(strings.TrimSpace(rawURL))
119126
if err != nil {
120127
return nil, err
121128
}
122129
token, err := cmd.Flags().GetString(varToken)
123130
if err != nil || token == "" {
124131
token, err = root.Session().Read()
125132
if err != nil {
133+
// If the configuration files are absent, the user is logged out
134+
if os.IsNotExist(err) {
135+
return nil, xerrors.New("You are not logged in. Try logging in using 'coder login <url>'.")
136+
}
126137
return nil, err
127138
}
128139
}
129140
client := codersdk.New(serverURL)
130-
client.SessionToken = token
141+
client.SessionToken = strings.TrimSpace(token)
131142
return client, nil
132143
}
133144

0 commit comments

Comments
 (0)