plugin

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 31 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddStandardComposeCommands added in v0.16.5

func AddStandardComposeCommands(s *SDK, opts StandardComposeCommandOptions)

AddStandardComposeCommands registers standard lifecycle, status, logs, and rollout commands for a Docker Compose-backed plugin.

func CloneTemplateRepo added in v0.5.0

func CloneTemplateRepo(opts GitTemplateOptions) error

func ConfigureTemplateRemotes added in v0.5.0

func ConfigureTemplateRemotes(opts GitTemplateOptions) error

func ContextPluginSupports added in v0.11.0

func ContextPluginSupports(contextPlugin, requestedPlugin string) bool

func DetectProjectOwner added in v0.17.0

func DetectProjectOwner(projectDir, requestedPlugin string) (*config.ProjectClaim, error)

func DockerComposeExecCommand added in v0.16.5

func DockerComposeExecCommand(service string, args ...string) string

DockerComposeExecCommand builds a shell-safe "docker compose exec -T" command for a service and argv-style command.

func PrintComposeTemplateCreateSummary added in v0.16.5

func PrintComposeTemplateCreateSummary(out io.Writer, ctx *config.Context, readyMessage string, setupOnly bool)

PrintComposeTemplateCreateSummary renders the standard create completion summary for compose-template plugins.

func RegisterComposeTemplateCreateRunner added in v0.16.5

func RegisterComposeTemplateCreateRunner(s *SDK, spec CreateSpec, opts ComposeTemplateCreateOptions)

RegisterComposeTemplateCreateRunner registers the SDK's standard Docker Compose template create runner for a plugin.

func RegisterStandardComposeTemplate added in v0.16.5

func RegisterStandardComposeTemplate(s *SDK, spec CreateSpec, opts StandardComposeTemplateOptions)

RegisterStandardComposeTemplate registers the standard create flow and lifecycle commands for a Docker Compose template plugin.

func ShellJoin added in v0.16.5

func ShellJoin(args []string) string

ShellJoin shell-quotes and joins argv-style command arguments.

func ShellQuote added in v0.16.5

func ShellQuote(value string) string

ShellQuote quotes a value for POSIX shell command construction.

Types

type CheckoutSource added in v0.15.0

type CheckoutSource string
const (
	CheckoutSourceTemplate CheckoutSource = "template"
	CheckoutSourceExisting CheckoutSource = "existing"
)

type CommandExecOptions added in v0.11.0

type CommandExecOptions struct {
	Context    context.Context
	Stdin      io.Reader
	Stdout     io.Writer
	Stderr     io.Writer
	Capture    bool
	LiveStderr bool
}

type ComposeCreateContextOptions added in v0.15.0

type ComposeCreateContextOptions struct {
	DefaultName         string
	DefaultSite         string
	DefaultPlugin       string
	DefaultProjectDir   string
	DefaultProjectName  string
	DefaultEnvironment  string
	DefaultDockerSocket string
	DefaultDrupalRootfs string
	DrupalContainerRoot string
	ConfirmOverwrite    bool
	Input               config.InputFunc
}

type ComposeCreateRequest added in v0.15.0

type ComposeCreateRequest struct {
	ContextName        string
	TargetType         config.ContextType
	CheckoutSource     CheckoutSource
	Path               string
	TemplateRepo       string
	TemplateBranch     string
	Site               string
	Environment        string
	ProjectName        string
	ComposeProjectName string
	ComposeNetwork     string
	DockerSocket       string
	SSHHostname        string
	SSHUser            string
	SSHPort            uint
	SSHKeyPath         string
	DrupalRootfs       string
	SetDefaultContext  bool
	SetupOnly          bool
	Decisions          map[string]corecomponent.ReviewDecision
}

type ComposeProjectDiscovery added in v0.17.0

type ComposeProjectDiscovery struct {
	RequiredServices          []string
	ForbiddenServices         []string
	RequiredComposerPackages  []string
	ForbiddenComposerPackages []string
	ComposerFiles             []string
	Reason                    string
}

type ComposeRemoteContextOptions added in v0.15.0

