Documentation
¶
Index ¶
- Constants
- Variables
- func BuiltinTemplateLocalIgnores(ref string) []string
- func BuiltinTemplateNames() []string
- func ComputeManifestSHA256(path string) (string, error)
- func DefaultSidecarImageForBinaryVersion(binaryVersion string) string
- func ManifestDir(configPath string) string
- func RenderEmbeddedTemplate(path string, vars *TemplateVars) (string, error)
- func RenderTemplate(ref string, vars *TemplateVars) (string, error)
- func RenderTemplateContext(ctx context.Context, ref string, vars *TemplateVars) (string, error)
- func ResolveLocalAgentPath(path string) (string, error)
- func ResolvePath(configPath string) (string, error)
- func ResolveTemplate(ref string) (string, error)
- func ResolveTemplateContext(ctx context.Context, ref string) (string, error)
- func ResolveWorkloadManifestPath(configPath, manifestPath string) string
- func RootDir(configPath string) string
- func STIgnorePreset(name string) []string
- func UserTemplateNames() ([]string, error)
- type AgentAuth
- type AgentSpec
- type DevEnvSpec
- type DevEnvironment
- type LastAppliedWorkloadSpec
- type LegacyWorkspace
- type LifecycleSpec
- type Metadata
- type MetadataMap
- type Migration
- type MigrationEligibleError
- type MigrationResult
- type PodTemplateRef
- type PortMapping
- type PortVar
- type SSHSpec
- type SessionSpec
- type SidecarSpec
- type SyncSpec
- type SyncthingSpec
- type TemplateVars
- type WorkloadAttachSpec
- type WorkloadInjectSpec
- type WorkloadSpec
Constants ¶
const ( DefaultSyncthingVersion = "v1.29.7" DefaultSyncthingRescanSeconds = 300 DefaultSidecarImageRepository = "ghcr.io/acmore/okdev" DefaultSidecarImageFallback = "edge" DefaultWorkspacePVCSize = "50Gi" )
const ( DefaultWorkspacePath = "/workspace" DefaultWorkspaceName = "workspace" )
const ( PortDirectionForward = "forward" PortDirectionReverse = "reverse" )
const ( DefaultFile = ".okdev.yaml" FolderFile = ".okdev/okdev.yaml" LegacyFile = "okdev.yaml" )
const ( SnapshotVersion = "v1" AnnotationLastAppliedSpec = "okdev.io/last-applied-spec" AnnotationLastAppliedHash = "okdev.io/last-applied-spec-sha256" )
Variables ¶
var DefaultMigrations = []Migration{
workspaceToVolumesMigration(),
pytorchjobWorkerInjectMigration(),
}
DefaultMigrations is the ordered list of all config migrations.
var DefaultSidecarImage = DefaultSidecarImageForBinaryVersion(version.Version)
Functions ¶
func BuiltinTemplateLocalIgnores ¶ added in v0.2.20
func BuiltinTemplateNames ¶ added in v0.2.11
func BuiltinTemplateNames() []string
BuiltinTemplateNames returns the list of available built-in template names.
func ComputeManifestSHA256 ¶ added in v0.4.2
func DefaultSidecarImageForBinaryVersion ¶ added in v0.2.0
func ManifestDir ¶ added in v0.3.5
func RenderEmbeddedTemplate ¶ added in v0.3.1
func RenderEmbeddedTemplate(path string, vars *TemplateVars) (string, error)
func RenderTemplate ¶ added in v0.2.11
func RenderTemplate(ref string, vars *TemplateVars) (string, error)
RenderTemplate resolves a template by ref and renders it with the given vars.
func RenderTemplateContext ¶ added in v0.3.0
RenderTemplateContext resolves a template by ref and renders it with the given vars.
func ResolveLocalAgentPath ¶ added in v0.3.0
func ResolvePath ¶
func ResolveTemplate ¶ added in v0.2.11
ResolveTemplate loads raw template content from a built-in name, file path, or URL.
func ResolveTemplateContext ¶ added in v0.3.0
ResolveTemplateContext loads raw template content from a built-in name, file path, or URL.
func ResolveWorkloadManifestPath ¶ added in v0.3.5
func STIgnorePreset ¶ added in v0.3.0
func UserTemplateNames ¶ added in v0.3.1
Types ¶
type DevEnvSpec ¶
type DevEnvSpec struct {
Namespace string `yaml:"namespace"`
KubeContext string `yaml:"kubeContext"`
Session SessionSpec `yaml:"session"`
Agents []AgentSpec `yaml:"agents,omitempty"`
Workload WorkloadSpec `yaml:"workload"`
Volumes []corev1.Volume `yaml:"volumes"`
Workspace *LegacyWorkspace `yaml:"workspace,omitempty"`
Sync SyncSpec `yaml:"sync"`
Ports []PortMapping `yaml:"ports"`
SSH SSHSpec `yaml:"ssh"`
Lifecycle LifecycleSpec `yaml:"lifecycle"`
Sidecar SidecarSpec `yaml:"sidecar"`
PodTemplate PodTemplateRef `yaml:"podTemplate"`
}
type DevEnvironment ¶
type DevEnvironment struct {
APIVersion string `yaml:"apiVersion"`
Kind string `yaml:"kind"`
Metadata Metadata `yaml:"metadata"`
Spec DevEnvSpec `yaml:"spec"`
}
DevEnvironment is the top-level config structure for .okdev.yaml.
func (*DevEnvironment) EffectiveVolumes ¶ added in v0.2.4
func (d *DevEnvironment) EffectiveVolumes() []corev1.Volume
func (*DevEnvironment) EffectiveWorkspaceMountPath ¶ added in v0.3.4
func (d *DevEnvironment) EffectiveWorkspaceMountPath(configPath string) string
func (*DevEnvironment) SetDefaults ¶
func (d *DevEnvironment) SetDefaults()
func (*DevEnvironment) Validate ¶
func (d *DevEnvironment) Validate() error
func (*DevEnvironment) WorkspaceMountPath ¶ added in v0.2.4
func (d *DevEnvironment) WorkspaceMountPath() string
type LastAppliedWorkloadSpec ¶ added in v0.4.2
type LastAppliedWorkloadSpec struct {
Version string `json:"version"`
WorkloadKind string `json:"workloadKind"`
Workload WorkloadSpec `json:"workload"`
PodTemplate PodTemplateRef `json:"podTemplate"`
Volumes []corev1.Volume `json:"volumes"`
SidecarImage string `json:"sidecarImage"`
WorkspaceMountPath string `json:"workspaceMountPath"`
TargetContainer string `json:"targetContainer"`
Tmux bool `json:"tmux"`
PreStop string `json:"preStop"`
ManifestPath string `json:"manifestPath,omitempty"`
ManifestSHA256 string `json:"manifestSHA256,omitempty"`
}
func BuildWorkloadSnapshot ¶ added in v0.4.2
func BuildWorkloadSnapshot(cfg *DevEnvironment, workspaceMountPath, targetContainer string, tmux bool, preStop, manifestPath, manifestResolvedPath string) LastAppliedWorkloadSpec
func ParseLastAppliedWorkloadSpec ¶ added in v0.4.2
func ParseLastAppliedWorkloadSpec(raw string) (LastAppliedWorkloadSpec, error)
func (*LastAppliedWorkloadSpec) JSON ¶ added in v0.4.2
func (s *LastAppliedWorkloadSpec) JSON() (string, error)
func (*LastAppliedWorkloadSpec) SHA256 ¶ added in v0.4.2
func (s *LastAppliedWorkloadSpec) SHA256() (string, error)
type LegacyWorkspace ¶ added in v0.2.4
type LegacyWorkspace struct {
MountPath string `yaml:"mountPath"`
PVC map[string]string `yaml:"pvc"`
}
LegacyWorkspace exists only to produce a clear migration error for removed config.
type LifecycleSpec ¶ added in v0.2.0
type MetadataMap ¶
type Migration ¶ added in v0.2.11
type Migration struct {
Name string
Description string
Applies func(doc *yaml.Node) bool
Transform func(doc *yaml.Node) (warnings []string, err error)
}
Migration defines a single config transformation.
type MigrationEligibleError ¶ added in v0.2.11
type MigrationEligibleError struct {
Err error
}
MigrationEligibleError wraps validation errors that can be fixed by okdev migrate.
func (*MigrationEligibleError) Error ¶ added in v0.2.11
func (e *MigrationEligibleError) Error() string
func (*MigrationEligibleError) Unwrap ¶ added in v0.2.11
func (e *MigrationEligibleError) Unwrap() error
type MigrationResult ¶ added in v0.2.11
type MigrationResult struct {
Applied []string // names of applied migrations
Warnings []string // warnings from ambiguous transforms
}
MigrationResult holds the outcome of running migrations.
func RunMigrations ¶ added in v0.2.11
func RunMigrations(doc *yaml.Node, migrations []Migration) (*MigrationResult, error)
RunMigrations runs all applicable migrations sequentially. Each migration checks Applies() before running Transform().
type PodTemplateRef ¶
type PodTemplateRef struct {
Metadata MetadataMap `yaml:"metadata"`
Spec corev1.PodSpec `yaml:"spec"`
}
type PortMapping ¶
type PortMapping struct {
Name string `yaml:"name"`
Local int `yaml:"local"`
Remote int `yaml:"remote"`
Direction string `yaml:"direction,omitempty"`
}
func (PortMapping) EffectiveDirection ¶ added in v0.3.0
func (p PortMapping) EffectiveDirection() string
type SSHSpec ¶
type SSHSpec struct {
User string `yaml:"user"`
PrivateKeyPath string `yaml:"privateKeyPath"`
AutoDetectPorts *bool `yaml:"autoDetectPorts"`
PersistentSession *bool `yaml:"persistentSession"`
KeepAliveInterval int `yaml:"keepAliveIntervalSeconds"`
KeepAliveTimeout int `yaml:"keepAliveTimeoutSeconds"`
KeepAliveCountMax int `yaml:"keepAliveCountMax"`
}
func (SSHSpec) PersistentSessionEnabled ¶ added in v0.2.0
type SessionSpec ¶
type SidecarSpec ¶ added in v0.2.0
type SidecarSpec struct {
Image string `yaml:"image"`
}
type SyncSpec ¶
type SyncSpec struct {
Paths []string `yaml:"paths"`
Exclude []string `yaml:"exclude"`
RemoteExclude []string `yaml:"remoteExclude"`
Engine string `yaml:"engine"`
Syncthing SyncthingSpec `yaml:"syncthing"`
}
type SyncthingSpec ¶
type SyncthingSpec struct {
Version string `yaml:"version"`
AutoInstall *bool `yaml:"autoInstall"`
Image string `yaml:"image"`
RescanIntervalSeconds int `yaml:"rescanIntervalSeconds"`
RelaysEnabled bool `yaml:"relaysEnabled"`
Compression bool `yaml:"compression"`
}
func (SyncthingSpec) AutoInstallEnabled ¶
func (s SyncthingSpec) AutoInstallEnabled() bool
type TemplateVars ¶ added in v0.2.11
type TemplateVars struct {
Name string
Namespace string
DevImage string
SidecarImage string
SyncthingVersion string
SyncLocal string
SyncRemote string
SSHUser string
Ports []PortVar
WorkloadType string
ManifestPath string
InjectPaths []string
AttachContainer string
GenericPreset string
TTLHours int
}
TemplateVars holds all variables available to templates.
func NewTemplateVars ¶ added in v0.2.11
func NewTemplateVars() *TemplateVars
NewTemplateVars returns TemplateVars with sensible defaults.
type WorkloadAttachSpec ¶ added in v0.3.0
type WorkloadAttachSpec struct {
Container string `yaml:"container,omitempty"`
}
type WorkloadInjectSpec ¶ added in v0.3.0
type WorkloadSpec ¶ added in v0.3.0
type WorkloadSpec struct {
Type string `yaml:"type"`
ManifestPath string `yaml:"manifestPath,omitempty"`
Inject []WorkloadInjectSpec `yaml:"inject,omitempty"`
Attach WorkloadAttachSpec `yaml:"attach,omitempty"`
}