platform

package
v0.20.0-beta.6 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: Apache-2.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LoftDirectClusterEndpointCaData = "loft.sh/direct-cluster-endpoint-ca-data"
	VersionPath                     = "%s/version"
	LoginPath                       = "%s/login?cli=true"
	RedirectPath                    = "%s/spaces"
	AccessKeyPath                   = "%s/profile/access-keys"
	ConfigFileName                  = "platform.json"
	RefreshToken                    = time.Minute * 30
	CacheFolder                     = ".vcluster"
)
View Source
const DefaultPlatformSecretName = "vcluster-platform-api-key"

Variables

View Source
var (
	MinimumVersionTag = "v3.3.0-alpha.26"
	MinimumVersion    = semver.MustParse(strings.TrimPrefix(MinimumVersionTag, "v"))
)
View Source
var (
	Self *managementv1.Self
)

Functions

func ApplyPlatformSecret

func ApplyPlatformSecret(ctx context.Context, client Client, kubeClient kubernetes.Interface, importName, namespace, project string) error

func CanAccessInstance

func CanAccessInstance(ctx context.Context, managementClient kube.Interface, namespace, name string, resource string) (bool, error)

func CanAccessProjectSecret

func CanAccessProjectSecret(ctx context.Context, managementClient kube.Interface, namespace, name string) (bool, error)

func CreateSpaceInstanceOptions

func CreateSpaceInstanceOptions(ctx context.Context, client Client, config string, projectName string, spaceInstance *managementv1.SpaceInstance, setActive bool) (kubeconfig.ContextOptions, error)

func CreateVirtualClusterInstanceOptions

func CreateVirtualClusterInstanceOptions(ctx context.Context, client Client, config string, projectName string, virtualClusterInstance *managementv1.VirtualClusterInstance, setActive bool) (kubeconfig.ContextOptions, error)

func GetCurrentUser

func GetCurrentUser(ctx context.Context, managementClient kube.Interface) (*managementv1.UserInfo, *clusterv1.EntityInfo, error)

func LatestCompatibleVersion

func LatestCompatibleVersion(ctx context.Context) (string, error)

LatestCompatibleVersion returns the latest compatible version of vCluster.Pro

func ResolveVirtualClusterTemplate

func ResolveVirtualClusterTemplate(
	ctx context.Context,
	client Client,
	project,
	template,
	templateVersion string,
	setParams []string,
	fileParams string,
	log log.Logger,
) (*managementv1.VirtualClusterTemplate, string, error)

func RetrieveCaData

func RetrieveCaData(cluster *managementv1.Cluster) ([]byte, error)

func SelectCluster

func SelectCluster(ctx context.Context, client Client, log log.Logger) (string, error)

SelectCluster lets the user select a cluster

func SelectProjectCluster

func SelectProjectCluster(ctx context.Context, client Client, project *managementv1.Project, log log.Logger) (string, error)

SelectProjectCluster lets the user select a cluster from the project's allowed clusters

func SelectProjectOrCluster

func SelectProjectOrCluster(ctx context.Context, client Client, clusterName, projectName string, allowClusterOnly bool, log log.Logger) (cluster string, project string, err error)

func SelectSpaceAndClusterName

func SelectSpaceAndClusterName(ctx context.Context, client Client, spaceName, clusterName string, log log.Logger) (string, string, error)

SelectSpaceAndClusterName selects a space and cluster name

func SelectSpaceInstanceOrSpace

func SelectSpaceInstanceOrSpace(ctx context.Context, client Client, spaceName, projectName, clusterName string, log log.Logger) (string, string, string, error)

func SelectSpaceTemplate

func SelectSpaceTemplate(ctx context.Context, client Client, projectName, templateName string, log log.Logger) (*managementv1.SpaceTemplate, error)

func SelectUserOrTeam

func SelectUserOrTeam(ctx context.Context, client Client, clusterName string, log log.Logger) (*clusterv1.EntityInfo, *clusterv1.EntityInfo, error)

SelectUserOrTeam lets the user select an user or team in a cluster

func SelectVirtualClusterAndSpaceAndClusterName

func SelectVirtualClusterAndSpaceAndClusterName(ctx context.Context, client Client, virtualClusterName, spaceName, clusterName string, log log.Logger) (string, string, string, error)

