coder

package
v1.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2020 License: GPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const Me = "me"

Me is the route param to access resources of the authenticated user

Variables

View Source
var ErrNotFound = xerrors.Errorf("resource not found")

ErrNotFound describes an error case in which the requested resource could not be found

Functions

This section is empty.

Types

type BuildLog added in v1.12.0

type BuildLog struct {
	ID            string `db:"id" json:"id"`
	EnvironmentID string `db:"environment_id" json:"environment_id"`
	// BuildID allows the frontend to separate the logs from the old build with the logs from the new.
	BuildID string       `db:"build_id" json:"build_id"`
	Time    time.Time    `db:"time" json:"time"`
	Type    BuildLogType `db:"type" json:"type"`
	Msg     string       `db:"msg" json:"msg"`
}

BuildLog defines a build log record for a Coder environment.

type BuildLogFollowMsg added in v1.12.0

type BuildLogFollowMsg struct {
	BuildLog
	Err error
}

BuildLogFollowMsg wraps the base BuildLog and adds a field for collecting errors that may occur when follow or parsing.

type BuildLogType added in v1.11.0

type BuildLogType string

BuildLogType describes the type of an event.

const (
	// BuildLogTypeStart signals that a new build log has begun.
	BuildLogTypeStart BuildLogType = "start"
	// BuildLogTypeStage is a stage-level event for an environment.
	// It can be thought of as a major step in the environment's
	// lifecycle.
	BuildLogTypeStage BuildLogType = "stage"
	// BuildLogTypeError describes an error that has occurred.
	BuildLogTypeError BuildLogType = "error"
	// BuildLogTypeSubstage describes a subevent that occurs as
	// part of a stage. This can be the output from a user's
	// personalization script, or a long running command.
	BuildLogTypeSubstage BuildLogType = "substage"
	// BuildLogTypeDone signals that the build has completed.
	BuildLogTypeDone BuildLogType = "done"
)

type Client

type Client struct {
	BaseURL *url.URL
	Token   string
}

Client wraps the Coder HTTP API

func (Client) CreateEnvironment added in v1.11.0

func (c Client) CreateEnvironment(ctx context.Context, orgID string, req CreateEnvironmentRequest) (*Environment, error)

CreateEnvironment sends a request to create an environment.

func (Client) DelDevURL

func (c Client) DelDevURL(ctx context.Context, envID, urlID string) error

DelDevURL deletes the specified devurl.

func (Client) DeleteEnvironment added in v1.11.0

func (c Client) DeleteEnvironment(ctx context.Context, envID string) error

DeleteEnvironment deletes the environment.

func (*Client) DeleteSecretByName

func (c *Client) DeleteSecretByName(ctx context.Context, name, userID string) error

DeleteSecretByName deletes the authenticated users secret with the given name

func (Client) DialEnvironmentBuildLog added in v1.11.0

func (c Client) DialEnvironmentBuildLog(ctx context.Context, envID string) (*websocket.Conn, error)

DialEnvironmentBuildLog opens a websocket connection for the environment build log messages.

func (Client) DialEnvironmentStats added in v1.11.0

func (c Client) DialEnvironmentStats(ctx context.Context, envID string) (*websocket.Conn, error)

DialEnvironmentStats opens a websocket connection for environment stats.

func (Client) DialIDEStatus added in v1.11.0

func (c Client) DialIDEStatus(ctx context.Context, envID string) (*websocket.Conn, error)

DialIDEStatus opens a websocket connection for cpu load metrics on the environment

func (Client) DialResourceLoad added in v1.11.0

func (c Client) DialResourceLoad(ctx context.Context, envID string) (*websocket.Conn, error)

DialResourceLoad opens a websocket connection for cpu load metrics on the environment

func (Client) DialWsep

func (c Client) DialWsep(ctx context.Context, env *Environment) (*websocket.Conn, error)

DialWsep dials an environments command execution interface See https://github.com/cdr/wsep for details.

func (Client) EditEnvironment added in v1.12.0

func (c Client) EditEnvironment(ctx context.Context, envID string, req UpdateEnvironmentReq) error

EditEnvironment modifies the environment specification and initiates a rebuild.

func (Client) Environments added in v1.12.0