type ComposeRemoteContextOptions struct {
	ContextName         string
	DefaultName         string
	Site                string
	DefaultSite         string
	Plugin              string
	ProjectDir          string
	DefaultProjectDir   string
	ProjectName         string
	DefaultProjectName  string
	Environment         string
	DefaultEnvironment  string
	ComposeProjectName  string
	ComposeNetwork      string
	DockerSocket        string
	SSHHostname         string
	SSHUser             string
	SSHPort             uint
	SSHKeyPath          string
	SetDefault          bool
	ConfirmOverwrite    bool
	Input               config.InputFunc
	DrupalRootfs        string
	DrupalContainerRoot string
}

type ComposeTemplateCreateOptions added in v0.16.5

type ComposeTemplateCreateOptions struct {
	DefaultPath         string
	DefaultPlugin       string
	DefaultEnvironment  string
	DefaultDrupalRootfs string
	DrupalContainerRoot string
	ConfirmOverwrite    bool
	ReadyMessage        string
	Input               config.InputFunc
}

ComposeTemplateCreateOptions configures the SDK's standard Docker Compose template create runner.

type Config

type Config struct {
	LogLevel string
	Context  string
	APIUrl   string
	Format   string
}

Config holds common plugin configuration

type ContextJob added in v0.13.0

type ContextJob interface {
	BindFlags(cmd *cobra.Command)
	Run(cmd *cobra.Command, ctx *config.Context) error
}

type ConvergeRunner added in v0.16.0

type ConvergeRunner interface {
	BindFlags(cmd *cobra.Command)
	Run(cmd *cobra.Command, ctx *config.Context) error
}

ConvergeRunner implements plugin-specific component convergence. Run detects and repairs configuration drift for the active context.

type CreateRunner added in v0.14.0

type CreateRunner interface {
	BindFlags(cmd *cobra.Command)
	Run(cmd *cobra.Command) error
}

type CreateSpec added in v0.14.0

type CreateSpec struct {
	Name                 string   `yaml:"name"`
	Plugin               string   `yaml:"plugin,omitempty"`
	Description          string   `yaml:"description,omitempty"`
	Default              bool     `yaml:"default,omitempty"`
	MinCPUCores          float64  `yaml:"min_cpu_cores,omitempty"`
	MinMemory            string   `yaml:"min_memory,omitempty"`
	MinDiskSpace         string   `yaml:"min_disk_space,omitempty"`
	DockerComposeRepo    string   `yaml:"docker_compose_repo,omitempty"`
	DockerComposeBranch  string   `yaml:"docker_compose_branch,omitempty"`
	DockerComposeBuild   []string `yaml:"docker_compose_build,omitempty"`
	DockerComposeInit    []string `yaml:"docker_compose_init,omitempty"`
	DockerComposeUp      []string `yaml:"docker_compose_up,omitempty"`
	DockerComposeDown    []string `yaml:"docker_compose_down,omitempty"`
	DockerComposeRollout []string `yaml:"docker_compose_rollout,omitempty"`
}

type DebugRunner added in v0.16.0

type DebugRunner interface {
	BindFlags(cmd *cobra.Command)
	Render(cmd *cobra.Command, ctx *config.Context) (string, error)
}

DebugRunner renders plugin-specific debug diagnostics. Render returns the body content (without panel wrapper) for the plugin's debug section. The SDK wraps the body in a named panel and delegates to included plugins.

type DeployRunner added in v0.16.0

type DeployRunner interface {
	BindFlags(cmd *cobra.Command)
	PreDown(cmd *cobra.Command, ctx *config.Context) error
	PostUp(cmd *cobra.Command, ctx *config.Context) error
}

DeployRunner implements plugin-specific lifecycle hooks for the deploy flow. PreDown runs before compose down; PostUp runs after compose up.

type DeploySpec added in v0.16.0

type DeploySpec struct {
	Name        string `yaml:"name"`
	Plugin      string `yaml:"plugin,omitempty"`
	Description string `yaml:"description,omitempty"`
	Default     bool   `yaml:"default,omitempty"`
}

