api

package
v0.0.186 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DestroyCluster

func DestroyCluster(ctx context.Context, api API, clusterId string) error

func DialPort

func DialPort(ctx context.Context, cluster *KubernetesCluster, targetPort int) (net.Conn, error)

func DialPortWithToken added in v0.0.165

func DialPortWithToken(ctx context.Context, token fnapi.Token, cluster *KubernetesCluster, targetPort int) (net.Conn, error)

func Register added in v0.0.164

func Register()

func RegistryCreds added in v0.0.166

func RegistryCreds(ctx context.Context) (*authn.Basic, error)

func SetupFlags added in v0.0.164

func SetupFlags(flags *pflag.FlagSet, hide bool)

func StartRefreshing added in v0.0.181

func StartRefreshing(ctx context.Context, api API, clusterId string, handle func(error) error) error

func TailClusterLogs added in v0.0.168

func TailClusterLogs(ctx context.Context, api API, opts *LogsOpts, handle func(LogBlock) error) error

Types

type API added in v0.0.103

type API struct {
	StartCreateKubernetesCluster fnapi.Call[CreateKubernetesClusterRequest]
	GetKubernetesCluster         fnapi.Call[GetKubernetesClusterRequest]
	WaitKubernetesCluster        fnapi.Call[WaitKubernetesClusterRequest]
	ListKubernetesClusters       fnapi.Call[ListKubernetesClustersRequest]
	DestroyKubernetesCluster     fnapi.Call[DestroyKubernetesClusterRequest]
	RefreshKubernetesCluster     fnapi.Call[RefreshKubernetesClusterRequest]
	GetImageRegistry             fnapi.Call[emptypb.Empty]
	TailClusterLogs              fnapi.Call[TailLogsRequest]
	GetClusterLogs               fnapi.Call[GetLogsRequest]
}
var Endpoint API

func MakeAPI added in v0.0.103

func MakeAPI(endpoint string) API

type Attachment added in v0.0.167

type Attachment struct {
	TypeURL string `json:"type_url,omitempty"`
	Content []byte `json:"content,omitempty"`
}

type BuildCluster

type BuildCluster struct {
	Colocated *BuildCluster_ColocatedPort `json:"colocated,omitempty"`
}

type BuildCluster_ColocatedPort

type BuildCluster_ColocatedPort struct {
	TargetPort int32  `json:"target_port,omitempty"`
	ClusterId  string `json:"cluster_id,omitempty"`
}

type ClusterShape

type ClusterShape struct {
	VirtualCpu      int32 `json:"virtual_cpu,omitempty"`
	MemoryMegabytes int32 `json:"memory_megabytes,omitempty"`
}

type CreateClusterOpts added in v0.0.135

type CreateClusterOpts struct {
	MachineType string
	Ephemeral   bool

	// Whether to keep the cluster alive, regardless of it being ephemeral.
	// This is typically needed if you want to execute multiple ns commands on an ephemeral cluster.
	KeepAtExit bool

	Purpose           string
	Features          []string
	AuthorizedSshKeys []string
	UniqueTag         string

	WaitForStates []string
}

type CreateClusterResult

type CreateClusterResult struct {
	ClusterId    string
	Cluster      *KubernetesCluster
	Registry     *ImageRegistry
	BuildCluster *BuildCluster
	Deadline     *time.Time
}

func CreateAndWaitCluster

func CreateAndWaitCluster(ctx context.Context, api API, opts CreateClusterOpts) (*CreateClusterResult, error)

func EnsureBuildCluster added in v0.0.166

func EnsureBuildCluster(ctx context.Context, api API) (*CreateClusterResult, error)

func WaitCluster

func WaitCluster(ctx context.Context, api API, clusterId string, waitForStates ...string) (*CreateClusterResult, error)

type CreateKubernetesClusterRequest

type CreateKubernetesClusterRequest struct {
	OpaqueUserAuth    []byte   `json:"opaque_user_auth,omitempty"`
	Ephemeral         bool     `json:"ephemeral,omitempty"`
	DocumentedPurpose string   `json:"documented_purpose,omitempty"`
	AuthorizedSshKeys []string `json:"authorized_ssh_keys,omitempty"`
	MachineType       string   `json:"machine_type,omitempty"`
	Feature           []string `json:"feature,omitempty"`
	UniqueTag         string   `json:"unique_tag,omitempty"`
}

