Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

feat: add coder-sdk methods for multi-cluster#215

Merged
cmoog merged 3 commits intomasterfromcmoog/resource-pools
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes fromall 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
1 change: 1 addition & 0 deletionscoder-sdk/env.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,6 +34,7 @@ type Environment struct {
AutoOffThreshold Duration `json:"auto_off_threshold" table:"-"`
SSHAvailable bool `json:"ssh_available" table:"-"`
UseContainerVM bool `json:"use_container_vm" table:"CVM"`
ResourcePoolID string `json:"resource_pool_id" table:"-"`
}

// RebuildMessage defines the message shown when an Environment requires a rebuild for it can be accessed.
Expand Down
63 changes: 63 additions & 0 deletionscoder-sdk/resourcepools.go
View file
Open in desktop
Original file line numberDiff line numberDiff 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)
}

[8]ページ先頭

©2009-2025 Movatter.jp