config

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const RuntimeComposeOverrideName = "docker-compose.override.yml"

Variables

View Source
var ErrContextNotFound = errors.New("context not found")

Functions

func ConfigFilePath

func ConfigFilePath() string

func ContextExists

func ContextExists(name string) (bool, error)

func Current

func Current() (string, error)

func GetDefaultLocalDockerSocket

func GetDefaultLocalDockerSocket(dockerSocket string) string

for local contexts, try a bunch of common paths grab the docker socket this is mostly needed for Mac OS

func GetInput

func GetInput(question ...string) (string, error)

func IsDockerSocketAlive added in v0.9.0

func IsDockerSocketAlive(socket string) bool

func LooksLikeComposeProject added in v0.9.0

func LooksLikeComposeProject(projectDir string) bool

func ResolveCurrentContextName added in v0.9.0

func ResolveCurrentContextName(f *pflag.FlagSet) (string, error)

func Save

func Save(cfg *Config) error

func SaveContext

func SaveContext(ctx *Context, setDefault bool) error

func SetCommandFlags

func SetCommandFlags(flags *pflag.FlagSet)

func ValidateExistingComposeProjectDir added in v0.9.0

func ValidateExistingComposeProjectDir(projectDir string) error

Types

type Config

type Config struct {
	CurrentContext string    `yaml:"current-context"`
	Contexts       []Context `yaml:"contexts"`
}

func Load

func Load() (*Config, error)

type Context

type Context struct {
	Name           string      `yaml:"name"`
	Site           string      `yaml:"site"`
	Plugin         string      `yaml:"plugin"`
	DockerHostType ContextType `mapstructure:"type" yaml:"type"`
	Environment    string      `yaml:"environment,omitempty"`
	DockerSocket   string      `yaml:"docker-socket"`
	ProjectName    string      `yaml:"project-name"`
	ProjectDir     string      `yaml:"project-dir"`
	SSHUser        string      `yaml:"ssh-user"`
	SSHHostname    string      `yaml:"ssh-hostname,omitempty"`
	SSHPort        uint        `yaml:"ssh-port,omitempty"`
	SSHKeyPath     string      `yaml:"ssh-key,omitempty"`
	EnvFile        []string    `yaml:"env-file"`
	ComposeFile    []string    `yaml:"compose-file,omitempty"`
	RunSudo        bool        `yaml:"sudo"`

	// Database connection configuration
	DatabaseService        string `yaml:"database-service,omitempty"`
	DatabaseUser           string `yaml:"database-user,omitempty"`
	DatabasePasswordSecret string `yaml:"database-password-secret,omitempty"`
	DatabaseName           string `yaml:"database-name,omitempty"`

	ReadSmallFileFunc func(filename string) string `yaml:"-"`

	// Extra holds plugin-specific configuration.
	// Each plugin uses its own key (e.g., "drupal", "isle", "wordpress").
	Extra map[string]yaml.Node `yaml:"extra,omitempty"`
}

func CurrentContext

func CurrentContext(f *pflag.FlagSet) (*Context, error)

func DiscoverCurrentContext added in v0.9.0

func DiscoverCurrentContext() (*Context, error)

func FindLocalContextByProjectDir added in v0.9.0

func FindLocalContextByProjectDir(projectDir string) (*Context, error)

func GetContext

func GetContext(name string) (Context, error)

func LoadFromFlags

func LoadFromFlags(f *pflag.FlagSet, context Context) (*Context, error)

func PromptAndSaveLocalContext added in v0.5.0

func PromptAndSaveLocalContext(opts LocalContextCreateOptions) (*Context, error)

func (*Context) DialSSH

func (c *Context) DialSSH() (*ssh.Client, error)
func (c Context) EnsureTrackedComposeOverrideSymlink() error

func (*Context) FileExists added in v0.9.0

func (c *Context) FileExists(path string) (bool, error)

func (*Context) GetSshUri added in v0.2.0

func (c *Context) GetSshUri() string

GetSshUri returns an SSH connection URI

func (*Context) HasComposeProject added in v0.9.0

func (c *Context) HasComposeProject() (bool, error)

func (*Context) ListFiles added in v0.5.0

func (c *Context) ListFiles(root string) ([]string, error)

ListFiles lists files under a directory relative to the directory root.

func (Context) OverrideEnvironment added in v0.9.0

func (c Context) OverrideEnvironment() string

func (*Context) ProjectDirExists

func (c *Context) ProjectDirExists() (bool, error)

func (*Context) ReadFile added in v0.5.0

func (c *Context) ReadFile(filename string) ([]byte, error)

ReadFile reads a file from the context, supporting local and remote paths.

func (*Context) ReadSmallFile

func (c *Context) ReadSmallFile(filename string) string

func (*Context) RemoveFile added in v0.5.0

func (c *Context) RemoveFile(filename string) error

RemoveFile removes a file from the context.

func (*Context) ResolveProjectPath added in v0.9.0

func (c *Context) ResolveProjectPath(path string) string

func (*Context) RunCommand

func (c *Context) RunCommand(cmd *exec.Cmd) (string, error)

func (*Context) RunQuietCommand added in v0.9.0

func (c *Context) RunQuietCommand(cmd *exec.Cmd) (string, error)

func (Context) RuntimeComposeOverridePath added in v0.9.0

func (c Context) RuntimeComposeOverridePath() string

func (Context) String

func (context Context) String() (string, error)

func (Context) TrackedComposeOverrideName added in v0.9.0

func (c Context) TrackedComposeOverrideName() string

func (Context) TrackedComposeOverridePath added in v0.9.0

func (c Context) TrackedComposeOverridePath() string

func (*Context) UploadFile

func (c *Context) UploadFile(source, destination string) error

func (*Context) ValidateComposeAccess added in v0.9.0

func (c *Context) ValidateComposeAccess() error
func (c Context) ValidateTrackedComposeOverrideSymlink() error

func (*Context) VerifyRemoteInput

func (cc *Context) VerifyRemoteInput(existingSite bool) error

func (*Context) WriteFile added in v0.5.0

func (c *Context) WriteFile(filename string, data []byte) error

WriteFile writes a file to the context, creating parent directories as needed.

type ContextType

type ContextType string
const (
	ContextLocal  ContextType = "local"
	ContextRemote ContextType = "remote"
)

type FileReader

type FileReader interface {
	ReadSmallFile(path string) (string, error)
}

FileReader defines the behavior needed to read small files.

type InputFunc added in v0.5.0

type InputFunc func(question ...string) (string, error)

type LocalContextCreateOptions added in v0.5.0

type LocalContextCreateOptions struct {
	Name                string
	DefaultName         string
	Site                string
	DefaultSite         string
	Plugin              string
	DefaultPlugin       string
	ProjectDir          string
	DefaultProjectDir   string
	ProjectName         string
	DefaultProjectName  string
	Environment         string
	DockerSocket        string
	SetDefault          bool
	ConfirmOverwrite    bool
	Input               InputFunc
	ProjectDirValidator func(string) error
	ContextNamePrompt   []string
	ProjectDirPrompt    []string
	OverwritePrompt     []string
}

Jump to

Keyboard shortcuts

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