Help us shape the future of Go! Take the 2026 Go Developer Survey

platform

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 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  = "DEVSY_CONFIG"
	ProjectEnv = "DEVSY_PROJECT"
	ClusterEnv = "DEVSY_CLUSTER"
	RunnerEnv  = "DEVSY_RUNNER"

	TemplateOptionEnv        = "DEVSY_TEMPLATE"
	TemplateVersionOptionEnv = "DEVSY_TEMPLATE_VERSION"

	TimeoutEnv        = "DEVSY_TIMEOUT"
	ProviderBinaryEnv = "PRO_PROVIDER"

	SpaceInstanceNameEnv          = "DEVSY_SPACE_INSTANCE_NAME"
	VirtualClusterInstanceNameEnv = "DEVSY_VIRTUAL_CLUSTER_INSTANCE_NAME"
	InstanceNamespaceEnv          = "DEVSY_INSTANCE_NAMESPACE"

	DaemonFolderEnv = "DAEMON_FOLDER"
)
View Source
const (
	DevsyPlatformConfigFileName string = "devsy-config.json"
)

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 DevsyConfigPath

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

func DialInstance

func DialInstance(
	baseClient client.Client,
	workspace *managementv1.DevsyWorkspaceInstance,
	subResource string,
	values url.Values,
) (*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.DevsyWorkspaceInstance, error)

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

func GetDevsyVersion

func GetDevsyVersion(url string) (string, error)

func GetProInstanceDevsyVersion

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

func GetUserName

func GetUserName(self *managementv1.Self) string

func InitClientFromHost

func InitClientFromHost(
	ctx context.Context,
	devsyConfig *config.Config,
	devsyProHost string,
) (client.Client, error)

func InitClientFromProvider

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

func IsOwner

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

func NewInstanceKubeConfig

func NewInstanceKubeConfig(
	ctx context.Context,
	platformOptions *devsy.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,
	devsyConfig *config.Config,
	devsyProHost string,
) (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 DevsyWorkspaceInstance, 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,
) (*corev1.Pod, error)

Types

type FindInstanceOptions

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

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 devsy version
	DevsyVersion string `json:"devsyVersion,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