castai

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoApiKey = errors.New("no api key")
	ErrNotFound = errors.New("not found")
)

Functions

func GetVersion added in v0.0.26

func GetVersion() config.CastwareOperatorVersion

func NewRestyClient

func NewRestyClient(config *config.Config, apiURL string, auth auth.Auth) *resty.Client

NewRestyClient returns a new authenticated rest client to send requests to the specified API.

func SetVersion

func SetVersion(v config.CastwareOperatorVersion)

Types

type AckActionRequest added in v0.0.6

type AckActionRequest struct {
	Error *string `json:"error"`
}

type Action added in v0.0.6

type Action struct {
	// The ID of the action.
	Id string `json:"id"`
	// Creation date of the action.
	CreateTime *time.Time `json:"createTime"`

	ActionInstall   *ActionInstall   `json:"install"`
	ActionUpgrade   *ActionUpgrade   `json:"upgrade"`
	ActionRollback  *ActionRollback  `json:"rollback"`
	ActionUninstall *ActionUninstall `json:"uninstall"`
}

func (Action) Action added in v0.0.6

func (a Action) Action() interface{}

type ActionInstall added in v0.0.6

type ActionInstall struct {
	// Version of the component to install, if empty install the latest version.
	Version string `json:"version"`
	// Name of the component to install.
	Component string `json:"component"`
	// If true and the component is already installed the operator will attempt to reinstall it.
	Upsert bool `json:"upsert"`
	// Helm values overrides, use dot notation for nested values.
	ValuesOverrides map[string]string `json:"valuesOverrides"`
	// If true the component and upsert is true will be upgraded with
	// helm flag reset-than-reuse-values instead of reuse-values.
	ResetThenReuseValues bool `json:"resetThenReuseValues"`
	// Name used by helm during component installation.
	ReleaseName string `json:"releaseName,omitempty"`
}

ActionInstall installs a new component on a cluster.

type ActionRollback added in v0.0.6

type ActionRollback struct {
	// Name of the component to rollback.
	Component string `json:"component"`
}

ActionRollback rolls back a component to the previously installed version.

type ActionType added in v0.0.6

type ActionType string

The action that can be performed on a CASTware component.

const (
	// An install component action.
	Action_INSTALL ActionType = "ENABLE"
	// An upgrade component action.
	Action_UPGRADE ActionType = "UPDATE"
	// A delete component action.
	Action_DELETE ActionType = "DISABLE"
	// A rollback component action.
	Action_ROLLBACK ActionType = "ROLLBACK"
)

type ActionUninstall added in v0.0.6

type ActionUninstall struct {
	// Name of the component to uninstall.
	Component string `json:"component"`
}

ActionUninstall uninstalls a component from a cluster.

type ActionUpgrade added in v0.0.6

type ActionUpgrade struct {
	// Version of the component to upgrade, if empty upgrade to the latest version.
	Version string `json:"version"`
	// Name of the component to upgrade.
	Component string `json:"component"`
	// Helm values overrides, use dot notation for nested values.
	ValuesOverrides map[string]string `json:"valuesOverrides"`
	// If true the component will be upgraded with helm flag reset-than-reuse-values instead of reuse-values.
	ResetThenReuseValues bool `json:"resetThenReuseValues"`
	// Name used by helm during component upgrade.
	ReleaseName string `json:"releaseName"`
}

ActionUpgrade upgrades an existing component on a cluster.

type ApiError

type ApiError struct {
	Message         string        `json:"message"`
	FieldViolations []interface{} `json:"fieldViolations"`
}

type CastAIClient

type CastAIClient interface {
	castai.Client
	Me(ctx context.Context) (*User, error)
	GetCluster(ctx context.Context, clusterID string) (*Cluster, error)
	GetComponentByName(ctx context.Context, name string) (*Component, error)
	RecordActionResult(ctx context.Context, clusterID string, req *ComponentActionResult) error
	PollActions(ctx context.Context, clusterID string) (*PollActionsResponse, error)
	AckAction(ctx context.Context, clusterID, actionID string, error error) error
	ValidateComponentUpgrade(ctx context.Context, req *ValidateComponentUpgradeRequest) (*ValidateComponentUpgradeResponse, error)
}

func NewClient

func NewClient(log logrus.FieldLogger, config *config.Config, rest *resty.Client) CastAIClient

NewClient returns new Client for communicating with Cast AI.

type Client

type Client struct {
	// contains filtered or unexported fields
}

func (*Client) AckAction added in v0.0.6

func (c *Client) AckAction(ctx context.Context, clusterID, actionID string, error error) error

func (*Client) ExchangeAgentTelemetry

func (c *Client) ExchangeAgentTelemetry(ctx context.Context, clusterID string, req *castai.AgentTelemetryRequest) (*castai.AgentTelemetryResponse, error)

ExchangeAgentTelemetry is not supported in castware operator, this function is here only to implement castai.Client interface needed for cluster registration

func (*Client) GetCluster

func (c *Client) GetCluster(ctx context.Context, clusterID string) (*Cluster, error)

GetCluster gets a cluster by id.

func (*Client) GetComponentByName

func (c *Client) GetComponentByName(ctx context.Context, name string) (*Component, error)

GetComponentByName retrieves a component by its name.

func (*Client) Me

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

