Documentation
¶
Index ¶
- Constants
- Variables
- func AppendEnvOverrides(base []string, values map[string]string) []string
- func ConfigFilePath() (string, error)
- func ContextExists(name string) (bool, error)
- func Current() (string, error)
- func CurrentForPlugin(pluginName string) (string, error)
- func CurrentForPluginWithDiagnostics(pluginName string, diagnostics io.Writer) (string, error)
- func DetectComposeNetworkName(projectDir, composeProjectName string) string
- func DetectComposeProjectName(projectDir string) string
- func DetectComposeServices(projectDir string) []string
- func DetectContextComposeNetwork(ctx *Context) string
- func DetectContextComposeProjectName(ctx *Context) string
- func DockerVisibleLocalPath(path string) string
- func ExpandProjectDir(value string) (string, error)
- func FindComposeProjectRoot(startDir string) string
- func GetDefaultLocalDockerSocket(dockerSocket string) string
- func GetInput(question ...string) (string, error)
- func GitSyncRefShellCommand(ref string) string
- func GitSyncShellCommand(branch string) string
- func IsDockerSocketAlive(socket string) bool
- func LogDockerComposeCommand(ctx *Context, command string)
- func LooksLikeComposeProject(projectDir string) bool
- func ResolveCurrentContextName(f *pflag.FlagSet) (string, error)
- func ResolveCurrentContextNameForPlugin(f *pflag.FlagSet, pluginName string) (string, error)
- func Save(cfg *Config) error
- func SaveContext(ctx *Context, setDefault bool) error
- func SetCommandFlags(flags *pflag.FlagSet)
- func ValidateExistingComposeProjectDir(projectDir string) error
- type Config
- type Context
- func CurrentContext(f *pflag.FlagSet) (*Context, error)
- func DiscoverCurrentContext() (*Context, error)
- func FindLocalContextByProjectDir(projectDir string) (*Context, error)
- func FindLocalContextByProjectDirAndPlugin(projectDir, pluginName string) (*Context, error)
- func GetContext(name string) (Context, error)
- func GetContextForPlugin(name, pluginName string) (Context, error)
- func LoadFromFlags(f *pflag.FlagSet, context Context) (*Context, error)
- func NewLocalProjectContext(projectDir, pluginName string) (*Context, error)
- func PromptAndSaveLocalContext(opts LocalContextCreateOptions) (*Context, error)
- func (c Context) ComposePublicScheme(defaultScheme string) string
- func (c Context) ComposePublishedHostPort(target int) (int, bool)
- func (c Context) ComposeTLSProvider(defaultProvider string) string
- func (c *Context) DialSSH() (*ssh.Client, error)
- func (c Context) DockerComposeGlobalArgs() []string
- func (c Context) DockerComposeGlobalArgsForCommand(command string) []string
- func (c Context) DockerComposeShellCommand(command string) string
- func (c Context) DockerComposeSubcommandArgs(args []string) []string
- func (c Context) EffectiveComposeNetwork() string
- func (c Context) EffectiveComposeProjectName() string
- func (c *Context) EffectiveDrupalContainerRoot() string
- func (c *Context) EffectiveDrupalRootfs() string
- func (c Context) EnsureTrackedComposeOverrideSymlink() error
- func (c *Context) FileExists(path string) (bool, error)
- func (c *Context) GetSshUri() string
- func (c Context) GitSyncRefShellCommand(ref string) string
- func (c Context) GitSyncShellCommand(branchOverride string) string
- func (c *Context) HasComposeProject() (bool, error)
- func (c Context) IsLocalDevelopment() bool
- func (c *Context) ListFiles(root string) ([]string, error)
- func (c Context) MarshalYAML() (any, error)
- func (c *Context) NewFileAccessor() (*FileAccessor, error)
- func (c Context) OverrideEnvironment() string
- func (c Context) PrepareComposeUpPortOverride() (map[string]string, []string, error)
- func (c *Context) ProjectDirExists() (bool, error)
- func (c *Context) ReadFile(filename string) ([]byte, error)
- func (c *Context) ReadSmallFile(filename string) (string, error)
- func (c *Context) RemoveFile(filename string) error
- func (c *Context) ResolveProjectPath(path string) string
- func (c *Context) RunCommand(cmd *exec.Cmd) (string, error)
- func (c *Context) RunCommandContext(ctx context.Context, cmd *exec.Cmd) (string, error)
- func (c *Context) RunQuietCommand(cmd *exec.Cmd) (string, error)
- func (c *Context) RunQuietCommandContext(ctx context.Context, cmd *exec.Cmd) (string, error)
- func (c Context) RuntimeComposeOverridePath() string
- func (context Context) String() (string, error)
- func (c Context) TrackedComposeOverrideName() string
- func (c Context) TrackedComposeOverridePath() string
- func (c *Context) UnmarshalYAML(value *yaml.Node) error
- func (c *Context) UploadFile(source, destination string) error
- func (c *Context) ValidateComposeAccess() error
- func (c Context) ValidateTrackedComposeOverrideSymlink() error
- func (cc *Context) VerifyRemoteInput(existingSite bool) error
- func (c *Context) WriteFile(filename string, data []byte) error
- type ContextType
- type CurrentContextDiscovery
- type FileAccessor
- func (a *FileAccessor) Close() error
- func (a *FileAccessor) FileExists(path string) (bool, error)
- func (a *FileAccessor) ListFiles(root string) ([]string, error)
- func (a *FileAccessor) MkdirAll(path string) error
- func (a *FileAccessor) ReadFile(filename string) ([]byte, error)
- func (a *FileAccessor) ReadFileContext(ctx context.Context, filename string) ([]byte, error)
- func (a *FileAccessor) ReadFiles(paths []string) (map[string][]byte, error)
- func (a *FileAccessor) ReadFilesContext(ctx context.Context, paths []string) (map[string][]byte, error)
- func (a *FileAccessor) RemoveAll(path string) error
- func (a *FileAccessor) RemoveFile(filename string) error
- func (a *FileAccessor) Stat(path string) (fs.FileInfo, error)
- func (a *FileAccessor) StatVFS(path string) (*sftp.StatVFS, error)
- func (a *FileAccessor) UploadFile(source, destination string) error
- func (a *FileAccessor) WriteFile(filename string, data []byte) error
- type FileReader
- type InputFunc
- type LocalContextCreateOptions
- type ProjectClaim
- type ProjectClaimDetector
Constants ¶
const (
LocalDevComposeOverrideName = "docker-compose.override.yml"
)
const RuntimeComposeOverrideName = "docker-compose.override.yml"
Variables ¶
var ErrContextNotFound = errors.New("context not found")
Functions ¶
func AppendEnvOverrides ¶ added in v0.22.0
func ConfigFilePath ¶
func ContextExists ¶
func CurrentForPlugin ¶ added in v0.17.0
func CurrentForPluginWithDiagnostics ¶ added in v0.17.0
func DetectComposeNetworkName ¶ added in v0.10.0
func DetectComposeProjectName ¶ added in v0.10.0
func DetectComposeServices ¶ added in v0.17.0
func DetectContextComposeNetwork ¶ added in v0.10.0
func DetectContextComposeProjectName ¶ added in v0.35.2
func DockerVisibleLocalPath ¶ added in v0.23.2
DockerVisibleLocalPath translates a path inside this process into the path the local Docker daemon can see when the workspace is mounted through sshfs.
func ExpandProjectDir ¶ added in v0.10.0
func FindComposeProjectRoot ¶ added in v0.17.0
func GetDefaultLocalDockerSocket ¶
for local contexts, try a bunch of common paths grab the docker socket this is mostly needed for Mac OS
func GitSyncRefShellCommand ¶ added in v0.39.0
func GitSyncShellCommand ¶ added in v0.24.0
func IsDockerSocketAlive ¶ added in v0.9.0
func LogDockerComposeCommand ¶ added in v1.3.0
LogDockerComposeCommand records Compose commands at info level so normal sitectl operation also teaches operators the underlying command line.
func LooksLikeComposeProject ¶ added in v0.9.0
func ResolveCurrentContextName ¶ added in v0.9.0
func ResolveCurrentContextNameForPlugin ¶ added in v0.17.0
func SaveContext ¶
func SetCommandFlags ¶
func ValidateExistingComposeProjectDir ¶ added in v0.9.0
Types ¶
type Config ¶
type Context ¶
type Context struct {
// Name is the unique sitectl identifier selected with --context.
Name string `yaml:"name"`
// Site groups multiple environment contexts for the same logical site.
Site string `yaml:"site"`
// Plugin identifies the plugin responsible for this stack's lifecycle.
Plugin string `yaml:"plugin"`
// DockerHostType selects local execution or SSH-backed remote execution.
DockerHostType ContextType `mapstructure:"type" yaml:"type"`
// Environment distinguishes deployments of a site, such as local or prod.
Environment string `yaml:"environment,omitempty"`
// DockerSocket is the Unix socket Docker exposes on the target machine.
DockerSocket string `yaml:"docker-socket"`
// ComposeProjectName is Docker Compose's runtime project identity.
ComposeProjectName string `yaml:"compose-project-name,omitempty"`
// ProjectName is retained for source compatibility with older plugins.
// Deprecated: use Site for logical identity and ComposeProjectName for the
// Docker Compose runtime identity. This alias is never persisted.
ProjectName string `json:"-" yaml:"-"`
// ComposeNetwork is the primary network used to resolve stack services.
ComposeNetwork string `yaml:"compose-network,omitempty"`
// ProjectDir is the compose checkout path on the target machine.
ProjectDir string `yaml:"project-dir"`
// DrupalRootfs locates Drupal within ProjectDir for Drupal-aware plugins.
DrupalRootfs string `yaml:"drupal-rootfs,omitempty"`
// DrupalContainerRoot is Drupal's corresponding path inside its container.
DrupalContainerRoot string `yaml:"drupal-container-root,omitempty"`
// SSHUser, SSHHostname, SSHPort, and SSHKeyPath define remote transport.
SSHUser string `yaml:"ssh-user"`
SSHHostname string `yaml:"ssh-hostname,omitempty"`
SSHPort uint `yaml:"ssh-port,omitempty"`
SSHKeyPath string `yaml:"ssh-key,omitempty"`
// EnvFile and ComposeFile select the ordered inputs passed to Compose.
EnvFile []string `yaml:"env-file"`
ComposeFile []string `yaml:"compose-file,omitempty"`
// Database fields describe the compose service and secret references used
// by shared database jobs; they never contain the password itself.
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 is an injectable runtime reader and is never persisted.
ReadSmallFileFunc func(filename string) (string, error) `yaml:"-"`
// Ephemeral marks discovered contexts that must not be saved implicitly.
Ephemeral bool `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 DiscoverCurrentContext ¶ added in v0.9.0
func FindLocalContextByProjectDir ¶ added in v0.9.0
func FindLocalContextByProjectDirAndPlugin ¶ added in v0.17.0
func GetContext ¶
func GetContextForPlugin ¶ added in v0.17.1
func NewLocalProjectContext ¶ added in v0.29.0
NewLocalProjectContext returns a transient local context for a Compose project directory. The returned context is not persisted to the sitectl config file and mirrors the context shape used for claimed current-directory projects.
func PromptAndSaveLocalContext ¶ added in v0.5.0
func PromptAndSaveLocalContext(opts LocalContextCreateOptions) (*Context, error)
func (Context) ComposePublicScheme ¶ added in v0.23.0
func (Context) ComposePublishedHostPort ¶ added in v0.23.0
func (Context) ComposeTLSProvider ¶ added in v0.23.1
func (Context) DockerComposeGlobalArgs ¶ added in v0.23.2
DockerComposeGlobalArgs returns docker compose options that must be inserted after "docker compose" and before the compose subcommand.
func (Context) DockerComposeGlobalArgsForCommand ¶ added in v0.23.2
func (Context) DockerComposeShellCommand ¶ added in v0.23.2
DockerComposeShellCommand rewrites executable "docker compose ..." commands in a shell list so they honor the context's Compose and environment files. It also supplies daemon-visible project paths for local sshfs workspaces.
func (Context) DockerComposeSubcommandArgs ¶ added in v0.23.2
DockerComposeSubcommandArgs returns compose subcommand arguments adjusted for the local Docker daemon path mapping.
func (Context) EffectiveComposeNetwork ¶ added in v0.10.0
func (Context) EffectiveComposeProjectName ¶ added in v0.10.0
func (*Context) EffectiveDrupalContainerRoot ¶ added in v0.13.0
func (*Context) EffectiveDrupalRootfs ¶ added in v0.13.0
func (Context) EnsureTrackedComposeOverrideSymlink ¶ added in v0.9.0
func (*Context) FileExists ¶ added in v0.9.0
func (Context) GitSyncRefShellCommand ¶ added in v0.39.0
GitSyncRefShellCommand returns a shell command that fetches an exact remote ref (including refs/pull/* or an advertised commit) into a dedicated local ref, verifies that it resolves to a commit, and checks it out detached. This deliberately does not rewrite a configured branch or its upstream.
func (Context) GitSyncShellCommand ¶ added in v0.24.0
GitSyncShellCommand returns a shell command that fast-forwards the checkout from the checkout's configured upstream branch. An explicit branch is fetched from the checkout's selected remote before it is checked out. It skips non-git directories and checkouts without an upstream branch only when no explicit branch was requested.
func (*Context) HasComposeProject ¶ added in v0.9.0
func (Context) IsLocalDevelopment ¶ added in v0.22.0
func (*Context) ListFiles ¶ added in v0.5.0
ListFiles lists files under a directory relative to the directory root.
func (Context) MarshalYAML ¶ added in v1.3.0
MarshalYAML writes only canonical context keys while normalizing values from callers that still populate the deprecated ProjectName field.
func (*Context) NewFileAccessor ¶ added in v0.12.0
func (c *Context) NewFileAccessor() (*FileAccessor, error)
func (Context) OverrideEnvironment ¶ added in v0.9.0
func (Context) PrepareComposeUpPortOverride ¶ added in v0.23.0
func (*Context) ProjectDirExists ¶
func (*Context) ReadFile ¶ added in v0.5.0
ReadFile reads a file from the context, supporting local and remote paths.
func (*Context) RemoveFile ¶ added in v0.5.0
RemoveFile removes a file from the context.
func (*Context) ResolveProjectPath ¶ added in v0.9.0
func (*Context) RunCommandContext ¶ added in v0.12.0
func (*Context) RunQuietCommand ¶ added in v0.9.0
func (*Context) RunQuietCommandContext ¶ added in v0.12.0
func (Context) RuntimeComposeOverridePath ¶ added in v0.9.0
func (Context) TrackedComposeOverrideName ¶ added in v0.9.0
func (Context) TrackedComposeOverridePath ¶ added in v0.9.0
func (*Context) UnmarshalYAML ¶ added in v1.3.0
UnmarshalYAML accepts the retired project-name key so existing configs keep working. Site owns logical identity and ComposeProjectName owns Compose's runtime identity, so newly saved contexts contain no duplicate project name.
func (*Context) UploadFile ¶
func (*Context) ValidateComposeAccess ¶ added in v0.9.0
func (Context) ValidateTrackedComposeOverrideSymlink ¶ added in v0.9.0
func (*Context) VerifyRemoteInput ¶
type ContextType ¶
type ContextType string
const ( ContextLocal ContextType = "local" ContextRemote ContextType = "remote" )
type CurrentContextDiscovery ¶ added in v0.17.0
type CurrentContextDiscovery struct {
CWD string
ComposeProjectDir string
Claim *ProjectClaim
Context *Context
}
func DiscoverCurrentContextForPlugin ¶ added in v0.17.0
func DiscoverCurrentContextForPlugin(requestedPlugin string) (CurrentContextDiscovery, error)
type FileAccessor ¶ added in v0.12.0
type FileAccessor struct {
// contains filtered or unexported fields
}
func NewFileAccessor ¶ added in v0.12.0
func NewFileAccessor(ctx *Context) (*FileAccessor, error)
func NewFileAccessorWithSSH ¶ added in v0.12.0
func (*FileAccessor) Close ¶ added in v0.12.0
func (a *FileAccessor) Close() error
func (*FileAccessor) FileExists ¶ added in v0.12.0
func (a *FileAccessor) FileExists(path string) (bool, error)
func (*FileAccessor) ListFiles ¶ added in v0.12.0
func (a *FileAccessor) ListFiles(root string) ([]string, error)
func (*FileAccessor) MkdirAll ¶ added in v0.13.0
func (a *FileAccessor) MkdirAll(path string) error
func (*FileAccessor) ReadFile ¶ added in v0.12.0
func (a *FileAccessor) ReadFile(filename string) ([]byte, error)
func (*FileAccessor) ReadFileContext ¶ added in v0.12.0
func (*FileAccessor) ReadFiles ¶ added in v0.12.0
func (a *FileAccessor) ReadFiles(paths []string) (map[string][]byte, error)
func (*FileAccessor) ReadFilesContext ¶ added in v0.12.0
func (*FileAccessor) RemoveAll ¶ added in v0.13.0
func (a *FileAccessor) RemoveAll(path string) error
func (*FileAccessor) RemoveFile ¶ added in v0.12.0
func (a *FileAccessor) RemoveFile(filename string) error
func (*FileAccessor) Stat ¶ added in v0.12.0
func (a *FileAccessor) Stat(path string) (fs.FileInfo, error)
func (*FileAccessor) StatVFS ¶ added in v0.13.1
func (a *FileAccessor) StatVFS(path string) (*sftp.StatVFS, error)
func (*FileAccessor) UploadFile ¶ added in v0.12.0
func (a *FileAccessor) UploadFile(source, destination string) error
type FileReader ¶
FileReader defines the behavior needed to read small files.
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 is retained for source compatibility with older plugins.
// Deprecated: use ComposeProjectName.
ProjectName string
DefaultProjectName string
ComposeProjectName string
ComposeNetwork string
Environment string
DockerSocket string
DatabaseService string
DatabaseUser string
DatabaseSecret string
DatabaseName string
DrupalRootfs string
DrupalContainerRoot string
SetDefault bool
ConfirmOverwrite bool
Input InputFunc
ProjectDirValidator func(string) error
ContextNamePrompt []string
ProjectDirPrompt []string
OverwritePrompt []string
}
type ProjectClaim ¶ added in v0.17.0
type ProjectClaimDetector ¶ added in v0.17.0
type ProjectClaimDetector func(projectDir, requestedPlugin string) (*ProjectClaim, error)
func SetProjectClaimDetector ¶ added in v0.17.0
func SetProjectClaimDetector(detector ProjectClaimDetector) ProjectClaimDetector