Documentation
¶
Index ¶
- Constants
- func CloseSession(ac *client.AlpaconClient, sessionID string) error
- func GetClusterDetailRaw(ac *client.AlpaconClient, clusterID string) ([]byte, error)
- func GetClusterIDByName(ac *client.AlpaconClient, clusterName string) (string, error)
- func IsSurfaceOff(err error) bool
- func ResolveGroupNames(ac *client.AlpaconClient, groupIDs []string) []string
- type ClusterAttributes
- type ClusterDetail
- type KubeSessionCreateRequest
- type KubeSessionDetail
- type KubeSessionResponse
- type Optional
Constants ¶
const ClientTypeCLI = "cli"
ClientTypeCLI is the client_type a session opened from this CLI declares.
const SurfaceNotEnabledMessage = "Kubernetes support is not enabled on this workspace. If it was enabled recently, run 'alpacon login' again to refresh."
SurfaceNotEnabledMessage is what the CLI prints when the workspace does not expose the Kubernetes surface.
Variables ¶
This section is empty.
Functions ¶
func CloseSession ¶ added in v1.16.0
func CloseSession(ac *client.AlpaconClient, sessionID string) error
CloseSession ends a proxy session.
func GetClusterDetailRaw ¶
func GetClusterDetailRaw(ac *client.AlpaconClient, clusterID string) ([]byte, error)
GetClusterDetailRaw fetches one cluster by ID and returns the body as the server sent it.
func GetClusterIDByName ¶
func GetClusterIDByName(ac *client.AlpaconClient, clusterName string) (string, error)
GetClusterIDByName resolves a cluster name to its ID through the server's exact-match name filter.
func IsSurfaceOff ¶ added in v1.18.0
IsSurfaceOff reports whether err carries a 404, which the server answers for every path under /api/kubernetes/ when the Kubernetes surface is off.
func ResolveGroupNames ¶
func ResolveGroupNames(ac *client.AlpaconClient, groupIDs []string) []string
ResolveGroupNames maps group UUIDs to names in one batched lookup. A UUID with no match, or every UUID when the lookup fails, is shown as-is so the caller's output is never blocked on the group list.
Types ¶
type ClusterAttributes ¶
type ClusterAttributes struct {
Name string `json:"name"`
Provider string `json:"provider"`
KubeVersion Optional[string] `json:"kube_version" table:"Kube Version"`
NodeCount Optional[int] `json:"node_count" table:"Nodes"`
Connected bool `json:"connected"`
Enabled bool `json:"enabled"`
AgentVersion string `json:"agent_version" table:"Agent Version"`
}
ClusterAttributes is the 'kube ls' row. Its version and node count keep the server's names and types, so a script reading --output json sees node_count as a number and a value the agent has not reported yet as null; the table shows that as blank. Connected follows ServerAttributes, not is_connected.
func GetClusterList ¶
func GetClusterList(ac *client.AlpaconClient) ([]ClusterAttributes, error)
GetClusterList returns every cluster the caller can see, projected for 'kube ls'. A service token sees none: the server answers it with an empty list.
type ClusterDetail ¶
type ClusterDetail struct {
ID string `json:"id"`
Name string `json:"name"`
Provider string `json:"provider"`
KubeVersion *string `json:"kube_version"`
AgentVersion string `json:"agent_version"`
NodeCount *int `json:"node_count"`
Status json.RawMessage `json:"status"`
Enabled bool `json:"enabled"`
Groups []string `json:"groups"`
Tags json.RawMessage `json:"tags"`
IsConnected bool `json:"is_connected"`
LastConnectivity *time.Time `json:"last_connectivity"`
LastSyncedAt *time.Time `json:"last_synced_at"`
AddedAt time.Time `json:"added_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ClusterDetail decodes one entry of /api/kubernetes/clusters/. Status and Tags stay raw: the server stores both as free-form JSON, and status has no enum. KubeVersion and NodeCount are nil until the agent has measured them, which is not the same as an empty version or zero nodes.
func GetClusterDetail ¶
func GetClusterDetail(ac *client.AlpaconClient, clusterID string) (*ClusterDetail, error)
GetClusterDetail fetches one cluster by ID.
type KubeSessionCreateRequest ¶ added in v1.16.0
type KubeSessionCreateRequest struct {
Cluster string `json:"cluster"`
WorkSession string `json:"work_session,omitempty"`
ClientType string `json:"client_type"`
}
KubeSessionCreateRequest opens a proxy session to one cluster. Cluster and WorkSession are UUIDs; WorkSession is left out when neither --work-session nor ALPACON_WORK_SESSION names a session.
type KubeSessionDetail ¶ added in v1.18.0
type KubeSessionDetail struct {
ID string `json:"id"`
TokenExpiredAt *time.Time `json:"token_expired_at"`
ClosedAt *time.Time `json:"closed_at"`
}
KubeSessionDetail is a kube session as it is read back. It never carries the channel token. TokenExpiredAt follows an extended work session, and ClosedAt is set once the session has ended for any reason.
func GetSession ¶ added in v1.18.0
func GetSession(ac *client.AlpaconClient, sessionID string) (*KubeSessionDetail, error)
GetSession reads a proxy session back, to learn whether it is still open and when its token expires now.
type KubeSessionResponse ¶ added in v1.16.0
type KubeSessionResponse struct {
ID string `json:"id"`
Cluster string `json:"cluster"`
ChannelID string `json:"channel_id"`
ChannelToken string `json:"channel_token"`
TokenExpiredAt time.Time `json:"token_expired_at"`
ProxyURL string `json:"proxy_url"`
}
KubeSessionResponse is the session the server opened. ChannelToken is the credential kubectl presents to ProxyURL until TokenExpiredAt.
func CreateSession ¶ added in v1.16.0
func CreateSession(ac *client.AlpaconClient, req KubeSessionCreateRequest) (*KubeSessionResponse, error)
CreateSession opens a proxy session to a cluster. The channel token appears only in this response—the server never returns it again—so the caller must persist it at once.
type Optional ¶
type Optional[T any] struct { Value *T }
Optional is a value the server may send as null. PrintTable formats a cell with %v, which would print a bare pointer's address, so the pointer is wrapped: String renders null as blank and MarshalJSON keeps it null.