provider

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: MPL-2.0 Imports: 16 Imported by: 6

Documentation

Index

Constants

View Source
const (
	DEVPOD                   = "DEVPOD"
	DEVPOD_OS                = "DEVPOD_OS"
	DEVPOD_ARCH              = "DEVPOD_ARCH"
	WORKSPACE_ID             = "WORKSPACE_ID"
	WORKSPACE_FOLDER         = "WORKSPACE_FOLDER"
	WORKSPACE_CONTEXT        = "WORKSPACE_CONTEXT"
	WORKSPACE_ORIGIN         = "WORKSPACE_ORIGIN"
	WORKSPACE_GIT_REPOSITORY = "WORKSPACE_GIT_REPOSITORY"
	WORKSPACE_GIT_BRANCH     = "WORKSPACE_GIT_BRANCH"
	WORKSPACE_LOCAL_FOLDER   = "WORKSPACE_LOCAL_FOLDER"
	WORKSPACE_IMAGE          = "WORKSPACE_IMAGE"
	WORKSPACE_PROVIDER       = "WORKSPACE_PROVIDER"
	MACHINE_ID               = "MACHINE_ID"
	MACHINE_CONTEXT          = "MACHINE_CONTEXT"
	MACHINE_FOLDER           = "MACHINE_FOLDER"
	MACHINE_PROVIDER         = "MACHINE_PROVIDER"
)
View Source
const (
	DockerDriver     = "docker"
	KubernetesDriver = "kubernetes"
)
View Source
const (
	CommandEnv = "COMMAND"
)
View Source
const MachineConfigFile = "machine.json"
View Source
const ProviderConfigFile = "provider.json"
View Source
const WorkspaceConfigFile = "workspace.json"

Variables

View Source
var ProviderNameRegEx = regexp.MustCompile(`[^a-z0-9\-]+`)

Functions

func CombineOptions

func CombineOptions(workspace *Workspace, machine *Machine, options map[string]config.OptionValue) map[string]config.OptionValue

func GetBaseEnvironment

func GetBaseEnvironment() map[string]string

func GetMachineDir

func GetMachineDir(context, machineID string) (string, error)

func GetMachinesDir

func GetMachinesDir(context string) (string, error)

func GetProviderBinariesDir

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

func GetProviderDir

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

func GetProviderOptions

func GetProviderOptions(workspace *Workspace, server *Machine, devConfig *config.Config) map[string]config.OptionValue

func GetProvidersDir

func GetProvidersDir(context string) (string, error)

func GetWorkspaceDir

func GetWorkspaceDir(context, workspaceID string) (string, error)

func GetWorkspacesDir

func GetWorkspacesDir(context string) (string, error)

func MachineExists

func MachineExists(context, machineID string) bool

func Merge

func Merge(m1 map[string]string, m2 map[string]string) map[string]string

func ParseOptions

func ParseOptions(provider *ProviderConfig, options []string) (map[string]string, error)

func SaveMachineConfig

func SaveMachineConfig(machine *Machine) error

func SaveProviderConfig

func SaveProviderConfig(context string, provider *ProviderConfig) error

func SaveWorkspaceConfig

func SaveWorkspaceConfig(workspace *Workspace) error

func ToEnvironment

func ToEnvironment(workspace *Workspace, machine *Machine, options map[string]config.OptionValue, extraEnv map[string]string) []string

func ToOptions

func ToOptions(workspace *Workspace, machine *Machine, options map[string]config.OptionValue) map[string]string

func ToOptionsMachine

func ToOptionsMachine(machine *Machine) map[string]string

func ToOptionsWorkspace

func ToOptionsWorkspace(workspace *Workspace) map[string]string

func WorkspaceExists

func WorkspaceExists(context, workspaceID string) bool

Types

type AgentWorkspaceInfo

type AgentWorkspaceInfo struct {
	// Workspace holds the workspace info
	Workspace *Workspace `json:"workspace,omitempty"`

	// Machine holds the machine info
	Machine *Machine `json:"machine,omitempty"`

	// Agent holds the agent info
	Agent ProviderAgentConfig `json:"agent,omitempty"`

	// Options holds the filled provider options for this workspace
	Options map[string]config.OptionValue `json:"options,omitempty"`

	// ContentFolder holds the folder where the content is stored
	ContentFolder string `json:"contentFolder,omitempty"`

	// Origin holds the folder where this config was loaded from
	Origin string `json:"-"`
}