func (c Client) Environments(ctx context.Context) ([]Environment, error)

Environments lists environments returned by the given filter. TODO: add the filter options, explore performance issues

func (Client) EnvironmentsByOrganization

func (c Client) EnvironmentsByOrganization(ctx context.Context, userID, orgID string) ([]Environment, error)

EnvironmentsByOrganization gets the list of environments owned by the given user.

func (Client) FollowEnvironmentBuildLog added in v1.12.0

func (c Client) FollowEnvironmentBuildLog(ctx context.Context, envID string) (<-chan BuildLogFollowMsg, error)

FollowEnvironmentBuildLog trails the build log of a Coder environment.

func (Client) ImportImage added in v1.11.0

func (c Client) ImportImage(ctx context.Context, orgID string, req ImportImageRequest) (*Image, error)

ImportImage creates a new image and optionally a new registry

func (Client) InsertDevURL

func (c Client) InsertDevURL(ctx context.Context, envID string, port int, name, access string) error

InsertDevURL inserts a new devurl for the authenticated user.

func (*Client) InsertSecret

func (c *Client) InsertSecret(ctx context.Context, user *User, req InsertSecretReq) error

InsertSecret adds a new secret for the authed user

func (Client) Me

func (c Client) Me(ctx context.Context) (*User, error)

Me gets the details of the authenticated user.

func (Client) OrgMembers added in v1.12.0

func (c Client) OrgMembers(ctx context.Context, orgID string) ([]OrganizationUser, error)

OrgMembers get all members of the given organization

func (Client) Organizations added in v1.12.0

func (c Client) Organizations(ctx context.Context) ([]Organization, error)

Organizations gets all Organizations

func (Client) PushActivity

func (c Client) PushActivity(ctx context.Context, source, envID string) error

PushActivity pushes CLI activity to Coder.

func (Client) RebuildEnvironment added in v1.12.0

func (c Client) RebuildEnvironment(ctx context.Context, envID string) error

RebuildEnvironment requests that the given envID is rebuilt with no changes to its specification.

func (Client) SSHKey

func (c Client) SSHKey(ctx context.Context) (*SSHKey, error)

SSHKey gets the current SSH kepair of the authenticated user.

func (*Client) SecretByName

func (c *Client) SecretByName(ctx context.Context, name, userID string) (*Secret, error)

SecretByName gets a secret object by name

func (*Client) SecretWithValueByID

func (c *Client) SecretWithValueByID(ctx context.Context, id, userID string) (*Secret, error)

SecretWithValueByID gets the Coder secret with its value by the secret_id.

func (*Client) SecretWithValueByName

func (c *Client) SecretWithValueByName(ctx context.Context, name, userID string) (*Secret, error)

SecretWithValueByName gets the Coder secret with its value by its name.

func (*Client) Secrets

func (c *Client) Secrets(ctx context.Context, userID string) ([]Secret, error)

Secrets gets all secrets for the given user

func (Client) StopEnvironment added in v1.12.0

func (c Client) StopEnvironment(ctx context.Context, envID string) error

StopEnvironment stops the stops.

func (Client) UpdateDevURL

func (c Client) UpdateDevURL(ctx context.Context, envID, urlID string, port int, name, access string) error

UpdateDevURL updates an existing devurl for the authenticated user.

func (Client) UserByEmail

func (c Client) UserByEmail(ctx context.Context, email string) (*User, error)

UserByEmail gets a user by email.

func (Client) UserByID

func (c Client) UserByID(ctx context.Context, id string) (*User, error)

UserByID get the details of a user by their id.

func (Client) Users

func (c Client) Users(ctx context.Context) ([]User, error)

Users gets the list of user accounts.

func (Client) WaitForEnvironmentReady added in v1.11.0

func (c Client) WaitForEnvironmentReady(ctx context.Context, env *Environment) error

WaitForEnvironmentReady will watch the build log and return when done

type CreateEnvironmentRequest added in v1.11.0

type CreateEnvironmentRequest struct {
	Name     string   `json:"name"`
	ImageID  string   `json:"image_id"`
	ImageTag string   `json:"image_tag"`
	CPUCores float32  `json:"cpu_cores"`
	MemoryGB int      `json:"memory_gb"`
	DiskGB   int      `json:"disk_gb"`
	GPUs     int      `json:"gpus"`
	Services []string `json:"services"`
}

