model

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DothFileLocation = "./doth.yaml"
View Source
const DothFileLocationAlt = "./doth.yml"
View Source
const DothLockFileLocation = "./doth.lock"
View Source
const DothShWrapperLocation = "./doth.sh"
View Source
const GitignoreFileLocation = "./.gitignore"
View Source
const LocalStateDir = "./.doth"
View Source
const ModuleFileName = "module.yaml"
View Source
const ModuleFileNameAlt = "module.yml"

Variables

View Source
var DothFileTemplate string
View Source
var DothShWrapper string
View Source
var GitignoreFileTemplate string
View Source
var Version string

Functions

func LoadConfigFileFromPath

func LoadConfigFileFromPath[T any](path string) (*T, error)

Types

type ConfigMap

type ConfigMap map[string]any

func LoadConfigFiles

func LoadConfigFiles(paths []string) (ConfigMap, error)

func (ConfigMap) GetPackageConfig

func (configMap ConfigMap) GetPackageConfig() (*PackageConfig, error)

type ConfirmStep

type ConfirmStep struct {
	// contains filtered or unexported fields
}

func (*ConfirmStep) Apply

func (s *ConfirmStep) Apply(config PipelineConfig) error

func (*ConfirmStep) ApplyDry

func (s *ConfirmStep) ApplyDry(config PipelineConfig) (string, error)

type CopyFileStep

type CopyFileStep struct {
	// contains filtered or unexported fields
}

func (*CopyFileStep) Apply

func (s *CopyFileStep) Apply(config PipelineConfig) error

func (*CopyFileStep) ApplyDry

func (s *CopyFileStep) ApplyDry(config PipelineConfig) (string, error)

type CreateDirIfNotExistsStep

type CreateDirIfNotExistsStep struct {
	// contains filtered or unexported fields
}

func (*CreateDirIfNotExistsStep) Apply

func (*CreateDirIfNotExistsStep) ApplyDry

func (s *CreateDirIfNotExistsStep) ApplyDry(config PipelineConfig) (string, error)

type CreateDirStep

type CreateDirStep struct {
	// contains filtered or unexported fields
}

func (*CreateDirStep) Apply

func (s *CreateDirStep) Apply(config PipelineConfig) error

func (*CreateDirStep) ApplyDry

func (s *CreateDirStep) ApplyDry(config PipelineConfig) (string, error)

type CreateFileStep

type CreateFileStep struct {
	// contains filtered or unexported fields
}

func (*CreateFileStep) Apply

func (s *CreateFileStep) Apply(config PipelineConfig) error

func (*CreateFileStep) ApplyDry

func (s *CreateFileStep) ApplyDry(config PipelineConfig) (string, error)

type CreateSymlinkStep

type CreateSymlinkStep struct {
	// contains filtered or unexported fields
}

func (*CreateSymlinkStep) Apply

func (s *CreateSymlinkStep) Apply(config PipelineConfig) error

func (*CreateSymlinkStep) ApplyDry

func (s *CreateSymlinkStep) ApplyDry(config PipelineConfig) (string, error)

type Dependency

type Dependency struct {
	Name string `yaml:"name"`

	// a map of source -> package name.
	// sources are provided by the user
	Packages map[string]string `yaml:"packages"`
}

type DothFile

type DothFile struct {
	// Relative path to the module directory, e.g. "./modules" or "."
	ModulePath string `yaml:"modulePath"`

	Deps []Dependency `yaml:"deps"`

	RequireConfig bool `yaml:"requireConfig"`

	// Version of doth used. Incompable versions will cause an error on load.
	// There are automatic migrations from older->newer, but not the other way around.
	DothFormatVersion uint32 `yaml:"dothVersionDoNotEditManually"`
}

func LoadDothFileFromCwd

func LoadDothFileFromCwd() (*DothFile, error)

type ExecuteShellCommandStep

type ExecuteShellCommandStep struct {
	// contains filtered or unexported fields
}

func (*ExecuteShellCommandStep) Apply

func (s *ExecuteShellCommandStep) Apply(config PipelineConfig) error

func (*ExecuteShellCommandStep) ApplyDry

func (s *ExecuteShellCommandStep) ApplyDry(config PipelineConfig) (string, error)

type FileStrategy

type FileStrategy string
const (
	StrategyCopy   FileStrategy = "copy"
	StrategyLink   FileStrategy = "link"
	StrategyRender FileStrategy = "render"
)

type LogStep