type Machine

type Machine struct {
	// ID is the machine id to use
	ID string `json:"id,omitempty"`

	// Folder is the local folder where machine related contents will be stored
	Folder string `json:"folder,omitempty"`

	// Provider is the provider used to create this workspace
	Provider MachineProviderConfig `json:"provider,omitempty"`

	// CreationTimestamp is the timestamp when this workspace was created
	CreationTimestamp types.Time `json:"creationTimestamp,omitempty"`

	// Context is the context where this config file was loaded from
	Context string `json:"context,omitempty"`

	// Origin is the place where this config file was loaded from
	Origin string `json:"-"`
}

func CloneMachine

func CloneMachine(server *Machine) *Machine

func FromEnvironment

func FromEnvironment() *Machine

func LoadMachineConfig

func LoadMachineConfig(context, machineID string) (*Machine, error)

type MachineProviderConfig

type MachineProviderConfig struct {
	// Name is the provider name used to deploy this machine
	Name string `json:"name,omitempty"`

	// Options are the local options that override the global ones
	Options map[string]config.OptionValue `json:"options,omitempty"`
}

type ProviderAgentConfig

type ProviderAgentConfig struct {
	// Path is the binary path inside the server devpod will expect the agent binary
	Path string `json:"path,omitempty"`

	// DataPath is the agent path where data is stored
	DataPath string `json:"dataPath,omitempty"`

	// DownloadURL is the base url where to download the agent from
	DownloadURL string `json:"downloadURL,omitempty"`

	// Timeout is the timeout in minutes to wait until the agent tries
	// to turn of the server.
	Timeout string `json:"inactivityTimeout,omitempty"`

	// ContainerTimeout is the timeout in minutes to wait until the agent tries
	// to delete the container.
	ContainerTimeout string `json:"containerInactivityTimeout,omitempty"`

	// InjectGitCredentials signals DevPod if git credentials should get synced into
	// the remote machine for cloning the repository.
	InjectGitCredentials types.StrBool `json:"injectGitCredentials,omitempty"`

	// InjectDockerCredentials signals DevPod if docker credentials should get synced
	// into the remote machine for pulling and pushing images.
	InjectDockerCredentials types.StrBool `json:"injectDockerCredentials,omitempty"`

	// Exec commands that can be used on the remote
	Exec ProviderAgentConfigExec `json:"exec,omitempty"`

	// Binaries is an optional field to specify a binary to execute the commands
	Binaries map[string][]*ProviderBinary `json:"binaries,omitempty"`

	// Driver is the driver to use for deploying the devcontainer. Currently supports
	// docker (default) or kubernetes (experimental)
	Driver string `json:"driver,omitempty"`

	// Kubernetes holds kubernetes specific configuration
	Kubernetes ProviderKubernetesDriverConfig `json:"kubernetes,omitempty"`

	// Docker holds docker specific configuration
	Docker ProviderDockerDriverConfig `json:"docker,omitempty"`
}

type ProviderAgentConfigExec

type ProviderAgentConfigExec struct {
	// Shutdown is the remote command to run when the remote machine
	// should shutdown.
	Shutdown types.StrArray `json:"shutdown,omitempty"`
}

type ProviderBinary

type ProviderBinary struct {
	// The current OS
	OS string `json:"os,omitempty"`

	// The current Arch
	Arch string `json:"arch,omitempty"`

	// Checksum is the sha256 hash of the binary
	Checksum string `json:"checksum,omitempty"`

	// Path is the binary url to download from or relative path to use
	Path string `json:"path,omitempty"`

	// ArchivePath is the path within the archive to extract
	ArchivePath string `json:"archivePath,omitempty"`

	// Name is the name of the binary to store locally
	Name string `json:"name,omitempty"`
}

type ProviderCommands

type ProviderCommands struct {
	// Init is run directly after `devpod provider use`
	Init types.StrArray `json:"init,omitempty"`

	// Command executes a command on the server
	Command types.StrArray `json:"command,omitempty"`

	// Create creates a new server
	Create types.StrArray `json:"create,omitempty"`

	// Delete destroys a server
	Delete types.StrArray `json:"delete,omitempty"`

	// Start starts a stopped server
	Start types.StrArray `json:"start,omitempty"`

	// Stop stops a running server
	Stop types.StrArray `json:"stop,omitempty"`

	// Status retrieves the server status
	Status types.StrArray `json:"status,omitempty"`
}