DeploySpec describes a plugin's deploy capability.

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 *config.Context) (*FileAccessor, error)

func NewFileAccessorWithSSH added in v0.12.0

func NewFileAccessorWithSSH(ctx *config.Context, client *ssh.Client, ownsSSH bool) (*FileAccessor, error)

func (*FileAccessor) Close added in v0.12.0

func (a *FileAccessor) Close() error

func (*FileAccessor) ListFiles added in v0.12.0

func (a *FileAccessor) ListFiles(root string) ([]string, error)

func (*FileAccessor) MatchFiles added in v0.12.0

func (a *FileAccessor) MatchFiles(root, pattern string) ([]string, error)

func (*FileAccessor) MatchFilesInDir added in v0.12.0

func (a *FileAccessor) MatchFilesInDir(root, pattern string) ([]string, error)

func (*FileAccessor) ReadFile added in v0.12.0

func (a *FileAccessor) ReadFile(path string) ([]byte, error)

func (*FileAccessor) ReadFileContext added in v0.12.0

func (a *FileAccessor) ReadFileContext(ctx context.Context, path string) ([]byte, error)

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 (a *FileAccessor) ReadFilesContext(ctx context.Context, paths []string) (map[string][]byte, error)

type GitTemplateOptions added in v0.5.0

type GitTemplateOptions struct {
	TemplateRepo       string
	TemplateBranch     string
	ProjectDir         string
	GitRemoteURL       string
	GitRemoteName      string
	TemplateRemoteName string
	Quiet              bool
}

type InstalledPlugin added in v0.10.0

type InstalledPlugin struct {
	Name              string
	BinaryName        string
	Path              string
	Version           string
	Description       string
	Author            string
	TemplateRepo      string
	CanCreate         bool
	CanDeploy         bool
	CanConverge       bool
	CanSet            bool
	CanValidate       bool
	Includes          []string
	CreateDefinitions []CreateSpec
	DeployDefinitions []DeploySpec
}

func DiscoverInstalled added in v0.10.0

func DiscoverInstalled() []InstalledPlugin

func DiscoverInstalledFromPath added in v0.10.0

func DiscoverInstalledFromPath(pathEnv string) []InstalledPlugin

func DiscoverInstalledLightweight added in v0.15.0

func DiscoverInstalledLightweight() []InstalledPlugin

func DiscoverInstalledLightweightFromPath added in v0.15.0

func DiscoverInstalledLightweightFromPath(pathEnv string) []InstalledPlugin

func FindInstalled added in v0.11.0

func FindInstalled(name string) (InstalledPlugin, bool)

type Metadata

type Metadata struct {
	Name         string
	Version      string
	Description  string
	Author       string
	TemplateRepo string
	Includes     []string
}

Metadata contains information about a plugin

type ProgressLine added in v0.13.0

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

func NewProgressLine added in v0.13.0

func NewProgressLine(w io.Writer, title, detail string) *ProgressLine

func (*ProgressLine) Close added in v0.13.0

func (p *ProgressLine) Close()

func (*ProgressLine) Report added in v0.13.0

func (p *ProgressLine) Report(title, detail string)

type ProjectDiscoveryFunc added in v0.17.0

type ProjectDiscoveryFunc func(projectDir string) (*config.ProjectClaim, error)

type RegisteredCreate added in v0.14.0

type RegisteredCreate struct {
	Spec    CreateSpec
	Command *cobra.Command
}

type RegisteredDeploy added in v0.16.0

type RegisteredDeploy struct {
	Spec DeploySpec
}

RegisteredDeploy holds a registered deploy spec.

type RegisteredJob added in v0.13.0

type RegisteredJob struct {
	Spec    job.Spec
	Command *cobra.Command
}

type SDK

type SDK struct {
	Metadata Metadata
	Config   Config
	RootCmd  *cobra.Command
	// contains filtered or unexported fields
}

SDK provides common functionality for plugins

func NewSDK

func NewSDK(metadata Metadata) *SDK

NewSDK creates a new plugin SDK instance

func (*SDK) AddCommand

