Documentation
¶
Index ¶
- Constants
- Variables
- func BuiltinTemplateLocalIgnores(ref string) []string
- func BuiltinTemplateNames() []string
- func CoerceVariableValue(v TemplateVariable, raw string) (any, error)
- func ComputeManifestSHA256(path string) (string, error)
- func DefaultSidecarImageForBinaryVersion(binaryVersion string) string
- func ManifestDir(configPath string) string
- func ProjectTemplateNames(dir string) ([]string, error)
- func RenderEmbeddedTemplate(path string, vars *TemplateVars) (string, error)
- func RenderTemplate(ref string, vars *TemplateVars) (string, error)
- func RenderTemplateContent(name, raw string, vars *TemplateVars, customVars map[string]any) (string, error)
- func RenderTemplateContext(ctx context.Context, ref string, vars *TemplateVars) (string, error)
- func RenderTemplateWithVars(ctx context.Context, ref string, vars *TemplateVars, customVars map[string]any, ...) (string, error)
- func ResolveLocalAgentPath(path string) (string, error)
- func ResolvePath(configPath string) (string, error)
- func ResolveTemplate(ref string) (string, error)
- func ResolveTemplateAssetFromDir(ctx context.Context, templateRef, assetRef, projDir string) (string, error)
- func ResolveTemplateContext(ctx context.Context, ref string) (string, error)
- func ResolveTemplateFromDir(ctx context.Context, ref, projDir string) (string, error)
- func ResolveVariables(meta *TemplateMeta, sets map[string]string, stored map[string]any) (map[string]any, 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
- func (d *DevEnvironment) EffectiveVolumes() []corev1.Volume
- func (d *DevEnvironment) EffectiveWorkloadInject() []WorkloadInjectSpec
- func (d *DevEnvironment) EffectiveWorkspaceMountPath(configPath string) string
- func (d *DevEnvironment) SetDefaults()
- func (d *DevEnvironment) Validate() error
- func (d *DevEnvironment) WorkspaceMountPath() string
- 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 TemplateFile
- type TemplateMeta
- type TemplateRef
- type TemplateVariable
- 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 CoerceVariableValue ¶ added in v0.7.0
func CoerceVariableValue(v TemplateVariable, raw string) (any, error)
CoerceVariableValue converts a string value to the declared variable type.
func ComputeManifestSHA256 ¶ added in v0.4.2
func DefaultSidecarImageForBinaryVersion ¶ added in v0.2.0
func ManifestDir ¶ added in v0.3.5
func ProjectTemplateNames ¶ added in v0.7.0
ProjectTemplateNames returns template names found in <dir>/.okdev/templates.
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 RenderTemplateContent ¶ added in v0.7.0
func RenderTemplateContent(name, raw string, vars *TemplateVars, customVars map[string]any) (string, error)
RenderTemplateContent renders raw template content with built-in fields plus custom variables exposed as .Vars.
func RenderTemplateContext ¶ added in v0.3.0
RenderTemplateContext resolves a template by ref and renders it with the given vars.
func RenderTemplateWithVars ¶ added in v0.7.0
func RenderTemplateWithVars(ctx context.Context, ref string, vars *TemplateVars, customVars map[string]any, projDir string) (string, error)
RenderTemplateWithVars resolves and renders a template with built-in fields plus custom variables exposed as .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 ResolveTemplateAssetFromDir ¶ added in v0.7.0
func ResolveTemplateAssetFromDir(ctx context.Context, templateRef, assetRef, projDir string) (string, error)
ResolveTemplateAssetFromDir resolves a companion template asset declared by frontmatter. Relative asset paths are resolved next to the selected template.
func ResolveTemplateContext ¶ added in v0.3.0
ResolveTemplateContext loads raw template content from a built-in name, file path, or URL.
func ResolveTemplateFromDir ¶ added in v0.7.0
ResolveTemplateFromDir resolves a template with project-local directory awareness.
func ResolveVariables ¶ added in v0.7.0
func ResolveVariables(meta *TemplateMeta, sets map[string]string, stored map[string]any) (map[string]any, error)
ResolveVariables resolves template variables from flags, stored values, and defaults.
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"`
Template *TemplateRef `yaml:"template,omitempty"`
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) EffectiveWorkloadInject ¶ added in v0.7.3
func (d *DevEnvironment) EffectiveWorkloadInject() []WorkloadInjectSpec
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"`
SidecarResources corev1.ResourceRequirements `json:"sidecarResources,omitempty"`
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"`
ForwardAgent *bool `yaml:"forwardAgent"`
InterPod *bool `yaml:"interPod"`
PersistentSession *bool `yaml:"persistentSession"`
KeepAliveInterval int `yaml:"keepAliveIntervalSeconds"`
KeepAliveTimeout int `yaml:"keepAliveTimeoutSeconds"`
KeepAliveCountMax int `yaml:"keepAliveCountMax"`
}
func (SSHSpec) ForwardAgentEnabled ¶ added in v0.6.1
func (SSHSpec) InterPodEnabled ¶ added in v0.7.3
func (SSHSpec) PersistentSessionEnabled ¶ added in v0.2.0
type SessionSpec ¶
type SidecarSpec ¶ added in v0.2.0
type SidecarSpec struct {
Image string `yaml:"image"`
Resources corev1.ResourceRequirements `yaml:"resources,omitempty"`
}
type SyncSpec ¶
type SyncSpec struct {
Paths []string `yaml:"paths"`
PreservePaths []string `yaml:"preservePaths"`
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"`
WatcherDelaySeconds int `yaml:"watcherDelaySeconds"`
RelaysEnabled bool `yaml:"relaysEnabled"`
Compression bool `yaml:"compression"`
}
func (SyncthingSpec) AutoInstallEnabled ¶
func (s SyncthingSpec) AutoInstallEnabled() bool
type TemplateFile ¶ added in v0.7.0
TemplateFile declares an additional file rendered by okdev init.
type TemplateMeta ¶ added in v0.7.0
type TemplateMeta struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Variables []TemplateVariable `yaml:"variables"`
Files []TemplateFile `yaml:"files"`
}
TemplateMeta holds optional frontmatter metadata from a template file.
func ParseFrontmatter ¶ added in v0.7.0
func ParseFrontmatter(raw string) (*TemplateMeta, string, error)
ParseFrontmatter extracts YAML frontmatter from a template string.
type TemplateRef ¶ added in v0.7.0
TemplateRef records which template and variable values produced this config.
type TemplateVariable ¶ added in v0.7.0
type TemplateVariable struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Type string `yaml:"type"`
Default any `yaml:"default,omitempty"`
}
TemplateVariable declares a custom variable that a template accepts.
func (TemplateVariable) HasDefault ¶ added in v0.7.0
func (v TemplateVariable) HasDefault() bool
HasDefault returns true when a default value was declared.
type TemplateVars ¶ added in v0.2.11
type TemplateVars struct {
Name string
Namespace string
KubeContext string
User string
Repo string
DevImage string
DevCPURequest string
DevMemoryRequest string
DevCPULimit string
DevMemoryLimit string
SidecarImage string
SidecarCPU string
SidecarMemory 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"`
}