func SelectVirtualClusterInstanceOrVirtualCluster

func SelectVirtualClusterInstanceOrVirtualCluster(ctx context.Context, client Client, virtualClusterName, spaceName, projectName, clusterName string, log log.Logger) (string, string, string, string, error)

func SelectVirtualClusterTemplate

func SelectVirtualClusterTemplate(ctx context.Context, client Client, projectName, templateName string, log log.Logger) (*managementv1.VirtualClusterTemplate, error)

func Timeout

func Timeout() time.Duration

func VerifyVersion

func VerifyVersion(platformClient Client) error

VerifyVersion checks if the Loft version is compatible with this CLI version

func VirtualClusterAccessPointCertificate

func VirtualClusterAccessPointCertificate(client Client, project, virtualCluster string, forceRefresh bool) (string, string, error)

func WaitForSpaceInstance

func WaitForSpaceInstance(ctx context.Context, managementClient kube.Interface, namespace, name string, waitUntilReady bool, log log.Logger) (*managementv1.SpaceInstance, error)

Types

type Client

type Client interface {
	LoginClient
	Logout(ctx context.Context) error

	Self() *managementv1.Self
	RefreshSelf(ctx context.Context) error

	Management() (kube.Interface, error)
	Cluster(cluster string) (kube.Interface, error)

	Config() *config.CLI
	Save() error

	Version() (*auth.Version, error)
}

func InitClientFromConfig

func InitClientFromConfig(ctx context.Context, config *config.CLI) (Client, error)

InitClientFromConfig returns a client with the client identity initialized through the selves api. Use this by default, unless performing actions that don't require a log in (like login itself).

func NewClientFromConfig

func NewClientFromConfig(config *config.CLI) Client

NewClientFromConfig returns a client without the client identity initialized through the selves api. Use this only when performing actions that don't require a log in (like login itself).

type ClusterSpace

type ClusterSpace struct {
	clusterv1.Space
	Cluster string
}

func GetSpaces

func GetSpaces(ctx context.Context, client Client, log log.Logger) ([]ClusterSpace, error)

GetSpaces returns all spaces accessible by the user or team

type ClusterUserOrTeam

type ClusterUserOrTeam struct {
	Team          bool
	ClusterMember managementv1.ClusterMember
}

func SelectClusterUserOrTeam

func SelectClusterUserOrTeam(ctx context.Context, client Client, clusterName, userName, teamName string, log log.Logger) (*ClusterUserOrTeam, error)

type ClusterVirtualCluster

type ClusterVirtualCluster struct {
	clusterv1.VirtualCluster
	Cluster string
}

func GetVirtualClusters

func GetVirtualClusters(ctx context.Context, client Client, log log.Logger) ([]ClusterVirtualCluster, error)

GetVirtualClusters returns all virtual clusters the user has access to

type LoginClient

type LoginClient interface {
	Login(host string, insecure bool, log log.Logger) error
	LoginWithAccessKey(host, accessKey string, insecure bool) error
}

func NewLoginClientFromConfig

func NewLoginClientFromConfig(config *config.CLI) LoginClient

type ProjectProjectSecret

type ProjectProjectSecret struct {
	ProjectSecret managementv1.ProjectSecret
	Project       string
}

func GetProjectSecrets

func GetProjectSecrets(ctx context.Context, managementClient kube.Interface, projectNames ...string) ([]*ProjectProjectSecret, error)

type SpaceInstanceProject

type SpaceInstanceProject struct {
	SpaceInstance *managementv1.SpaceInstance
	Project       *managementv1.Project
}

func GetSpaceInstances

func GetSpaceInstances(ctx context.Context, client Client) ([]*SpaceInstanceProject, error)

type VirtualClusterInstanceProject

type VirtualClusterInstanceProject struct {
	VirtualCluster *managementv1.VirtualClusterInstance
	Project        *managementv1.Project
}

func GetVirtualClusterInstances

func GetVirtualClusterInstances(ctx context.Context, client Client) ([]*VirtualClusterInstanceProject, error)

func ListVClusters

func ListVClusters(ctx context.Context, client Client, virtualClusterName, projectName string) ([]*VirtualClusterInstanceProject, error)

ListVClusters lists all virtual clusters across all projects if virtualClusterName and projectName are empty. The list can be narrowed down by the given virtual cluster name and project name.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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