type ProviderConfig

type ProviderConfig struct {
	// Name is the name of the provider
	Name string `json:"name,omitempty"`

	// Version is the provider version
	Version string `json:"version,omitempty"`

	// Icon holds an image URL that will be displayed
	Icon string `json:"icon,omitempty"`

	// Home holds the provider home URL
	Home string `json:"home,omitempty"`

	// Source is the source the provider was loaded from
	Source ProviderSource `json:"source,omitempty"`

	// Description is the provider description
	Description string `json:"description,omitempty"`

	// OptionGroups holds information how to display options
	OptionGroups []ProviderOptionGroup `json:"optionGroups,omitempty"`

	// Options are the provider options.
	Options map[string]*ProviderOption `json:"options,omitempty"`

	// Agent allows you to override agent configuration
	Agent ProviderAgentConfig `json:"agent,omitempty"`

	// Exec holds the provider commands
	Exec ProviderCommands `json:"exec,omitempty"`

	// Binaries is an optional field to specify a binary to execute the commands
	Binaries map[string][]*ProviderBinary `json:"binaries,omitempty"`
}

func LoadProviderConfig

func LoadProviderConfig(context, provider string) (*ProviderConfig, error)

func ParseProvider

func ParseProvider(reader io.Reader) (*ProviderConfig, error)

func (*ProviderConfig) IsMachineProvider

func (c *ProviderConfig) IsMachineProvider() bool

type ProviderDockerDriverConfig

type ProviderDockerDriverConfig struct {
	// Path where to find the docker binary, defaults to 'docker'
	Path string `json:"path,omitempty"`

	// If false, DevPod will not try to install docker into the machine.
	Install types.StrBool `json:"install,omitempty"`
}

type ProviderKubernetesDriverConfig

type ProviderKubernetesDriverConfig struct {
	// Path where to find the kubectl binary, defaults to 'kubectl'
	Path string `json:"path,omitempty"`

	// Namespace is the Kubernetes namespace to use
	Namespace string `json:"namespace,omitempty"`

	// CreateNamespace specifies if DevPod should try to create the namespace
	CreateNamespace types.StrBool `json:"createNamespace,omitempty"`

	// Context is the context to use
	Context string `json:"context,omitempty"`

	// Config is the path to the kube config to use
	Config string `json:"config,omitempty"`

	// ClusterRole defines a role binding with the given cluster role
	// DevPod should create.
	ClusterRole string `json:"clusterRole,omitempty"`

	// ServiceAccount is the service account to use
	ServiceAccount string `json:"serviceAccount,omitempty"`

	// BuildRepository defines the repository to push builds. If empty,
	// DevPod will not try to build any images at all.
	BuildRepository string `json:"buildRepository,omitempty"`

	// BuildkitImage is the build kit image to use
	BuildkitImage string `json:"buildkitImage,omitempty"`

	// BuildkitPrivileged signals if pod should be ran in privileged mode
	BuildkitPrivileged types.StrBool `json:"buildkitPrivileged,omitempty"`

	// HelperImage is used to find out cluster architecture and copy files
	HelperImage string `json:"helperImage,omitempty"`

	// PersistentVolumeSize is the size of the persistent volume in GB
	PersistentVolumeSize string `json:"persistentVolumeSize,omitempty"`
}

type ProviderOption

type ProviderOption struct {
	// A description of the option displayed to the user by a supporting tool.
	Description string `json:"description,omitempty"`

	// If required is true and the user doesn't supply a value, devpod will ask the user
	Required bool `json:"required,omitempty"`

	// If true, will not show the value to the user
	Password bool `json:"password,omitempty"`

	// Type is the provider option type. Can be one of: string, duration, number or boolean. Defaults to string
	Type string `json:"type,omitempty"`

	// ValidationPattern is a regex pattern to validate the value
	ValidationPattern string `json:"validationPattern,omitempty"`

	// ValidationMessage is the message that appears if the user enters an invalid option
	ValidationMessage string `json:"validationMessage,omitempty"`

	// Suggestions are suggestions to show in the DevPod UI for this option
	Suggestions []string `json:"suggestions,omitempty"`

	// Allowed values for this option.
	Enum []string `json:"enum,omitempty"`

	// Hidden specifies if the option should be hidden
	Hidden bool `json:"hidden,omitempty"`

	// Local means the variable is not resolved immediately and instead later when the workspace / machine was created.
	Local bool `json:"local,omitempty"`

	// Global means the variable is stored globally. By default, option values will be
	// saved per machine or workspace instead.
	Global bool `json:"global,omitempty"`

	// Default value if the user omits this option from their configuration.
	Default string `json:"default,omitempty"`

	// Cache is the duration to cache the value before rerunning the command
	Cache string `json:"cache,omitempty"`

	// Command is the command to run to specify an option
	Command string `json:"command,omitempty"`
}