type CreateKubernetesClusterResponse

type CreateKubernetesClusterResponse struct {
	Status       string             `json:"status,omitempty"`
	ClusterId    string             `json:"cluster_id,omitempty"`
	Cluster      *KubernetesCluster `json:"cluster,omitempty"`
	Registry     *ImageRegistry     `json:"registry,omitempty"`
	BuildCluster *BuildCluster      `json:"build_cluster,omitempty"`
	Deadline     string             `json:"deadline,omitempty"`
}

type DestroyKubernetesClusterRequest

type DestroyKubernetesClusterRequest struct {
	OpaqueUserAuth []byte `json:"opaque_user_auth,omitempty"`
	ClusterId      string `json:"cluster_id,omitempty"`
}

type GetImageRegistryResponse added in v0.0.183

type GetImageRegistryResponse struct {
	Registry *ImageRegistry `json:"registry,omitempty"`
}

func GetImageRegistry added in v0.0.183

func GetImageRegistry(ctx context.Context, api API) (*GetImageRegistryResponse, error)

type GetKubernetesClusterRequest

type GetKubernetesClusterRequest struct {
	OpaqueUserAuth []byte `json:"opaque_user_auth,omitempty"`
	ClusterId      string `json:"cluster_id,omitempty"`
}

type GetKubernetesClusterResponse

type GetKubernetesClusterResponse struct {
	Cluster      *KubernetesCluster `json:"cluster,omitempty"`
	Registry     *ImageRegistry     `json:"registry,omitempty"`
	BuildCluster *BuildCluster      `json:"build_cluster,omitempty"`
	Deadline     string             `json:"deadline,omitempty"`
}

func GetCluster

func GetCluster(ctx context.Context, api API, clusterId string) (*GetKubernetesClusterResponse, error)

type GetLogsRequest added in v0.0.168

type GetLogsRequest struct {
	ClusterID string          `json:"cluster_id,omitempty"`
	StartTs   *time.Time      `json:"start_ts,omitempty"`
	EndTs     *time.Time      `json:"end_ts,omitempty"`
	Include   []*LogsSelector `json:"include,omitempty"`
	Exclude   []*LogsSelector `json:"exclude,omitempty"`
}

type GetLogsResponse added in v0.0.168

type GetLogsResponse struct {
	LogBlock []LogBlock `json:"log_block,omitempty"`
}

func GetClusterLogs added in v0.0.168

func GetClusterLogs(ctx context.Context, api API, opts *LogsOpts) (*GetLogsResponse, error)

type GithubWorkflowInfo added in v0.0.175

type GithubWorkflowInfo struct {
	Repository string `json:"repository,omitempty"`
	RunId      string `json:"run_id,omitempty"`
	RunAttempt string `json:"run_attempt,omitempty"`
	Sha        string `json:"sha,omitempty"`
	Ref        string `json:"ref,omitempty"`
	Actor      string `json:"actor,omitempty"`
	Workflow   string `json:"workflow,omitempty"`
}

type ImageRegistry

type ImageRegistry struct {
	EndpointAddress string `json:"endpoint_address,omitempty"`
}

type KubernetesCluster

type KubernetesCluster struct {
	AppURL            string        `json:"app_url,omitempty"`
	ClusterId         string        `json:"cluster_id,omitempty"`
	Created           string        `json:"created,omitempty"`
	DestroyedAt       string        `json:"destroyed_at,omitempty"`
	Deadline          string        `json:"deadline,omitempty"`
	SSHProxyEndpoint  string        `json:"ssh_proxy_endpoint,omitempty"`
	SshPrivateKey     []byte        `json:"ssh_private_key,omitempty"`
	DocumentedPurpose string        `json:"documented_purpose,omitempty"`
	Shape             *ClusterShape `json:"shape,omitempty"`

	EndpointAddress          string `json:"endpoint_address,omitempty"`
	CertificateAuthorityData []byte `json:"certificate_authority_data,omitempty"`
	ClientCertificateData    []byte `json:"client_certificate_data,omitempty"`
	ClientKeyData            []byte `json:"client_key_data,omitempty"`

	KubernetesDistribution string   `json:"kubernetes_distribution,omitempty"`
	Platform               []string `json:"platform,omitempty"`

	IngressDomain string `json:"ingress_domain,omitempty"`

	Label []*LabelEntry `json:"label,omitempty"`

	CreatorId      string              `json:"creator_id,omitempty"`
	GithubWorkflow *GithubWorkflowInfo `json:"github_workflow,omitempty"`
}