type LogStep struct {
	// contains filtered or unexported fields
}

func (*LogStep) Apply

func (s *LogStep) Apply(config PipelineConfig) error

func (*LogStep) ApplyDry

func (s *LogStep) ApplyDry(config PipelineConfig) (string, error)

type Module

type Module struct {
	Target string       `yaml:"target"`
	Skip   bool         `yaml:"skip"` // if true, the module will be fully ignored when deploying
	Files  []ModuleFile `yaml:"files"`
	Deps   []Dependency `yaml:"deps"`

	BasePath string `yaml:"-"` // module path on disk, dynamically set when loading
}

type ModuleFile

type ModuleFile struct {
	// Name is the filename or relative path to the file within the module folder - may use glob patterns
	Name string `yaml:"name"`
	// Strategy is the strategy to use when deploying the file to it's target location. Defaults to "copy".
	Strategy       FileStrategy `yaml:"strategy"`
	TargetOverride string       `yaml:"target"` // if set, this path will be used instead of the default target path (module target + file name)
}

type PackageConfig

type PackageConfig struct {
	/**
	PackageSources is a list of package managers available on the target system.
	Use {package} as a placeholder for the package name (and version if needed) in the command.
	If multiple sources are valid for a package, the first one found will be used.

	Example configuration:

	packageSources:
	  - name: "pacman"
	    command: "sudo pacman -S {package}"
	  - name: "paru"
	    command: "paru -S {package}"
	  - name: "go"
	    command: "go install {package}"
	  - name: "npm"
	    command: "npm install -g {package}"

	*/
	PackageSources []PackageSource `yaml:"packageSources"`
}

type PackageSource

type PackageSource struct {
	Name    string `yaml:"name"`
	Command string `yaml:"command"`
}

type Pipeline

type Pipeline struct {
	// contains filtered or unexported fields
}

Pipeline represents a planned sequence of small operations. It can apply them, or print out what it would do (dry run), or print out what it is doing as it does it (verbose).

func NewPipeline

func NewPipeline() *Pipeline

func (*Pipeline) AddModule

func (p *Pipeline) AddModule(module PipelineModule) *Pipeline

func (*Pipeline) Apply

func (p *Pipeline) Apply(input PipelineConfig) error

func (*Pipeline) ApplyDry

func (p *Pipeline) ApplyDry(input PipelineConfig) error

func (*Pipeline) ApplyVerbose

func (p *Pipeline) ApplyVerbose(input PipelineConfig) error

func (*Pipeline) Run

func (p *Pipeline) Run(dry bool, verbose bool, config PipelineConfig) error

type PipelineConfig

type PipelineConfig interface {
	ForceOperations() bool
	Autoconfirm() bool
}

func CreatePipelineConfig

func CreatePipelineConfig(force bool, autoconfirm bool) PipelineConfig

type PipelineModule

type PipelineModule interface {
	Apply(input PipelineConfig) error
	ApplyDry(input PipelineConfig) (string, error)
}

PipelineModule represents a single operation that can be applied, or printed out in a dry run.

func NewConfirmStep

func NewConfirmStep(message string) PipelineModule

func NewCopyFileStep

func NewCopyFileStep(src string, dst string) PipelineModule

func NewCreateDirIfNotExistsStep

func NewCreateDirIfNotExistsStep(path string, role string) PipelineModule

func NewCreateDirStep

func NewCreateDirStep(path string, role string) PipelineModule

func NewCreateFileStep

func NewCreateFileStep(path string, content []byte, role string) PipelineModule

func NewCreateFileStepWithPermissions

func NewCreateFileStepWithPermissions(path string, content []byte, role string, permissions os.FileMode) PipelineModule

func NewCreateSymlinkStep

func NewCreateSymlinkStep(src string, dst string) PipelineModule

func NewExecuteShellCommandStep

func NewExecuteShellCommandStep(command string, silent bool) PipelineModule

func NewLogStep

func NewLogStep(message string, dryOnly bool) PipelineModule

func NewRenderFileStep

func NewRenderFileStep(templatePath string, configMap ConfigMap, dst string) PipelineModule

type RenderFileStep

type RenderFileStep struct {
	// contains filtered or unexported fields
}

func (*RenderFileStep) Apply

func (s *RenderFileStep) Apply(config PipelineConfig) error

func (*RenderFileStep) ApplyDry

func (s *RenderFileStep) ApplyDry(config PipelineConfig) (string, error)

Jump to

Keyboard shortcuts

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