CreateEnvironmentRequest is used to configure a new environment.

type DevURL

type DevURL struct {
	ID     string `json:"id"     tab:"ID"`
	URL    string `json:"url"    tab:"URL"`
	Port   int    `json:"port"   tab:"Port"`
	Access string `json:"access" tab:"Access"`
	Name   string `json:"name"   tab:"Name"`
}

DevURL is the parsed json response record for a devURL from cemanager.

type Environment

type Environment struct {
	ID               string           `json:"id"                 tab:"-"`
	Name             string           `json:"name"               tab:"Name"`
	ImageID          string           `json:"image_id"           tab:"-"`
	ImageTag         string           `json:"image_tag"          tab:"ImageTag"`
	OrganizationID   string           `json:"organization_id"    tab:"-"`
	UserID           string           `json:"user_id"            tab:"-"`
	LastBuiltAt      time.Time        `json:"last_built_at"      tab:"-"`
	CPUCores         float32          `json:"cpu_cores"          tab:"CPUCores"`
	MemoryGB         float32          `json:"memory_gb"          tab:"MemoryGB"`
	DiskGB           int              `json:"disk_gb"            tab:"DiskGB"`
	GPUs             int              `json:"gpus"               tab:"GPUs"`
	Updating         bool             `json:"updating"           tab:"Updating"`
	LatestStat       EnvironmentStat  `json:"latest_stat"        tab:"Status"`
	RebuildMessages  []RebuildMessage `json:"rebuild_messages"   tab:"-"`
	CreatedAt        time.Time        `json:"created_at"         tab:"-"`
	UpdatedAt        time.Time        `json:"updated_at"         tab:"-"`
	LastOpenedAt     time.Time        `json:"last_opened_at"     tab:"-"`
	LastConnectionAt time.Time        `json:"last_connection_at" tab:"-"`
	AutoOffThreshold xjson.MSDuration `json:"auto_off_threshold" tab:"-"`
}

Environment describes a Coder environment

type EnvironmentStat added in v1.11.0

type EnvironmentStat struct {
	Time            time.Time         `json:"time"`
	LastOnline      time.Time         `json:"last_online"`
	ContainerStatus EnvironmentStatus `json:"container_status"`
	StatError       string            `json:"stat_error"`
	CPUUsage        float32           `json:"cpu_usage"`
	MemoryTotal     int64             `json:"memory_total"`
	MemoryUsage     float32           `json:"memory_usage"`
	DiskTotal       int64             `json:"disk_total"`
	DiskUsed        int64             `json:"disk_used"`
}

EnvironmentStat represents the state of an environment

func (EnvironmentStat) String added in v1.11.0

func (e EnvironmentStat) String() string

type EnvironmentStatus added in v1.11.0

type EnvironmentStatus string

EnvironmentStatus refers to the states of an environment.

const (
	EnvironmentCreating EnvironmentStatus = "CREATING"
	EnvironmentOff      EnvironmentStatus = "OFF"
	EnvironmentOn       EnvironmentStatus = "ON"
	EnvironmentFailed   EnvironmentStatus = "FAILED"
	EnvironmentUnknown  EnvironmentStatus = "UNKNOWN"
)

The following represent the possible environment container states

type HTTPError added in v1.12.0

type HTTPError struct {
	*http.Response
}

HTTPError represents an error from the Coder API.

func (*HTTPError) Error added in v1.12.0

func (e *HTTPError) Error() string

type Image added in v1.11.0

type Image struct {
	ID              string  `json:"id"`
	OrganizationID  string  `json:"organization_id"`
	Repository      string  `json:"repository"`
	Description     string  `json:"description"`
	URL             string  `json:"url"` // User-supplied URL for image.
	DefaultCPUCores float32 `json:"default_cpu_cores"`
	DefaultMemoryGB int     `json:"default_memory_gb"`
	DefaultDiskGB   int     `json:"default_disk_gb"`
	Deprecated      bool    `json:"deprecated"`
}

Image describes a Coder Image

type ImportImageRequest added in v1.11.0