type KubernetesClusterMetadata added in v0.0.176

type KubernetesClusterMetadata struct {
	ClusterId         string        `json:"cluster_id,omitempty"`
	Created           string        `json:"created,omitempty"`
	DestroyedAt       string        `json:"destroyed_at,omitempty"`
	Deadline          string        `json:"deadline,omitempty"`
	DocumentedPurpose string        `json:"documented_purpose,omitempty"`
	Shape             *ClusterShape `json:"shape,omitempty"`

	KubernetesDistribution string   `json:"kubernetes_distribution,omitempty"`
	Platform               []string `json:"platform,omitempty"`

	IngressDomain string `json:"ingress_domain,omitempty"`

	Label []*LabelEntry `json:"label,omitempty"`

	CreatorId      string              `json:"creator_id,omitempty"`
	GithubWorkflow *GithubWorkflowInfo `json:"github_workflow,omitempty"`
}

type LabelEntry

type LabelEntry struct {
	Name  string `json:"name,omitempty"`
	Value string `json:"value,omitempty"`
}

type ListKubernetesClustersRequest

type ListKubernetesClustersRequest struct {
	OpaqueUserAuth      []byte `json:"opaque_user_auth,omitempty"`
	IncludePreviousRuns bool   `json:"include_previous_runs,omitempty"`
	PaginationCursor    []byte `json:"pagination_cursor,omitempty"`
	MaxEntries          int64  `json:"max_entries,omitempty"`
}

type ListKubernetesClustersResponse added in v0.0.176

type ListKubernetesClustersResponse struct {
	Clusters []KubernetesClusterMetadata `json:"cluster"`
}

func ListClusters

func ListClusters(ctx context.Context, api API, previousRuns bool) (*ListKubernetesClustersResponse, error)

type LogBlock added in v0.0.168

type LogBlock struct {
	Namespace string    `json:"namespace,omitempty"`
	Pod       string    `json:"pod,omitempty"`
	Container string    `json:"container,omitempty"`
	Line      []LogLine `json:"line,omitempty"`
}

type LogLine added in v0.0.168

type LogLine struct {
	Timestamp time.Time `json:"timestamp,omitempty"`
	Content   string    `json:"content,omitempty"`
	Stream    string    `json:"stream,omitempty"`
}

func (LogLine) String added in v0.0.168

func (l LogLine) String() string

type LogsOpts added in v0.0.168

type LogsOpts struct {
	ClusterID string
	StartTs   *time.Time
	EndTs     *time.Time
	Include   []*LogsSelector
	Exclude   []*LogsSelector
}

type LogsSelector added in v0.0.168

type LogsSelector struct {
	Namespace string `json:"namespace,omitempty"`
	Pod       string `json:"pod,omitempty"`
	Container string `json:"container,omitempty"`
}

type RefreshKubernetesClusterRequest added in v0.0.181

type RefreshKubernetesClusterRequest struct {
	ClusterId string `json:"cluster_id,omitempty"`
}

type RefreshKubernetesClusterResponse added in v0.0.181

type RefreshKubernetesClusterResponse struct {
	NewDeadline string `json:"new_deadline,omitempty"`
}

func RefreshCluster added in v0.0.181

func RefreshCluster(ctx context.Context, api API, clusterId string) (*RefreshKubernetesClusterResponse, error)

type StartCreateKubernetesClusterResponse

type StartCreateKubernetesClusterResponse struct {
	ClusterId       string             `json:"cluster_id,omitempty"`
	ClusterFragment *KubernetesCluster `json:"cluster_fragment,omitempty"`
	Registry        *ImageRegistry     `json:"registry,omitempty"`
	Deadline        string             `json:"deadline,omitempty"`
}

type TailLogsRequest added in v0.0.168

type TailLogsRequest struct {
	ClusterID string          `json:"cluster_id,omitempty"`
	Include   []*LogsSelector `json:"include,omitempty"`
	Exclude   []*LogsSelector `json:"exclude,omitempty"`
}

type WaitKubernetesClusterRequest

type WaitKubernetesClusterRequest struct {
	OpaqueUserAuth []byte `json:"opaque_user_auth,omitempty"`
	ClusterId      string `json:"cluster_id,omitempty"`
}

Jump to

Keyboard shortcuts

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