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

Add satellite commands #387

Merged
merged 8 commits into from
Jul 16, 2021
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
9 changes: 9 additions & 0 deletions coder-sdk/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,13 @@ type Client interface {

// SetPolicyTemplate sets the workspace policy template
SetPolicyTemplate(ctx context.Context, templateID string, templateScope TemplateScope, dryRun bool) (*SetPolicyTemplateResponse, error)

// satellites fetches all satellitess known to the Coder control plane.
Satellites(ctx context.Context) ([]Satellite, error)

// CreateSatellite creates a new satellite entity.
CreateSatellite(ctx context.Context, req CreateSatelliteReq) (*Satellite, error)

// DeleteSatelliteByID deletes a satellite entity from the Coder control plane.
DeleteSatelliteByID(ctx context.Context, id string) error
}
51 changes: 51 additions & 0 deletions coder-sdk/satellite.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package coder

import (
"context"
"net/http"
)

type Satellite struct {
ID string `json:"id"`
Name string `json:"name"`
Fingerprint string `json:"fingerprint"`
}

type satellites struct {
Data []Satellite `json:"data"`
}

type createSatelliteResponse struct {
Data Satellite `json:"data"`
}

// Satellites fetches all satellitess known to the Coder control plane.
func (c *DefaultClient) Satellites(ctx context.Context) ([]Satellite, error) {
var res satellites
err := c.requestBody(ctx, http.MethodGet, "/api/private/satellites", nil, &res)
if err != nil {
return nil, err
}
return res.Data, nil
}

// CreateSatelliteReq defines the request parameters for creating a new satellite entity.
type CreateSatelliteReq struct {
Name string `json:"name"`
PublicKey string `json:"public_key"`
}

// CreateSatellite creates a new satellite entity.
func (c *DefaultClient) CreateSatellite(ctx context.Context, req CreateSatelliteReq) (*Satellite, error) {
var res createSatelliteResponse
err := c.requestBody(ctx, http.MethodPost, "/api/private/satellites", req, &res)
if err != nil {
return nil, err
}
return &res.Data, nil
}

// DeleteSatelliteByID deletes a satellite entity from the Coder control plane.
func (c *DefaultClient) DeleteSatelliteByID(ctx context.Context, id string) error {
return c.requestBody(ctx, http.MethodDelete, "/api/private/satellites/"+id, nil, nil)
}
1 change: 1 addition & 0 deletions docs/coder.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ coder provides a CLI for working with an existing Coder installation
* [coder images](coder_images.md) - Manage Coder images
* [coder login](coder_login.md) - Authenticate this client for future operations
* [coder logout](coder_logout.md) - Remove local authentication credentials if any exist
* [coder satellites](coder_satellites.md) - Interact with Coder satellite deployments
* [coder ssh](coder_ssh.md) - Enter a shell of execute a command over SSH into a Coder workspace
* [coder sync](coder_sync.md) - Establish a one way directory sync to a Coder workspace
* [coder tokens](coder_tokens.md) - manage Coder API tokens for the active user
Expand Down
27 changes: 27 additions & 0 deletions docs/coder_satellites.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## coder satellites

Interact with Coder satellite deployments

### Synopsis

Perform operations on the Coder satellites for the platform.

### Options

```
-h, --help help for satellites
```

### Options inherited from parent commands

```
-v, --verbose show verbose output
```

### SEE ALSO

* [coder](coder.md) - coder provides a CLI for working with an existing Coder installation
* [coder satellites create](coder_satellites_create.md) - create a new satellite.
* [coder satellites ls](coder_satellites_ls.md) - list satellites.
* [coder satellites rm](coder_satellites_rm.md) - remove a satellite.

36 changes: 36 additions & 0 deletions docs/coder_satellites_create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## coder satellites create

create a new satellite.

### Synopsis

Create a new Coder satellite.

```
coder satellites create [name] [satellite_access_url] [flags]
```

### Examples

```
# create a new satellite

coder satellites create eu-west https://eu-west.coder.com
```

### Options

```
-h, --help help for create
```

### Options inherited from parent commands

```
-v, --verbose show verbose output
```

### SEE ALSO

* [coder satellites](coder_satellites.md) - Interact with Coder satellite deployments

35 changes: 35 additions & 0 deletions docs/coder_satellites_ls.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## coder satellites ls

list satellites.

### Synopsis

List all Coder workspace satellites.

```
coder satellites ls [flags]
```

### Examples

```
# list satellites
coder satellites ls
```

### Options

```
-h, --help help for ls
```

### Options inherited from parent commands

```
-v, --verbose show verbose output
```

### SEE ALSO

* [coder satellites](coder_satellites.md) - Interact with Coder satellite deployments

35 changes: 35 additions & 0 deletions docs/coder_satellites_rm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## coder satellites rm

remove a satellite.

### Synopsis

Remove an existing Coder satellite by name.

```
coder satellites rm [satellite_name] [flags]
```

### Examples

```
# remove an existing satellite by name
coder satellites rm my-satellite
```

### Options

```
-h, --help help for rm
```

### Options inherited from parent commands

```
-v, --verbose show verbose output
```

### SEE ALSO

* [coder satellites](coder_satellites.md) - Interact with Coder satellite deployments

1 change: 1 addition & 0 deletions internal/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func Make() *cobra.Command {
genDocsCmd(app),
agentCmd(),
tunnelCmd(),
satellitesCmd(),
)
app.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "show verbose output")
return app
Expand Down
Loading