platform

package
v0.14.6 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: MPL-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WorkspaceIDEnv       = "WORKSPACE_ID"
	WorkspaceUIDEnv      = "WORKSPACE_UID"
	WorkspaceContextEnv  = "WORKSPACE_CONTEXT"
	WorkspaceProviderEnv = "WORKSPACE_PROVIDER"
	WorkspaceInstanceEnv = "WORKSPACE_INSTANCE"
	WorkspacePictureEnv  = "WORKSPACE_PICTURE"
	WorkspaceSourceEnv   = "WORKSPACE_SOURCE"

	ConfigEnv  = "LOFT_CONFIG"
	ProjectEnv = "LOFT_PROJECT"
	ClusterEnv = "LOFT_CLUSTER"
	RunnerEnv  = "LOFT_RUNNER"

	TemplateOptionEnv        = "LOFT_TEMPLATE"
	TemplateVersionOptionEnv = "LOFT_TEMPLATE_VERSION"

	TimeoutEnv        = "LOFT_TIMEOUT"
	ProviderBinaryEnv = "PRO_PROVIDER"

	SpaceInstanceNameEnv          = "LOFT_SPACE_INSTANCE_NAME"
	VirtualClusterInstanceNameEnv = "LOFT_VIRTUAL_CLUSTER_INSTANCE_NAME"
	InstanceNamespaceEnv          = "LOFT_INSTANCE_NAMESPACE"

	DaemonFolderEnv = "DAEMON_FOLDER"
)
View Source
const (
	LoftPlatformConfigFileName string = "loft-config.json" // TODO: replace hardcoded strings with this
)

Variables

View Source
var CriticalStatus = map[string]bool{
	"Error":                      true,
	"Unknown":                    true,
	"ImagePullBackOff":           true,
	"CrashLoopBackOff":           true,
	"RunContainerError":          true,
	"ErrImagePull":               true,
	"CreateContainerConfigError": true,
	"InvalidImageName":           true,
}

CriticalStatus container status.

Functions

func DialInstance

func DialInstance(
	baseClient client.Client,
	workspace *managementv1.DevPodWorkspaceInstance,
	subResource string,
	values url.Values,
	log log.Logger,
) (*websocket.Conn, error)

func DisplayName

func DisplayName(name string, displayName string) string

func FindInstance

func FindInstance(
	ctx context.Context,
	baseClient client.Client,
	opts FindInstanceOptions,
) (*managementv1.DevPodWorkspaceInstance, error)

FindInstance finds a DevPodWorkspaceInstance using the provided options. Either UID or Name must be specified. If neither is provided, returns an error.

func GetDevPodVersion

func GetDevPodVersion(url string) (string, error)

func GetProInstanceDevPodVersion

func GetProInstanceDevPodVersion(proInstance *provider.ProInstance) (string, error)

func GetUserName

func GetUserName(self *managementv1.Self) string

func InitClientFromHost

func InitClientFromHost(
	ctx context.Context,
	devPodConfig *config.Config,
	devPodProHost string,
	log log.Logger,
) (client.Client, error)

func InitClientFromProvider

func InitClientFromProvider(
	ctx context.Context,
	devPodConfig *config.Config,
	providerName string,
	log log.Logger,
) (client.Client, error)

func IsOwner

func IsOwner(self *managementv1.Self, userOrTeam *storagev1.UserOrTeam) bool

func LoftConfigPath

func LoftConfigPath(context string, providerName string) (string, error)

func NewInstanceKubeConfig

func NewInstanceKubeConfig(
	ctx context.Context,
	platformOptions *devpod.PlatformOptions,
) ([]byte, error)

NewInstanceKubeConfig creates a KubeConfig (clientcmdapi.Config) based for either a space instance or virtual cluster instance. We return the config as byte slice to ensure correct handling and formatting through the `clientcmd` methods.

func OptionsFromEnv

func OptionsFromEnv(name string) url.Values

func ProviderFromHost

func ProviderFromHost(
	ctx context.Context,
	devPodConfig *config.Config,
	devPodProHost string,
	log log.Logger,
) (string, error)

func ReadConfig

func ReadConfig(contextName string, providerName string) (*client.Config, error)

ReadConfig reads client.Config for given context and provider.

func Timeout

func Timeout() time.Duration

func URLOptions

func URLOptions(options any) url.Values

func UpdateInstance

UpdateInstance diffs two versions of a DevPodWorkspaceInstance, applies changes via a patch to reduce conflicts. Afterwards it waits until the instance is ready to be used.

func WaitForPodReady

func WaitForPodReady(
	ctx context.Context,
	kubeClient kubernetes.Interface,
	namespace string,
	log log.Logger,
) (*corev1.Pod, error)

Types

type FindInstanceOptions added in v0.14.6

type FindInstanceOptions struct {
	// UID searches for an instance by its UID label. Takes precedence over Name.
	UID string
	// Name searches for an instance by its name. Only used if UID is empty.
	Name string
	// Namespace specifies the namespace to search in. If empty and ProjectName is set,
	// the project namespace is used. If both are empty, UID lookup searches all namespaces.
	// Name lookup requires Namespace or ProjectName to avoid ambiguous cross-namespace matches.
	Namespace string
	// ProjectName converts to a project namespace. Ignored if Namespace is explicitly set.
	ProjectName string
}

FindInstanceOptions configures how to find a DevPodWorkspaceInstance.

type OwnerFilter

type OwnerFilter string
const (
	SelfOwnerFilter OwnerFilter = "self"
	AllOwnerFilter  OwnerFilter = "all"
)

func (*OwnerFilter) Set

func (s *OwnerFilter) Set(v string) error

func (*OwnerFilter) String

func (s *OwnerFilter) String() string

func (*OwnerFilter) Type

func (s *OwnerFilter) Type() string

type VersionObject

type VersionObject struct {
	// Version is the server version
	Version string `json:"version,omitempty"`

	// Version is the remote devpod version
	DevPodVersion string `json:"devPodVersion,omitempty"`
}

func GetPlatformVersion

func GetPlatformVersion(url string) (*VersionObject, error)

type WorkspaceInfo

type WorkspaceInfo struct {
	ID          string
	UID         string
	ProjectName string
}

func GetWorkspaceInfoFromEnv

func GetWorkspaceInfoFromEnv() (*WorkspaceInfo, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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