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

Commit dd00acd

Browse files
authored
Add satellite commands (#387)
* Add satellite commands * lint and docs * docs * better yes check * better domain * more docs * add not found error * fix types
1 parent 0b4b4fa commit dd00acd

9 files changed

+417
-0
lines changed

coder-sdk/interface.go

+9
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,13 @@ type Client interface {
241241

242242
// SetPolicyTemplate sets the workspace policy template
243243
SetPolicyTemplate(ctx context.Context, templateID string, templateScope TemplateScope, dryRun bool) (*SetPolicyTemplateResponse, error)
244+
245+
// satellites fetches all satellitess known to the Coder control plane.
246+
Satellites(ctx context.Context) ([]Satellite, error)
247+
248+
// CreateSatellite creates a new satellite entity.
249+
CreateSatellite(ctx context.Context, req CreateSatelliteReq) (*Satellite, error)
250+
251+
// DeleteSatelliteByID deletes a satellite entity from the Coder control plane.
252+
DeleteSatelliteByID(ctx context.Context, id string) error
244253
}

coder-sdk/satellite.go

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package coder
2+
3+
import (
4+
"context"
5+
"net/http"
6+
)
7+
8+
type Satellite struct {
9+
ID string `json:"id"`
10+
Name string `json:"name"`
11+
Fingerprint string `json:"fingerprint"`
12+
}
13+
14+
type satellites struct {
15+
Data []Satellite `json:"data"`
16+
}
17+
18+
type createSatelliteResponse struct {
19+
Data Satellite `json:"data"`
20+
}
21+
22+
// Satellites fetches all satellitess known to the Coder control plane.
23+
func (c *DefaultClient) Satellites(ctx context.Context) ([]Satellite, error) {
24+
var res satellites
25+
err := c.requestBody(ctx, http.MethodGet, "/api/private/satellites", nil, &res)
26+
if err != nil {
27+
return nil, err
28+
}
29+
return res.Data, nil
30+
}
31+
32+
// CreateSatelliteReq defines the request parameters for creating a new satellite entity.
33+
type CreateSatelliteReq struct {
34+
Name string `json:"name"`
35+
PublicKey string `json:"public_key"`
36+
}
37+
38+
// CreateSatellite creates a new satellite entity.
39+
func (c *DefaultClient) CreateSatellite(ctx context.Context, req CreateSatelliteReq) (*Satellite, error) {
40+
var res createSatelliteResponse
41+
err := c.requestBody(ctx, http.MethodPost, "/api/private/satellites", req, &res)
42+
if err != nil {
43+
return nil, err
44+
}
45+
return &res.Data, nil
46+
}
47+
48+
// DeleteSatelliteByID deletes a satellite entity from the Coder control plane.
49+
func (c *DefaultClient) DeleteSatelliteByID(ctx context.Context, id string) error {
50+
return c.requestBody(ctx, http.MethodDelete, "/api/private/satellites/"+id, nil, nil)
51+
}

docs/coder.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ coder provides a CLI for working with an existing Coder installation
1616
* [coder images](coder_images.md) - Manage Coder images
1717
* [coder login](coder_login.md) - Authenticate this client for future operations
1818
* [coder logout](coder_logout.md) - Remove local authentication credentials if any exist
19+
* [coder satellites](coder_satellites.md) - Interact with Coder satellite deployments
1920
* [coder ssh](coder_ssh.md) - Enter a shell of execute a command over SSH into a Coder workspace
2021
* [coder sync](coder_sync.md) - Establish a one way directory sync to a Coder workspace
2122
* [coder tokens](coder_tokens.md) - manage Coder API tokens for the active user

docs/coder_satellites.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## coder satellites
2+
3+
Interact with Coder satellite deployments
4+
5+
### Synopsis
6+
7+
Perform operations on the Coder satellites for the platform.
8+
9+
### Options
10+
11+
```
12+
-h, --help help for satellites
13+
```
14+
15+
### Options inherited from parent commands
16+
17+
```
18+
-v, --verbose show verbose output
19+
```
20+
21+
### SEE ALSO
22+
23+
* [coder](coder.md) - coder provides a CLI for working with an existing Coder installation
24+
* [coder satellites create](coder_satellites_create.md) - create a new satellite.
25+
* [coder satellites ls](coder_satellites_ls.md) - list satellites.
26+
* [coder satellites rm](coder_satellites_rm.md) - remove a satellite.
27+

docs/coder_satellites_create.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## coder satellites create
2+
3+
create a new satellite.
4+
5+
### Synopsis
6+
7+
Create a new Coder satellite.
8+
9+
```
10+
coder satellites create [name] [satellite_access_url] [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
# create a new satellite
17+
18+
coder satellites create eu-west https://eu-west.coder.com
19+
```
20+
21+
### Options
22+
23+
```
24+
-h, --help help for create
25+
```
26+
27+
### Options inherited from parent commands
28+
29+
```
30+
-v, --verbose show verbose output
31+
```
32+
33+
### SEE ALSO
34+
35+
* [coder satellites](coder_satellites.md) - Interact with Coder satellite deployments
36+

docs/coder_satellites_ls.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## coder satellites ls
2+
3+
list satellites.
4+
5+
### Synopsis
6+
7+
List all Coder workspace satellites.
8+
9+
```
10+
coder satellites ls [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
# list satellites
17+
coder satellites ls
18+
```
19+
20+
### Options
21+
22+
```
23+
-h, --help help for ls
24+
```
25+
26+
### Options inherited from parent commands
27+
28+
```
29+
-v, --verbose show verbose output
30+
```
31+
32+
### SEE ALSO
33+
34+
* [coder satellites](coder_satellites.md) - Interact with Coder satellite deployments
35+

docs/coder_satellites_rm.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## coder satellites rm
2+
3+
remove a satellite.
4+
5+
### Synopsis
6+
7+
Remove an existing Coder satellite by name.
8+
9+
```
10+
coder satellites rm [satellite_name] [flags]
11+
```
12+
13+
### Examples
14+
15+
```
16+
# remove an existing satellite by name
17+
coder satellites rm my-satellite
18+
```
19+
20+
### Options
21+
22+
```
23+
-h, --help help for rm
24+
```
25+
26+
### Options inherited from parent commands
27+
28+
```
29+
-v, --verbose show verbose output
30+
```
31+
32+
### SEE ALSO
33+
34+
* [coder satellites](coder_satellites.md) - Interact with Coder satellite deployments
35+

internal/cmd/cmd.go

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func Make() *cobra.Command {
4040
genDocsCmd(app),
4141
agentCmd(),
4242
tunnelCmd(),
43+
satellitesCmd(),
4344
)
4445
app.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "show verbose output")
4546
return app

0 commit comments

Comments
 (0)