func (s *SDK) AddCommand(cmd *cobra.Command)

AddCommand adds a subcommand to the plugin

func (*SDK) AddStandardComposeCommands added in v0.16.5

func (s *SDK) AddStandardComposeCommands(opts StandardComposeCommandOptions)

AddStandardComposeCommands registers standard lifecycle, status, logs, and rollout commands for the receiver plugin.

func (*SDK) BindComposeCreateFlags added in v0.15.0

func (s *SDK) BindComposeCreateFlags(cmd *cobra.Command, spec CreateSpec, drupalRootfs *string, defaultDrupalRootfs string) error

func (*SDK) CloneTemplateRepo added in v0.5.0

func (s *SDK) CloneTemplateRepo(opts GitTemplateOptions) error

func (*SDK) Close added in v0.12.0

func (s *SDK) Close() error

func (*SDK) ConfigureTemplateRemotes added in v0.5.0

func (s *SDK) ConfigureTemplateRemotes(opts GitTemplateOptions) error

func (*SDK) ContextFromCommand added in v0.16.5

func (s *SDK) ContextFromCommand(cmd *cobra.Command) (*config.Context, error)

ContextFromCommand loads the sitectl context selected by a Cobra command.

func (*SDK) ContextValidators added in v0.9.0

func (s *SDK) ContextValidators() []validate.Validator

func (*SDK) CreateComponentDefinitions added in v0.15.0

func (s *SDK) CreateComponentDefinitions() ([]corecomponent.Definition, error)

func (*SDK) CreateDefinitions added in v0.14.0

func (s *SDK) CreateDefinitions() []CreateSpec

func (*SDK) DeployDefinitions added in v0.16.0

func (s *SDK) DeployDefinitions() []DeploySpec

DeployDefinitions returns the deploy specs registered with this SDK instance.

func (*SDK) EnsureComposeCreateContext added in v0.15.0

func (s *SDK) EnsureComposeCreateContext(req ComposeCreateRequest, opts ComposeCreateContextOptions) (*config.Context, error)

func (*SDK) EnsureComposeTemplateCheckout added in v0.16.5

func (s *SDK) EnsureComposeTemplateCheckout(out io.Writer, req ComposeCreateRequest, ctx *config.Context) (bool, error)

EnsureComposeTemplateCheckout ensures the requested Docker Compose template exists for the target context and returns whether a new checkout was cloned.

func (*SDK) ExecContainer added in v0.12.0

func (s *SDK) ExecContainer(ctx context.Context, opts docker.ExecOptions) (int, error)

ExecContainer executes a command in a Docker container using the shared SDK Docker path.

func (*SDK) ExecInContainer

func (s *SDK) ExecInContainer(ctx context.Context, containerID string, cmd []string) (int, error)

ExecInContainer executes a command in a Docker container. This is a convenience wrapper for plugins.

func (*SDK) ExecInContainerInteractive

func (s *SDK) ExecInContainerInteractive(ctx context.Context, containerID string, cmd []string) (int, error)

ExecInContainerInteractive executes an interactive command in a Docker container with TTY. This is a convenience wrapper for plugins.

func (*SDK) Execute

func (s *SDK) Execute()

Execute runs the plugin

func (*SDK) GetComponentManager added in v0.5.0

func (s *SDK) GetComponentManager() (*component.Manager, error)

GetComponentManager creates a component manager bound to the active sitectl context.

func (*SDK) GetContext

func (s *SDK) GetContext() (*config.Context, error)

GetContext loads the sitectl context configuration This is useful for plugins that need to access context-specific settings If no context is specified, returns the current context from config

func (*SDK) GetDiscoveryMetadataCommand added in v0.15.0

func (s *SDK) GetDiscoveryMetadataCommand() *cobra.Command

GetDiscoveryMetadataCommand returns a single cheap metadata payload for plugin discovery.

func (*SDK) GetDockerClient

func (s *SDK) GetDockerClient() (*docker.DockerClient, error)

GetDockerClient creates a Docker client respecting the sitectl context This is a helper for plugins that need to interact with Docker Returns the existing DockerClient which handles both local and remote contexts

func (*SDK) GetFileAccessor added in v0.12.0

func (s *SDK) GetFileAccessor() (*FileAccessor, error)

func (*SDK) GetProjectDetectionCommand added in v0.17.0

func (s *SDK) GetProjectDetectionCommand() *cobra.Command

func (*SDK) GetSSHClient added in v0.12.0

func (s *SDK) GetSSHClient() (*ssh.Client, error)

func (*SDK) InvokeIncludedPluginCommand added in v0.11.0

func (s *SDK) InvokeIncludedPluginCommand(pluginName string, args []string, opts CommandExecOptions) (string, error)

func (*SDK) InvokeIncludedPlugins added in v0.11.0

func (s *SDK) InvokeIncludedPlugins(args []string) ([]string, error)

func (*SDK) InvokePluginCommand added in v0.11.0

func (s *SDK) InvokePluginCommand(pluginName string, args []string, opts CommandExecOptions) (string, error)

func (*SDK) LocalComponentDefinitions added in v0.15.0

func (s *SDK) LocalComponentDefinitions() []corecomponent.Definition

func (*SDK) PromptAndSaveLocalContext added in v0.5.0

func (s *SDK) PromptAndSaveLocalContext(opts config.LocalContextCreateOptions) (*config.Context, error)

PromptAndSaveLocalContext creates or updates a local sitectl context using the shared config prompts and save behavior.

func (*SDK) RegisterComponentDefinition added in v0.15.0

func (s *SDK) RegisterComponentDefinition(def corecomponent.Definition)

func (*SDK) RegisterComponentDefinitions added in v0.15.0

func (s *SDK) RegisterComponentDefinitions(defs ...corecomponent.Definition)

func (*SDK) RegisterComposeTemplateCreateRunner added in v0.16.5

func (s *SDK) RegisterComposeTemplateCreateRunner(spec CreateSpec, opts ComposeTemplateCreateOptions)

RegisterComposeTemplateCreateRunner registers the SDK's standard Docker Compose template create runner for the receiver plugin.

func (*SDK) RegisterContextJob added in v0.13.0

func (s *SDK) RegisterContextJob(spec job.Spec, runner ContextJob)

func (*SDK) RegisterContextValidator added in v0.9.0

func (s *SDK) RegisterContextValidator(validator validate.Validator)

func (*SDK) RegisterConvergeRunner added in v0.16.0

func (s *SDK) RegisterConvergeRunner(runner ConvergeRunner)

RegisterConvergeRunner registers a converge runner for the plugin. The SDK creates the __converge hidden command that is invoked by sitectl converge.

func (*SDK) RegisterCreate added in v0.14.0

func (s *SDK) RegisterCreate(spec CreateSpec, cmd *cobra.Command)

func (*SDK) RegisterCreateRunner added in v0.14.0

func (s *SDK) RegisterCreateRunner(spec CreateSpec, runner CreateRunner)

func (*SDK) RegisterDebugHandler added in v0.16.0

func (s *SDK) RegisterDebugHandler(runner DebugRunner)

RegisterDebugHandler registers a debug runner for the plugin. The SDK creates the __debug hidden command, wraps the runner's output in a named panel, and delegates to any included plugins.

func (*SDK) RegisterDeployRunner added in v0.16.0

func (s *SDK) RegisterDeployRunner(spec DeploySpec, runner DeployRunner)

RegisterDeployRunner registers a deploy runner for the plugin. The SDK creates the __deploy hidden command with pre-down and post-up subcommands that are invoked by sitectl deploy around the compose down/up cycle.

func (*SDK) RegisterJob added in v0.13.0

func (s *SDK) RegisterJob(spec job.Spec, cmd *cobra.Command)

func (*SDK) RegisterSetRunner added in v0.16.0

func (s *SDK) RegisterSetRunner(runner SetRunner)

RegisterSetRunner registers a set runner for the plugin. The SDK creates the __set hidden command that is invoked by sitectl set.

func (*SDK) RegisterStandardComposeTemplate added in v0.16.5

func (s *SDK) RegisterStandardComposeTemplate(spec CreateSpec, opts StandardComposeTemplateOptions)

RegisterStandardComposeTemplate registers the standard create flow and lifecycle commands for the receiver plugin.

func (*SDK) RegisterValidateRunner added in v0.16.0

func (s *SDK) RegisterValidateRunner(runner ValidateRunner)

RegisterValidateRunner registers a validate runner for the plugin. The SDK creates the __validate hidden command that is invoked by sitectl validate. The command outputs YAML-encoded []validate.Result that sitectl merges with core validation results before writing the final report.

func (*SDK) ResolveComposeCreateRequest added in v0.15.0

func (s *SDK) ResolveComposeCreateRequest(cmd *cobra.Command, input config.InputFunc, drupalRootfs, defaultPath, defaultRepo, defaultBranch string) (ComposeCreateRequest, error)

func (*SDK) RunActiveComposeProjectCommand added in v0.16.5

func (s *SDK) RunActiveComposeProjectCommand(cmd *cobra.Command, command string) error

RunActiveComposeProjectCommand runs a shell command in the active context's compose project directory.

func (*SDK) RunActiveComposeProjectCommandList added in v0.16.5

func (s *SDK) RunActiveComposeProjectCommandList(cmd *cobra.Command, commands []string) error

RunActiveComposeProjectCommandList runs shell commands in the active context's compose project directory.

func (*SDK) RunComposeProjectCommand added in v0.16.5

func (s *SDK) RunComposeProjectCommand(ctx *config.Context, projectDir string, stdout, stderr io.Writer, command string) error

RunComposeProjectCommand runs a shell command in a compose project directory, honoring local and remote sitectl contexts.

func (*SDK) RunComposeProjectCommandList added in v0.16.5

func (s *SDK) RunComposeProjectCommandList(cmd *cobra.Command, ctx *config.Context, commands []string) error

RunComposeProjectCommandList runs a list of shell commands in a compose project's directory, skipping empty command strings.

func (*SDK) SetComposeProjectDiscovery added in v0.17.0

func (s *SDK) SetComposeProjectDiscovery(spec ComposeProjectDiscovery)

func (*SDK) SetProjectDiscovery added in v0.17.0

func (s *SDK) SetProjectDiscovery(discovery ProjectDiscoveryFunc)

func (*SDK) SetVersionInfo added in v0.6.1

func (s *SDK) SetVersionInfo(version, commit, date string)

SetVersionInfo formats plugin version metadata like the main sitectl binary.

type SetRunner added in v0.16.0

type SetRunner interface {
	BindFlags(cmd *cobra.Command)
	Run(cmd *cobra.Command, args []string, ctx *config.Context) error
}

SetRunner implements plugin-specific component state management. Run applies the requested state or disposition to the named component.

type StandardComposeCommandOptions added in v0.16.5

type StandardComposeCommandOptions struct {
	DisplayName     string
	LogsTail        int
	BuildCommands   []string
	InitCommands    []string
	UpCommands      []string
	DownCommands    []string
	RolloutCommands []string
	RolloutCommand  string
}

StandardComposeCommandOptions configures standard Docker Compose helper commands registered by the SDK.

type StandardComposeTemplateOptions added in v0.16.5

type StandardComposeTemplateOptions struct {
	DefaultPath         string
	DefaultPlugin       string
	DefaultEnvironment  string
	DefaultDrupalRootfs string
	DrupalContainerRoot string
	ConfirmOverwrite    bool
	ReadyMessage        string
	DisplayName         string
	LogsTail            int
	Input               config.InputFunc
}

StandardComposeTemplateOptions configures the SDK's standard Compose template create runner and lifecycle commands from one application spec.

type ValidateRunner added in v0.16.0

type ValidateRunner interface {
	BindFlags(cmd *cobra.Command)
	Run(cmd *cobra.Command, ctx *config.Context) ([]sitevalidate.Result, error)
}

ValidateRunner implements plugin-specific context validation. Run returns a list of validation results for the active context.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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