Me gets profile for current user.

func (*Client) PollActions added in v0.0.6

func (c *Client) PollActions(ctx context.Context, clusterID string) (*PollActionsResponse, error)

func (*Client) RecordActionResult added in v0.0.6

func (c *Client) RecordActionResult(ctx context.Context, clusterID string, req *ComponentActionResult) error

RecordActionResult recors the results of an action performed on a component.

func (*Client) RegisterCluster

RegisterCluster registers a new cluster in the mothership and returns a cluster id, if the cluster already exists the id of the existing cluster is returned

func (*Client) SendDelta

func (c *Client) SendDelta(ctx context.Context, clusterID string, delta *castai.Delta) error

SendDelta is not supported in castware operator, this function is here only to implement castai.Client interface needed for cluster registration

func (*Client) SendLogEvent

func (c *Client) SendLogEvent(ctx context.Context, clusterID string, req *castai.IngestAgentLogsRequest) (*castai.IngestAgentLogsResponse, error)

SendLogEvent is not supported in castware operator, this function is here only to implement castai.Client interface needed for cluster registration

func (*Client) ValidateComponentUpgrade added in v0.0.15

type Cluster

type Cluster struct {
	// The cluster's ID.
	Id string `json:"id,omitempty"`
	// The name of the external cluster.
	Name string `json:"name,omitempty"`
	// The cluster's organization ID.
	OrganizationId string `json:"organization_id,omitempty"`
	// The date when cluster was registered.
	CreatedAt *time.Time `json:"created_at,omitempty"`
	// Current status of the cluster.
	Status string `json:"status,omitempty"`
	// The date agent snapshot was last received.
	AgentSnapshotReceivedAt *time.Time `json:"agent_snapshot_received_at,omitempty"`
	// Agent status.
	AgentStatus string `json:"agent_status,omitempty"`
}

type Component

type Component struct {
	Id            string   `json:"id"`
	Name          string   `json:"name"`
	HelmChart     string   `json:"helmChart"`
	Dependencies  []string `json:"dependencies"`
	LatestVersion string   `json:"latestVersion"`
	ReleaseName   string   `json:"releaseName"`
}

type ComponentActionResult added in v0.0.6

type ComponentActionResult struct {
	// The name of the component.
	Name string `json:"name,omitempty"`
	// The action that has been performed on the component.
	Action ActionType `json:"action,omitempty"`
	// The current version of the component installed on the cluster.
	// An empty string means the component was not installed prior the performing the action.
	CurrentVersion string `json:"current_version,omitempty"`
	// The version of the component targeted by the action.
	// An empty string means the installed component has been deleted while performing the action.
	Version string `json:"version,omitempty"`
	// The status of the component installed on the cluster.
	Status Status `json:"status,omitempty"`
	// The list of available images and their versions.
	ImageVersions map[string]string `json:"image_versions,omitempty"`
	// The Helm release name of the installed component.
	ReleaseName string `json:"release_name,omitempty"`
	// The verbose details of the outcome.
	Message string `json:"message,omitempty"`
	// Component-specific installation parameters.
	// Only specific, non-sensitive parameters are included (not all Helm values).
	// Examples: {"extendedPermissions": true}, {"phase2Permissions": true}
	ComponentParams map[string]interface{} `json:"component_params,omitempty"`
}

type PollActionsResponse added in v0.0.6

type PollActionsResponse struct {
	// List of pending actions sorted from the oldest one.
	Actions []*Action `json:"actions"`
}

Response message with pending lifecycle actions

type Status added in v0.0.6

type Status string

The status of an installed CASTware component.

const (
	// Unspecified status.
	Status_STATUS_UNSPECIFIED Status = "STATUS_UNSPECIFIED"
	// A component which is disconnected.
	Status_DISCONNECTED Status = "DISCONNECTED"
	// A component which needs an update.
	Status_UPDATE_NEEDED Status = "UPDATE_NEEDED"
	// A component which needs a user action.
	Status_ACTION_REQUIRED Status = "ACTION_REQUIRED"
	// A component which has an error.
	Status_ERROR Status = "ERROR"
	// A component which has an OK status.
	Status_OK Status = "OK"
	// A component which is currently being installed, updated, or deleted.
	Status_PROGRESSING Status = "PROGRESSING"
)

type User

type User struct {
	ID       string `json:"id"`
	Username string `json:"username"`
}

type ValidateComponentUpgradeRequest added in v0.0.15

type ValidateComponentUpgradeRequest struct {
	ClusterID     string `json:"cluster_id"`
	ComponentName string `json:"component_name"`
	TargetVersion string `json:"target_version"`
}

type ValidateComponentUpgradeResponse added in v0.0.15

type ValidateComponentUpgradeResponse struct {
	Allowed     bool   `json:"allowed"`
	BlockReason string `json:"blockReason,omitempty"`
}

type ValidationError added in v0.0.30

type ValidationError struct {
	Allowed     bool   `json:"allowed"`
	BlockReason string `json:"blockReason"`
}

Directories

Path Synopsis
mock
Package mock_auth is a generated GoMock package.
Package mock_auth is a generated GoMock package.
Package mock_castai is a generated GoMock package.
Package mock_castai is a generated GoMock package.

Jump to

Keyboard shortcuts

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