Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v1
- uses: actions/setup-go@v2
with:
go-version: '^1.16.3'
- name: Build
run: make -j build/linux build/windows
- name: Upload
Expand All @@ -19,6 +22,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v1
- uses: actions/setup-go@v2
with:
go-version: '^1.16.3'
- name: Install Gon
run: |
brew tap mitchellh/gon
Expand Down
2 changes: 1 addition & 1 deletion ci/image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1
FROM golang:1.16.3

ENV GOFLAGS="-mod=readonly"
ENV CI=true
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ coder agent start --coder-url https://my-coder.com --token xxxx-xxxx
var ok bool
coderURL, ok = os.LookupEnv("CODER_URL")
if !ok {
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return xerrors.New("must login, pass --coder-url flag, or set the CODER_URL env variable")
}
Expand Down
12 changes: 8 additions & 4 deletions internal/cmd/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var errNeedLogin = clog.Fatal(
const tokenEnv = "CODER_TOKEN"
const urlEnv = "CODER_URL"

func newClient(ctx context.Context) (coder.Client, error) {
func newClient(ctx context.Context, checkVersion bool) (coder.Client, error) {
var (
err error
sessionToken = os.Getenv(tokenEnv)
Expand Down Expand Up @@ -55,10 +55,14 @@ func newClient(ctx context.Context) (coder.Client, error) {
return nil, xerrors.Errorf("failed to create new coder.Client: %w", err)
}

apiVersion, err := c.APIVersion(ctx)
if apiVersion != "" && !version.VersionsMatch(apiVersion) {
logVersionMismatchError(apiVersion)
if checkVersion {
var apiVersion string
apiVersion, err = c.APIVersion(ctx)
if apiVersion != "" && !version.VersionsMatch(apiVersion) {
logVersionMismatchError(apiVersion)
}
}

if err != nil {
var he *coder.HTTPError
if xerrors.As(err, &he) {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/configssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func configSSH(configpath *string, remove *bool, p2p *bool) func(cmd *cobra.Comm
return nil
}

client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down
12 changes: 6 additions & 6 deletions internal/cmd/envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func lsEnvsCommand() *cobra.Command {
Long: "List all Coder environments owned by the active user.",
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -128,7 +128,7 @@ coder envs --user charlie@coder.com ls -o json \
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return xerrors.Errorf("new client: %w", err)
}
Expand Down Expand Up @@ -189,7 +189,7 @@ coder envs create my-new-powerful-env --cpu 12 --disk 100 --memory 16 --image ub
return xerrors.New("image unset")
}

client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -315,7 +315,7 @@ coder envs create-from-config --name="dev-env" -f coder.yaml`,
)
}

client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -438,7 +438,7 @@ func editEnvCmd() *cobra.Command {
coder envs edit back-end-env --disk 20`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -532,7 +532,7 @@ func rmEnvsCmd() *cobra.Command {
Args: cobra.MinimumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func lsImgsCommand(user *string) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()

client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down
12 changes: 6 additions & 6 deletions internal/cmd/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ coder providers create my-provider --hostname=https://provider.example.com --clu
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()

client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -143,7 +143,7 @@ coder providers ls`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()

client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -174,7 +174,7 @@ func deleteProviderCmd() *cobra.Command {
coder providers rm my-workspace-provider`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -232,7 +232,7 @@ func cordonProviderCmd() *cobra.Command {
coder providers cordon my-workspace-provider --reason "limit cloud clost"`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -265,7 +265,7 @@ func unCordonProviderCmd() *cobra.Command {
coder providers uncordon my-workspace-provider`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -296,7 +296,7 @@ func renameProviderCmd() *cobra.Command {
coder providers rename build-in us-east-1`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/rebuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func rebuildEnvCommand() *cobra.Command {
coder envs rebuild backend-env --force`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -166,7 +166,7 @@ func watchBuildLogCommand() *cobra.Command {
Args: xcobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/resourcemanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ coder resources top --sort-by memory --show-empty`,
func runResourceTop(options *resourceTopOptions) func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ coder ssh my-dev pwd`,

func shell(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -99,7 +99,7 @@ func shValidArgs(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
err := cobra.MinimumNArgs(1)(cmd, args)
if err != nil {
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return clog.Error("missing [environment_name] argument")
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func makeRunSync(init *bool) func(cmd *cobra.Command, args []string) error {
remote = args[1]
)

client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func tagsCreateCmd() *cobra.Command {
Args: xcobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -86,7 +86,7 @@ func tagsLsCmd() *cobra.Command {
Example: `coder tags ls --image ubuntu --org default --output json`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -143,7 +143,7 @@ func tagsRmCmd() *cobra.Command {
Args: xcobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func lsTokensCmd() *cobra.Command {
Short: "show the user's active API tokens",
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -79,7 +79,7 @@ func createTokensCmd() *cobra.Command {
Args: xcobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand All @@ -102,7 +102,7 @@ func rmTokenCmd() *cobra.Command {
Args: xcobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand All @@ -121,7 +121,7 @@ func regenTokenCmd() *cobra.Command {
Args: xcobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ coder tunnel my-dev 3000 3000
}
}

sdk, err := newClient(ctx)
sdk, err := newClient(ctx, false)
if err != nil {
return xerrors.Errorf("getting coder client: %w", err)
}
Expand All @@ -72,7 +72,7 @@ coder tunnel my-dev 3000 3000
}

c := &tunnneler{
log: log.Leveled(slog.LevelDebug),
log: log,
brokerAddr: &baseURL,
token: sdk.Token(),
workspaceID: envID,
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/urls.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func accessLevelIsValid(level string) bool {
func listDevURLsCmd(outputFmt *string) func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -147,7 +147,7 @@ func createDevURLCmd() *cobra.Command {
if urlname != "" && !devURLNameValidRx.MatchString(urlname) {
return xerrors.New("update devurl: name must be < 64 chars in length, begin with a letter and only contain letters or digits.")
}
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down Expand Up @@ -230,7 +230,7 @@ func removeDevURL(cmd *cobra.Command, args []string) error {
return xerrors.Errorf("validate port: %w", err)
}

client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ coder users ls -o json | jq .[] | jq -r .email`,
func listUsers(outputFmt *string) func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
client, err := newClient(ctx)
client, err := newClient(ctx, true)
if err != nil {
return err
}
Expand Down
9 changes: 7 additions & 2 deletions wsnet/listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"cdr.dev/coder-cli/coder-sdk"
)

var keepAliveInterval = 5 * time.Second

// Listen connects to the broker proxies connections to the local net.
// Close will end all RTC connections.
func Listen(ctx context.Context, broker string) (io.Closer, error) {
Expand All @@ -35,7 +37,7 @@ func Listen(ctx context.Context, broker string) (io.Closer, error) {
go func() {
for {
err := <-ch
if errors.Is(err, io.EOF) {
if errors.Is(err, io.EOF) || errors.Is(err, yamux.ErrKeepAliveTimeout) {
// If we hit an EOF, then the connection to the broker
// was interrupted. We'll take a short break then dial
// again.
Expand Down Expand Up @@ -76,7 +78,10 @@ func (l *listener) dial(ctx context.Context) (<-chan error, error) {
}
l.ws = conn
nconn := websocket.NetConn(ctx, conn, websocket.MessageBinary)
session, err := yamux.Server(nconn, nil)
config := yamux.DefaultConfig()
config.KeepAliveInterval = keepAliveInterval
config.LogOutput = io.Discard
session, err := yamux.Server(nconn, config)
if err != nil {
return nil, fmt.Errorf("create multiplex: %w", err)
}
Expand Down
Loading