type ProviderOptionGroup

type ProviderOptionGroup struct {
	// Name is the display name of the option group
	Name string `json:"name,omitempty"`

	// Options are the options that belong to this group
	Options []string `json:"options,omitempty"`

	// DefaultVisible defines if the option group should be visible by default
	DefaultVisible bool `json:"defaultVisible,omitempty"`
}

type ProviderSource

type ProviderSource struct {
	// Internal means provider was received internally
	Internal bool `json:"internal,omitempty"`

	// Github source for the provider
	Github string `json:"github,omitempty"`

	// File source for the provider
	File string `json:"file,omitempty"`

	// URL where the provider was downloaded from
	URL string `json:"url,omitempty"`
}

type Workspace

type Workspace struct {
	// ID is the workspace id to use
	ID string `json:"id,omitempty"`

	// UID is used to identify this specific workspace
	UID string `json:"uid,omitempty"`

	// Folder is the local folder where workspace related contents will be stored
	Folder string `json:"folder,omitempty"`

	// Picture is the project social media image
	Picture string `json:"picture,omitempty"`

	// Provider is the provider used to create this workspace
	Provider WorkspaceProviderConfig `json:"provider,omitempty"`

	// Machine is the machine to use for this workspace
	Machine WorkspaceMachineConfig `json:"machine,omitempty"`

	// IDE holds IDE specific settings
	IDE WorkspaceIDEConfig `json:"ide,omitempty"`

	// Source is the source where this workspace will be created from
	Source WorkspaceSource `json:"source,omitempty"`

	// DevContainerPath is the relative path where the devcontainer.json is located.
	DevContainerPath string `json:"devContainerPath,omitempty"`

	// CreationTimestamp is the timestamp when this workspace was created
	CreationTimestamp types.Time `json:"creationTimestamp,omitempty"`

	// LastUsedTimestamp holds the timestamp when this workspace was last accessed
	LastUsedTimestamp types.Time `json:"lastUsed,omitempty"`

	// Context is the context where this config file was loaded from
	Context string `json:"context,omitempty"`

	// Origin is the place where this config file was loaded from
	Origin string `json:"-"`
}

func CloneWorkspace

func CloneWorkspace(workspace *Workspace) *Workspace

func LoadWorkspaceConfig

func LoadWorkspaceConfig(context, workspaceID string) (*Workspace, error)

type WorkspaceIDEConfig

type WorkspaceIDEConfig struct {
	// Name is the name of the IDE
	Name string `json:"name,omitempty"`

	// Options are the local options that override the global ones
	Options map[string]config.OptionValue `json:"options,omitempty"`
}

type WorkspaceMachineConfig

type WorkspaceMachineConfig struct {
	// ID is the machine ID to use for this workspace
	ID string `json:"machineId,omitempty"`

	// AutoDelete specifies if the machine should get destroyed when
	// the workspace is destroyed
	AutoDelete bool `json:"autoDelete,omitempty"`
}

type WorkspaceProviderConfig

type WorkspaceProviderConfig struct {
	// Name is the provider name
	Name string `json:"name,omitempty"`

	// Options are the local options that override the global ones
	Options map[string]config.OptionValue `json:"options,omitempty"`
}

type WorkspaceSource

type WorkspaceSource struct {
	// GitRepository is the repository to clone
	GitRepository string `json:"gitRepository,omitempty"`

	// GitBranch is the branch to use
	GitBranch string `json:"gitBranch,omitempty"`

	// LocalFolder is the local folder to use
	LocalFolder string `json:"localFolder,omitempty"`

	// Image is the docker image to use
	Image string `json:"image,omitempty"`
}

func (WorkspaceSource) String

func (w WorkspaceSource) String() string

Jump to

Keyboard shortcuts

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