type ImportImageRequest struct {
	RegistryID      *string             `json:"registry_id"`  // Used to import images to existing registries.
	NewRegistry     *NewRegistryRequest `json:"new_registry"` // Used when adding a new registry.
	Repository      string              `json:"repository"`   // Refers to the image. Ex: "codercom/ubuntu".
	Tag             string              `json:"tag"`
	DefaultCPUCores float32             `json:"default_cpu_cores"`
	DefaultMemoryGB int                 `json:"default_memory_gb"`
	DefaultDiskGB   int                 `json:"default_disk_gb"`
	Description     string              `json:"description"`
	URL             string              `json:"url"`
}

ImportImageRequest is used to import new images and registries into Coder

type InsertSecretReq

type InsertSecretReq struct {
	Name        string `json:"name"`
	Value       string `json:"value"`
	Description string `json:"description"`
}

InsertSecretReq describes the request body for creating a new secret.

type NewRegistryRequest added in v1.11.0

type NewRegistryRequest struct {
	FriendlyName string `json:"friendly_name"`
	Registry     string `json:"registry"`
	Username     string `json:"username"`
	Password     string `json:"password"`
}

NewRegistryRequest describes a docker registry used in importing an image

type Organization added in v1.12.0

type Organization struct {
	ID      string             `json:"id"`
	Name    string             `json:"name"`
	Members []OrganizationUser `json:"members"`
}

Organization describes an Organization in Coder

type OrganizationRole added in v1.12.0

type OrganizationRole string

OrganizationRole defines an organization OrganizationRole

const (
	RoleOrgMember  OrganizationRole = "organization-member"
	RoleOrgAdmin   OrganizationRole = "organization-admin"
	RoleOrgManager OrganizationRole = "organization-manager"
)

The OrganizationRole enum values

type OrganizationUser added in v1.12.0

type OrganizationUser struct {
	User
	OrganizationRoles []OrganizationRole `json:"organization_roles"`
	RolesUpdatedAt    time.Time          `json:"roles_updated_at"`
}

OrganizationUser user wraps the basic User type and adds data specific to the user's membership of an organization

type RebuildMessage added in v1.11.0

type RebuildMessage struct {
	Text             string           `json:"text"`
	Required         bool             `json:"required"`
	AutoOffThreshold xjson.MSDuration `json:"auto_off_threshold" tab:"-"`
	RebuildMessages  []struct {
		Text     string `json:"text"`
		Required bool   `json:"required"`
	} `json:"rebuild_messages" tab:"-"`
}

RebuildMessage defines the message shown when an Environment requires a rebuild for it can be accessed.

type SSHKey

type SSHKey struct {
	PublicKey  string `json:"public_key"`
	PrivateKey string `json:"private_key"`
}

SSHKey describes an SSH keypair.

type Secret

type Secret struct {
	ID          string    `json:"id"              tab:"-"`
	Name        string    `json:"name"            tab:"Name"`
	Value       string    `json:"value,omitempty" tab:"Value"`
	Description string    `json:"description"     tab:"Description"`
	CreatedAt   time.Time `json:"created_at"      tab:"CreatedAt"`
	UpdatedAt   time.Time `json:"updated_at"      tab:"-"`
}

Secret describes a Coder secret

type UpdateEnvironmentReq added in v1.12.0

type UpdateEnvironmentReq struct {
	ImageID              *string   `json:"image_id"`
	ImageTag             *string   `json:"image_tag"`
	CPUCores             *float32  `json:"cpu_cores"`
	MemoryGB             *float32  `json:"memory_gb"`
	DiskGB               *int      `json:"disk_gb"`
	GPUs                 *int      `json:"gpus"`
	Services             *[]string `json:"services"`
	CodeServerReleaseURL *string   `json:"code_server_release_url"`
}

UpdateEnvironmentReq defines the update operation, only setting nil-fields.

type User

type User struct {
	ID        string    `json:"id"         tab:"-"`
	Email     string    `json:"email"      tab:"Email"`
	Username  string    `json:"username"   tab:"Username"`
	Name      string    `json:"name"       tab:"Name"`
	CreatedAt time.Time `json:"created_at" tab:"CreatedAt"`
	UpdatedAt time.Time `json:"updated_at" tab:"-"`
}

User describes a Coder user account.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL