config

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSyncthingVersion       = "v1.29.7"
	DefaultSyncthingRescanSeconds = 300
	DefaultSidecarImageRepository = "ghcr.io/acmore/okdev"
	DefaultSidecarImageFallback   = "edge"
	DefaultWorkspacePVCSize       = "50Gi"
)
View Source
const (
	DefaultWorkspacePath = "/workspace"
	DefaultWorkspaceName = "workspace"
)
View Source
const (
	PortDirectionForward = "forward"
	PortDirectionReverse = "reverse"
)
View Source
const (
	DefaultFile = ".okdev.yaml"
	FolderFile  = ".okdev/okdev.yaml"
	LegacyFile  = "okdev.yaml"
)
View Source
const (
	SnapshotVersion           = "v1"
	AnnotationLastAppliedSpec = "okdev.io/last-applied-spec"
	AnnotationLastAppliedHash = "okdev.io/last-applied-spec-sha256"
)

Variables

View Source
var DefaultMigrations = []Migration{
	workspaceToVolumesMigration(),
	pytorchjobWorkerInjectMigration(),
}

DefaultMigrations is the ordered list of all config migrations.

Functions

func BuiltinTemplateLocalIgnores added in v0.2.20

func BuiltinTemplateLocalIgnores(ref string) []string

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 ComputeManifestSHA256(path string) (string, error)

func DefaultSidecarImageForBinaryVersion added in v0.2.0

func DefaultSidecarImageForBinaryVersion(binaryVersion string) string

func ManifestDir added in v0.3.5

func ManifestDir(configPath string) string

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

func RenderTemplateContext(ctx context.Context, ref string, vars *TemplateVars) (string, error)

RenderTemplateContext resolves a template by ref and renders it with the given vars.

func ResolveLocalAgentPath added in v0.3.0

func ResolveLocalAgentPath(path string) (string, error)

func ResolvePath

func ResolvePath(configPath string) (string, error)

func ResolveTemplate added in v0.2.11

func ResolveTemplate(ref string) (string, error)

ResolveTemplate loads raw template content from a built-in name, file path, or URL.

func ResolveTemplateContext added in v0.3.0

func ResolveTemplateContext(ctx context.Context, ref string) (string, error)

ResolveTemplateContext loads raw template content from a built-in name, file path, or URL.

func ResolveWorkloadManifestPath added in v0.3.5

func ResolveWorkloadManifestPath(configPath, manifestPath string) string

func RootDir added in v0.3.4

func RootDir(configPath string) string

func STIgnorePreset added in v0.3.0

func STIgnorePreset(name string) []string

func UserTemplateNames added in v0.3.1

func UserTemplateNames() ([]string, error)

Types

type AgentAuth added in v0.3.0

type AgentAuth struct {
	Env       string `yaml:"env,omitempty"`
	LocalPath string `yaml:"localPath,omitempty"`
}

type AgentSpec added in v0.3.0

type AgentSpec struct {
	Name string     `yaml:"name"`
	Auth *AgentAuth `yaml:"auth,omitempty"`
}

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 Load

func Load(configPath string) (*DevEnvironment, string, error)

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 LifecycleSpec struct {
	PostCreate string `yaml:"postCreate"`
	PostSync   string `yaml:"postSync"`
	PreStop    string `yaml:"preStop"`
}

type Metadata

type Metadata struct {
	Name string `yaml:"name"`
}

type MetadataMap

type MetadataMap struct {
	Labels map[string]string `yaml:"labels"`
}

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 PortVar added in v0.2.11

type PortVar struct {
	Name   string
	Local  int
	Remote int
}

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

func (s SSHSpec) PersistentSessionEnabled() bool

type SessionSpec

type SessionSpec struct {
	DefaultNameTemplate string `yaml:"defaultNameTemplate"`
	TTLHours            int    `yaml:"ttlHours"`
	IdleTimeoutMinutes  int    `yaml:"idleTimeoutMinutes"`
	Shareable           bool   `yaml:"shareable"`
}

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 WorkloadInjectSpec struct {
	Path       string `yaml:"path,omitempty"`
	Sidecar    *bool  `yaml:"sidecar,omitempty"`
	Attachable *bool  `yaml:"attachable,omitempty"`
}

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"`
}

Jump to

Keyboard shortcuts

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