setup

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2025 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoCommandsToExecute = errors.New("no commands to execute")

Functions

func GenerateJSONSchema

func GenerateJSONSchema() ([]byte, error)

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

func SaveSchemaToFile

func SaveSchemaToFile(filename string) error

func Validate

func Validate(config *SetupConfig) error

Types

type APIClientInterface

type APIClientInterface interface {
	GetSecret(orgSlug, projectSlug, secretKey string) (*types.SecretWithValue, error)
	GetWrappedProjectKey(orgSlug, projectSlug string) (string, error)
}

type ActionFactory

type ActionFactory struct{}

func NewActionFactory

func NewActionFactory() *ActionFactory

func (*ActionFactory) BuildFromStep

func (f *ActionFactory) BuildFromStep(step *Step) (actions.Action, error)

type AptInstall

type AptInstall struct {
	Packages []string `yaml:"packages" json:"packages"`
	Update   bool     `yaml:"update,omitempty" json:"update,omitempty"`
}

type AssertHTTP

type AssertHTTP struct {
	URL          string   `yaml:"url" json:"url"`
	ExpectStatus int      `yaml:"expect_status,omitempty" json:"expect_status,omitempty"`
	Retries      *Retries `yaml:"retries,omitempty" json:"retries,omitempty"`
}

type BrewInstall

type BrewInstall struct {
	Formula string `yaml:"formula" json:"formula"`
}

type ChocoInstall

type ChocoInstall struct {
	Packages []string `yaml:"packages" json:"packages"`
}

type CommandExecutor

type CommandExecutor interface {
	Execute(ctx context.Context, req *CommandRequest) error
}

func NewRealCommandExecutor

func NewRealCommandExecutor() CommandExecutor

type CommandRequest

type CommandRequest struct {
	Command    string
	Args       []string
	Env        map[string]string
	WorkingDir string
	Timeout    time.Duration
}

type ConditionEvaluator

type ConditionEvaluator struct {
	OS   string
	Arch string
	Env  map[string]string
}

func NewConditionEvaluator

func NewConditionEvaluator(os, arch string, env map[string]string) *ConditionEvaluator

func (*ConditionEvaluator) Evaluate

func (e *ConditionEvaluator) Evaluate(condition string) (bool, error)

func (*ConditionEvaluator) ShouldExecuteStep

func (e *ConditionEvaluator) ShouldExecuteStep(step *Step) (bool, error)

type Context

type Context struct {
	OS         string
	Arch       string
	WorkingDir string
	Secrets    map[string]string
}

func NewContext

func NewContext() (*Context, error)

func (*Context) ShouldExecuteStep

func (c *Context) ShouldExecuteStep(step *Step) (bool, error)

func (*Context) WithSecrets

func (c *Context) WithSecrets(secrets map[string]string) *Context

func (*Context) WithWorkingDir

func (c *Context) WithWorkingDir(dir string) (*Context, error)

type Defaults

type Defaults struct {
	Timeout         string `yaml:"timeout,omitempty" json:"timeout,omitempty"`
	Shell           string `yaml:"shell,omitempty" json:"shell,omitempty"`
	ContinueOnError bool   `yaml:"continue_on_error,omitempty" json:"continue_on_error,omitempty"`
	CWD             string `yaml:"cwd,omitempty" json:"cwd,omitempty"`
}

type EnsureDatabase

type EnsureDatabase struct {
	Engine        string   `yaml:"engine" json:"engine"`
	Version       string   `yaml:"version,omitempty" json:"version,omitempty"`
	ServiceName   string   `yaml:"service_name,omitempty" json:"service_name,omitempty"`
	EnsureRunning bool     `yaml:"ensure_running,omitempty" json:"ensure_running,omitempty"`
	CreateDB      []string `yaml:"create_db,omitempty" json:"create_db,omitempty"`
}

type EnsurePackageManager

type EnsurePackageManager struct {
	Type string `yaml:"type" json:"type"`
}

type EnsureRuntime

type EnsureRuntime struct {
	Name               string                     `yaml:"name" json:"name"`
	Version            string                     `yaml:"version,omitempty" json:"version,omitempty"`
	Manager            *RuntimeManager            `yaml:"manager,omitempty" json:"manager,omitempty"`
	FallbackInstallers []RuntimeFallbackInstaller `yaml:"fallback_installers,omitempty"`
}

