This repository was archived by the owner on Aug 30, 2024. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork18
feat: add coder-sdk methods for multi-cluster#215
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
3 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
1 change: 1 addition & 0 deletionscoder-sdk/env.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletionscoder-sdk/resourcepools.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package coder | ||
import ( | ||
"context" | ||
"net/http" | ||
) | ||
// ResourcePool defines an entity capable of deploying and acting as an ingress for Coder environments. | ||
type ResourcePool struct { | ||
ID string `json:"id"` | ||
Name string `json:"name"` | ||
Local bool `json:"local"` | ||
ClusterAddress string `json:"cluster_address"` | ||
DefaultNamespace string `json:"default_namespace"` | ||
StorageClass string `json:"storage_class"` | ||
ClusterDomainSuffix string `json:"cluster_domain_suffix"` | ||
DevurlHost string `json:"devurl_host"` | ||
NamespaceWhitelist []string `json:"namespace_whitelist"` | ||
OrgWhitelist []string `json:"org_whitelist"` | ||
} | ||
// ResourcePoolByID fetches a resource pool entity by its unique ID. | ||
func (c *Client) ResourcePoolByID(ctx context.Context, id string) (*ResourcePool, error) { | ||
var rp ResourcePool | ||
if err := c.requestBody(ctx, http.MethodGet, "/api/private/resource-pools/"+id, nil, &rp); err != nil { | ||
return nil, err | ||
} | ||
return &rp, nil | ||
} | ||
// DeleteResourcePoolByID deletes a resource pool entity from the Coder control plane. | ||
func (c *Client) DeleteResourcePoolByID(ctx context.Context, id string) error { | ||
return c.requestBody(ctx, http.MethodDelete, "/api/private/resource-pools/"+id, nil, nil) | ||
} | ||
// ResourcePools fetches all resource pools known to the Coder control plane. | ||
func (c *Client) ResourcePools(ctx context.Context) ([]ResourcePool, error) { | ||
var pools []ResourcePool | ||
if err := c.requestBody(ctx, http.MethodGet, "/api/private/resource-pools", nil, &pools); err != nil { | ||
return nil, err | ||
} | ||
return pools, nil | ||
} | ||
// CreateResourcePoolReq defines the request parameters for creating a new resource pool entity. | ||
type CreateResourcePoolReq struct { | ||
Name string `json:"name"` | ||
Local bool `json:"local"` | ||
ClusterCA string `json:"cluster_ca"` | ||
ClusterAddress string `json:"cluster_address"` | ||
SAToken string `json:"sa_token"` | ||
DefaultNamespace string `json:"default_namespace"` | ||
StorageClass string `json:"storage_class"` | ||
ClusterDomainSuffix string `json:"cluster_domain_suffix"` | ||
DevurlHost string `json:"devurl_host"` | ||
NamespaceWhitelist []string `json:"namespace_whitelist"` | ||
OrgWhitelist []string `json:"org_whitelist"` | ||
} | ||
// CreateResourcePool creates a new ResourcePool entity. | ||
func (c *Client) CreateResourcePool(ctx context.Context, req CreateResourcePoolReq) error { | ||
return c.requestBody(ctx, http.MethodPost, "/api/private/resource-pools", req, nil) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.