Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 59a0a20

Browse files
authored
feat: Add update command to coder-cli (#417)
* feat: Add update command to coder-cli This commit adds a new update subcommand that queries a Coder instance for its current version, fetches the corresponding version from GitHub releases if required, and updates the binary in-place.
1 parent 4117dc8 commit 59a0a20

File tree

8 files changed

+1074
-1
lines changed

8 files changed

+1074
-1
lines changed

docs/coder.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ coder provides a CLI for working with an existing Coder installation
2020
* [coder ssh](coder_ssh.md) - Enter a shell of execute a command over SSH into a Coder workspace
2121
* [coder sync](coder_sync.md) - Establish a one way directory sync to a Coder workspace
2222
* [coder tokens](coder_tokens.md) - manage Coder API tokens for the active user
23+
* [coder update](coder_update.md) - Update coder binary
2324
* [coder urls](coder_urls.md) - Interact with workspace DevURLs
2425
* [coder users](coder_users.md) - Interact with Coder user accounts
2526
* [coder workspaces](coder_workspaces.md) - Interact with Coder workspaces

docs/coder_update.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## coder update
2+
3+
Update coder binary
4+
5+
### Synopsis
6+
7+
Update coder to the version matching a given coder instance.
8+
9+
```
10+
coder update [flags]
11+
```
12+
13+
### Options
14+
15+
```
16+
--coder string query this coder instance for the matching version
17+
--force do not prompt for confirmation
18+
-h, --help help for update
19+
--version string explicitly specify which version to fetch and install
20+
```
21+
22+
### Options inherited from parent commands
23+
24+
```
25+
-v, --verbose show verbose output
26+
```
27+
28+
### SEE ALSO
29+
30+
* [coder](coder.md) - coder provides a CLI for working with an existing Coder installation
31+

go.mod

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.14
55
require (
66
cdr.dev/slog v1.4.1
77
cdr.dev/wsep v0.0.0-20200728013649-82316a09813f
8+
github.com/Masterminds/semver/v3 v3.1.1
89
github.com/briandowns/spinner v1.16.0
910
github.com/cli/safeexec v1.0.0
1011
github.com/fatih/color v1.12.0
@@ -23,6 +24,7 @@ require (
2324
github.com/pion/webrtc/v3 v3.0.32
2425
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4
2526
github.com/rjeczalik/notify v0.9.2
27+
github.com/spf13/afero v1.6.0
2628
github.com/spf13/cobra v1.2.1
2729
github.com/stretchr/testify v1.7.0
2830
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97

go.sum

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
4949
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
5050
github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0=
5151
github.com/GeertJohan/go.rice v1.0.0/go.mod h1:eH6gbSOAUv07dQuZVnBmoDP8mgsM1rtixis4Tib9if0=
52+
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
53+
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
5254
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
5355
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
5456
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
@@ -378,6 +380,7 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5I
378380
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
379381
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
380382
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
383+
github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY=
381384
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
382385
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
383386
github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw=

internal/cmd/cmd.go

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func Make() *cobra.Command {
3838
tagsCmd(),
3939
tokensCmd(),
4040
tunnelCmd(),
41+
updateCmd(),
4142
urlCmd(),
4243
usersCmd(),
4344
workspacesCmd(),

0 commit comments

Comments
 (0)