type EnsureTool

type EnsureTool struct {
	Name    string             `yaml:"name" json:"name"`
	Version string             `yaml:"version,omitempty" json:"version,omitempty"`
	Install *ToolInstallConfig `yaml:"install,omitempty" json:"install,omitempty"`
}

type Environment

type Environment struct {
	Vars    map[string]string `yaml:",inline" json:",inline"`
	Secrets []string          `yaml:"secrets,omitempty" json:"secrets,omitempty"`
}

type ExecutableCommand

type ExecutableCommand struct {
	Phase           string
	StepName        string
	StepIndex       int
	Command         string
	Args            []string
	Env             map[string]string
	WorkingDir      string
	Timeout         time.Duration
	Description     string
	Retries         *RetryPolicy
	ContinueOnError bool
}

type ExecutionPlan

type ExecutionPlan struct {
	Commands []ExecutableCommand
	Summary  ExecutionSummary
}

func Render

func Render(config *SetupConfig, ctx *RenderContext) (*ExecutionPlan, error)

type ExecutionSummary

type ExecutionSummary struct {
	TotalSteps    int
	TotalCommands int
	Phases        []PhaseSummary
}

type Executor

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

func NewExecutor

func NewExecutor(secrets map[string]string) *Executor

func NewExecutorWithCommandExecutor

func NewExecutorWithCommandExecutor(secrets map[string]string, executor CommandExecutor) *Executor

func (*Executor) Execute

func (e *Executor) Execute(plan *ExecutionPlan) error

type Matrix

type Matrix struct {
	OS   []string `yaml:"os,omitempty" json:"os,omitempty"`
	Arch []string `yaml:"arch,omitempty" json:"arch,omitempty"`
}

type MatrixMatcher

type MatrixMatcher struct {
	OS   string
	Arch string
}

func NewMatrixMatcher

func NewMatrixMatcher() *MatrixMatcher

func (*MatrixMatcher) GetCurrentPlatform

func (m *MatrixMatcher) GetCurrentPlatform() string

func (*MatrixMatcher) GetSupportedPlatforms

func (m *MatrixMatcher) GetSupportedPlatforms(config *SetupConfig) []string

func (*MatrixMatcher) IsCurrentPlatformSupported

func (m *MatrixMatcher) IsCurrentPlatformSupported(config *SetupConfig) (bool, error)

func (*MatrixMatcher) Matches

func (m *MatrixMatcher) Matches(config *SetupConfig) (bool, error)

type ParsedDuration

type ParsedDuration struct {
	Duration time.Duration
	Original string
}

type ParsedRetries

type ParsedRetries struct {
	Attempts int
	Backoff  time.Duration
	Original Retries
}

type Phase

type Phase struct {
	Name  string
	Steps []Step
}

func GetAllPhases

func GetAllPhases(config *SetupConfig) []Phase

type PhaseSummary

type PhaseSummary struct {
	Name         string
	StepCount    int
	CommandCount int
}

type RenderContext

type RenderContext struct {
	OS                     string
	Arch                   string
	WorkingDir             string
	Shell                  string
	Secrets                map[string]string
	GlobalEnv              map[string]string
	DefaultTimeout         time.Duration
	DefaultContinueOnError bool
}

type Retries

type Retries struct {
	Attempts int    `yaml:"attempts" json:"attempts"`
	Backoff  string `yaml:"backoff" json:"backoff"`
}

type RetryPolicy

type RetryPolicy struct {
	Attempts int
	Backoff  time.Duration
}

func ParseRetryPolicy

func ParseRetryPolicy(retries *Retries) *RetryPolicy

type RuntimeFallbackInstaller

type RuntimeFallbackInstaller struct {
	Brew  *BrewInstall  `yaml:"brew,omitempty" json:"brew,omitempty"`
	Apt   *AptInstall   `yaml:"apt,omitempty" json:"apt,omitempty"`
	Choco *ChocoInstall `yaml:"choco,omitempty" json:"choco,omitempty"`
}

type RuntimeManager

type RuntimeManager struct {
	Asdf bool `yaml:"asdf,omitempty" json:"asdf,omitempty"`
}

type SetupConfig

