platform

package
v0.22.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 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 CreatedByCLILabel = "vcluster.loft.sh/created-by-cli"
View Source
const DefaultPlatformSecretName = "vcluster-platform-api-key"

Variables

View Source
var (
	MinimumVersionTag = "v4.0.0-alpha.18"
	MinimumVersion    = semver.MustParse(strings.TrimPrefix(MinimumVersionTag, "v"))
)
View Source
var (
	Self *managementv1.Self
)

Functions

func ApplyPlatformSecret

func ApplyPlatformSecret(
	ctx context.Context,
	config *config.CLI,
	kubeClient kubernetes.Interface,
	importName,
	name,
	namespace,
	project,
	accessKey,
	host string,
	insecure bool,
	certificateAuthorityData []byte,
	log log.Logger,
) 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, *storagev1.EntityInfo, error)

func GetDeepValue

func GetDeepValue(parameters interface{}, path string) interface{}

func GetLatestMatchedVersion

func GetLatestMatchedVersion(versions storagev1.VersionsAccessor, versionPattern string) (latestVersion storagev1.VersionAccessor, latestMatchedVersion storagev1.VersionAccessor, err error)

func LatestCompatibleVersion

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

LatestCompatibleVersion returns the latest compatible version of vCluster.Pro

func ResolveTemplateParameters

func ResolveTemplateParameters(set []string, parameters []storagev1.AppParameter, fileName string) (string, error)

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 SelectSpaceInstance

func SelectSpaceInstance(ctx context.Context, client Client, spaceName, projectName 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 SelectVirtualClusterTemplate

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

func SetDeepValue

func SetDeepValue(parameters interface{}, path string, value interface{})

func VerifyValue

func VerifyValue(value string, parameter storagev1.AppParameter) (interface{}, error)

func WaitForSpaceInstance

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

func WaitForVirtualClusterInstance

func WaitForVirtualClusterInstance(ctx context.Context, managementClient kube.Interface, namespace, name string, waitUntilReady bool, log log.Logger) (*managementv1.VirtualClusterInstance, 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)
	VirtualCluster(cluster, namespace, virtualCluster string) (kube.Interface, error)

	ManagementConfig() (*rest.Config, 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 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 {
	Project       string
	ProjectSecret managementv1.ProjectSecret
}

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 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.

func (*VirtualClusterInstanceProject) IsInstanceSleeping

func (vci *VirtualClusterInstanceProject) IsInstanceSleeping() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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