type SetupConfig struct {
	Version     int          `yaml:"version" json:"version"`
	Name        string       `yaml:"name,omitempty" json:"name,omitempty"`
	Description string       `yaml:"description,omitempty" json:"description,omitempty"`
	Matrix      *Matrix      `yaml:"matrix,omitempty" json:"matrix,omitempty"`
	Defaults    *Defaults    `yaml:"defaults,omitempty" json:"defaults,omitempty"`
	Env         *Environment `yaml:"env,omitempty" json:"env,omitempty"`
	Bootstrap   []Step       `yaml:"bootstrap,omitempty" json:"bootstrap,omitempty"`
	Provision   []Step       `yaml:"provision,omitempty" json:"provision,omitempty"`
	Setup       []Step       `yaml:"setup,omitempty" json:"setup,omitempty"`
	Verify      []Step       `yaml:"verify,omitempty" json:"verify,omitempty"`
	Post        []Step       `yaml:"post,omitempty" json:"post,omitempty"`
}

func Parse

func Parse(data []byte) (*SetupConfig, error)

func ParseFile

func ParseFile(filename string) (*SetupConfig, error)

func ParseFromReader

func ParseFromReader(reader io.Reader) (*SetupConfig, error)

type SetupRunner

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

func NewSetupRunner

func NewSetupRunner(projectCtx *config.ProjectContext) *SetupRunner

func NewSetupRunnerWithDeps

func NewSetupRunnerWithDeps(
	projectCtx *config.ProjectContext,
	store StorageInterface,
	apiClient APIClientInterface,
) *SetupRunner

func (*SetupRunner) Run

func (r *SetupRunner) Run(config *SetupConfig) error

type Step

type Step struct {
	Name            string            `yaml:"name,omitempty" json:"name,omitempty"`
	If              string            `yaml:"if,omitempty" json:"if,omitempty"`
	Timeout         string            `yaml:"timeout,omitempty" json:"timeout,omitempty"`
	CWD             string            `yaml:"cwd,omitempty" json:"cwd,omitempty"`
	Env             map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
	EnvFromSecrets  []string          `yaml:"env_from_secrets,omitempty" json:"env_from_secrets,omitempty"`
	OptionalSecrets bool              `yaml:"optional_secrets,omitempty" json:"optional_secrets,omitempty"`
	ContinueOnError bool              `yaml:"continue_on_error,omitempty" json:"continue_on_error,omitempty"`
	Retries         *Retries          `yaml:"retries,omitempty" json:"retries,omitempty"`

	Run                  string                `yaml:"run,omitempty" json:"run,omitempty"`
	Print                string                `yaml:"print,omitempty" json:"print,omitempty"`
	EnsurePackageManager *EnsurePackageManager `yaml:"ensure_package_manager,omitempty"`
	EnsureTool           *EnsureTool           `yaml:"ensure_tool,omitempty" json:"ensure_tool,omitempty"`
	EnsureRuntime        *EnsureRuntime        `yaml:"ensure_runtime,omitempty" json:"ensure_runtime,omitempty"`
	EnsureDatabase       *EnsureDatabase       `yaml:"ensure_database,omitempty" json:"ensure_database,omitempty"`
	AssertCommand        string                `yaml:"assert_command,omitempty" json:"assert_command,omitempty"`
	AssertHTTP           *AssertHTTP           `yaml:"assert_http,omitempty" json:"assert_http,omitempty"`
}

type StorageInterface

type StorageInterface interface {
	HasDeviceID() bool
	GetEncryptionPrivateKey() ([]byte, error)
}

type ToolInstallConfig

type ToolInstallConfig struct {
	Brew        *BrewInstall  `yaml:"brew,omitempty" json:"brew,omitempty"`
	Apt         *AptInstall   `yaml:"apt,omitempty" json:"apt,omitempty"`
	Choco       *ChocoInstall `yaml:"choco,omitempty" json:"choco,omitempty"`
	FallbackURL string        `yaml:"fallback_url,omitempty" json:"fallback_url,omitempty"`
	Checksum    string        `yaml:"checksum,omitempty" json:"checksum,omitempty"`
}

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

func (ValidationError) Error

func (e ValidationError) Error() string

type ValidationErrors

type ValidationErrors []ValidationError

func (ValidationErrors) Error

func (e ValidationErrors) Error() string

Jump to

Keyboard shortcuts

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