executor

package
v0.18.5 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeDocker     = "docker"
	TypeLocal      = "local"
	TypeSSH        = "ssh"
	TypeSymfonyCLI = "symfony-cli"
)

Variables

View Source
var ErrNotSupported = errors.New("operation not supported by this executor")

Functions

func AllowBinCI

func AllowBinCI(ctx context.Context) context.Context

func IsBinCIAllowed

func IsBinCIAllowed(ctx context.Context) bool

func WithTTY

func WithTTY(ctx context.Context) context.Context

WithTTY requests a TTY for docker compose exec (no -T). Use this for interactive console usage so Symfony keeps ANSI colors and prompts.

Types

type DatabaseConnection

type DatabaseConnection struct {
	Host     string
	Port     string
	Username string
	Password string
	Database string
	// contains filtered or unexported fields
}

DatabaseConnection describes how to reach the project database from the host machine.

func (*DatabaseConnection) Addr

func (c *DatabaseConnection) Addr() string

Addr returns the host:port address of the database.

func (*DatabaseConnection) MySQLConfig

func (c *DatabaseConnection) MySQLConfig() *mysql.Config

MySQLConfig translates the credentials into a driver configuration.

func (*DatabaseConnection) Open

func (c *DatabaseConnection) Open(ctx context.Context) (*sql.Conn, func(), error)

Open opens a single dedicated connection to the database, so session state (SET, USE, ...) survives across statements. The returned cleanup closes the connection and its pool.

type DockerExecutor

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

func (*DockerExecutor) AdminAPIClient

func (d *DockerExecutor) AdminAPIClient(ctx context.Context) (*adminSdk.Client, error)

func (*DockerExecutor) AvailableLogFiles

func (d *DockerExecutor) AvailableLogFiles(ctx context.Context) ([]LogFile, error)

func (*DockerExecutor) ComposerCommand

func (d *DockerExecutor) ComposerCommand(ctx context.Context, args ...string) *Process

func (*DockerExecutor) ConsoleCommand

func (d *DockerExecutor) ConsoleCommand(ctx context.Context, args ...string) *Process

func (*DockerExecutor) DatabaseConnection

func (d *DockerExecutor) DatabaseConnection(ctx context.Context) (*DatabaseConnection, error)

DatabaseConnection resolves the database credentials as seen inside the compose network and translates the service host to the port published on the host machine.

func (*DockerExecutor) EnvironmentStatus

func (d *DockerExecutor) EnvironmentStatus(ctx context.Context) (bool, error)

func (*DockerExecutor) GetLog

func (d *DockerExecutor) GetLog(ctx context.Context, file string, lines int, follow bool, w io.Writer) error

func (*DockerExecutor) NPMCommand

func (d *DockerExecutor) NPMCommand(ctx context.Context, args ...string) *Process

func (*DockerExecutor) NormalizePath

func (d *DockerExecutor) NormalizePath(hostPath string) string

func (*DockerExecutor) PHPCommand

func (d *DockerExecutor) PHPCommand(ctx context.Context, args ...string) *Process

func (*DockerExecutor) ShopConfig

func (d *DockerExecutor) ShopConfig() *shop.Config

func (*DockerExecutor) StartEnvironment

func (d *DockerExecutor) StartEnvironment(ctx context.Context) error

func (*DockerExecutor) StopEnvironment

func (d *DockerExecutor) StopEnvironment(ctx context.Context, opts StopOptions) error

func (*DockerExecutor) Type

func (d *DockerExecutor) Type() string

func (*DockerExecutor) WithEnv

func (d *DockerExecutor) WithEnv(env map[string]string) Executor

func (*DockerExecutor) WithRelDir

func (d *DockerExecutor) WithRelDir(relDir string) Executor

type Executor

type Executor interface {
	ConsoleCommand(ctx context.Context, args ...string) *Process
	ComposerCommand(ctx context.Context, args ...string) *Process
	PHPCommand(ctx context.Context, args ...string) *Process
	NPMCommand(ctx context.Context, args ...string) *Process
	// AvailableLogFiles lists the .log files in the project's var/log
	// directory, most recently modified first.
	AvailableLogFiles(ctx context.Context) ([]LogFile, error)
	// GetLog streams the last lines of a var/log file to w, following new
	// output when follow is true. It blocks until the stream ends or ctx is
	// cancelled; cancellation (e.g. Ctrl-C while following) is not an error.
	GetLog(ctx context.Context, file string, lines int, follow bool, w io.Writer) error
	NormalizePath(hostPath string) string
	Type() string
	WithEnv(env map[string]string) Executor
	WithRelDir(relDir string) Executor
	StartEnvironment(ctx context.Context) error
	StopEnvironment(ctx context.Context, opts StopOptions) error
	EnvironmentStatus(ctx context.Context) (bool, error)
	AdminAPIClient(ctx context.Context) (*adminSdk.Client, error)
	// ShopConfig returns the project config with the selected environment's
	// url and admin_api applied.
	ShopConfig() *shop.Config
	// DatabaseConnection returns credentials to reach the project database
	// from the host machine.
	DatabaseConnection(ctx context.Context) (*DatabaseConnection, error)
}

func New

func New(projectRoot string, cfg *shop.EnvironmentConfig, shopCfg *shop.Config) (Executor, error)

func NewLocal

func NewLocal(projectRoot string) Executor

NewLocal returns a local executor for the given project root.

func NewLocalWithConfig

func NewLocalWithConfig(projectRoot string, cfg *shop.EnvironmentConfig, shopCfg *shop.Config) Executor

NewLocalWithConfig returns a local executor for the given project root and project configuration.

type LocalExecutor

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

func (*LocalExecutor) AdminAPIClient

func (l *LocalExecutor) AdminAPIClient(ctx context.Context) (*adminSdk.Client, error)

func (*LocalExecutor) AvailableLogFiles

func (l *LocalExecutor) AvailableLogFiles(_ context.Context) ([]LogFile, error)

func (*LocalExecutor) ComposerCommand

func (l *LocalExecutor) ComposerCommand(ctx context.Context, args ...string) *Process

func (*LocalExecutor) ConsoleCommand

func (l *LocalExecutor) ConsoleCommand(ctx context.Context, args ...string) *Process

func (*LocalExecutor) DatabaseConnection

func (l *LocalExecutor) DatabaseConnection(_ context.Context) (*DatabaseConnection, error)

func (*LocalExecutor) EnvironmentStatus

func (l *LocalExecutor) EnvironmentStatus(_ context.Context) (bool, error)

func (*LocalExecutor) GetLog

func (l *LocalExecutor) GetLog(ctx context.Context, file string, lines int, follow bool, w io.Writer) error

func (*LocalExecutor) NPMCommand

func (l *LocalExecutor) NPMCommand(ctx context.Context, args ...string) *Process

func (*LocalExecutor) NormalizePath

func (l *LocalExecutor) NormalizePath(hostPath string) string

func (*LocalExecutor) PHPCommand

func (l *LocalExecutor) PHPCommand(ctx context.Context, args ...string) *Process

func (*LocalExecutor) ShopConfig

func (l *LocalExecutor) ShopConfig() *shop.Config

func (*LocalExecutor) StartEnvironment

func (l *LocalExecutor) StartEnvironment(_ context.Context) error

func (*LocalExecutor) StopEnvironment

func (l *LocalExecutor) StopEnvironment(_ context.Context, _ StopOptions) error

func (*LocalExecutor) Type

func (l *LocalExecutor) Type() string

func (*LocalExecutor) WithEnv

func (l *LocalExecutor) WithEnv(env map[string]string) Executor

func (*LocalExecutor) WithRelDir

func (l *LocalExecutor) WithRelDir(relDir string) Executor

type LogFile

type LogFile struct {
	Name    string
	Size    int64
	ModTime time.Time
}

LogFile describes a log file in the project's var/log directory.

type Process

type Process struct {
	Cmd *exec.Cmd
	// contains filtered or unexported fields
}

func (*Process) CombinedOutput

func (p *Process) CombinedOutput() ([]byte, error)

func (*Process) Output

func (p *Process) Output() ([]byte, error)

func (*Process) Run

func (p *Process) Run() error

func (*Process) RunWithOutput

func (p *Process) RunWithOutput(w io.Writer) error

RunWithOutput runs the command and streams its combined stdout/stderr to w.

func (*Process) Start

func (p *Process) Start() error

func (*Process) StartCombined

func (p *Process) StartCombined() (io.ReadCloser, error)

StartCombined starts the command with its stdout and stderr merged into a single reader. Unlike RunWithOutput it does not block, and the returned reader reaches EOF once the process (and the read end of the pipe) is done, so a reader does not hang when the process is signaled to stop.

func (*Process) StderrPipe

func (p *Process) StderrPipe() (io.ReadCloser, error)

func (*Process) StdoutPipe

func (p *Process) StdoutPipe() (io.ReadCloser, error)

func (*Process) Stop

func (p *Process) Stop(ctx context.Context) error

func (*Process) Wait

func (p *Process) Wait() error

type SSHExecutor

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

SSHExecutor runs commands against a Shopware project on a remote host over SSH. Every invocation is a one-shot ssh call; repeated calls are cheap because they share a multiplexed master connection (ControlMaster / ControlPersist), so the TCP and authentication handshake happens only once.

func (*SSHExecutor) AdminAPIClient

func (s *SSHExecutor) AdminAPIClient(ctx context.Context) (*adminSdk.Client, error)

func (*SSHExecutor) AvailableLogFiles

func (s *SSHExecutor) AvailableLogFiles(ctx context.Context) ([]LogFile, error)

func (*SSHExecutor) ComposerCommand

func (s *SSHExecutor) ComposerCommand(ctx context.Context, args ...string) *Process

func (*SSHExecutor) ConsoleCommand

func (s *SSHExecutor) ConsoleCommand(ctx context.Context, args ...string) *Process

func (*SSHExecutor) DatabaseConnection

func (s *SSHExecutor) DatabaseConnection(ctx context.Context) (*DatabaseConnection, error)

DatabaseConnection resolves the database credentials from the remote project and routes the connection through the SSH host: the resolved host:port lives in the remote network, so the mysql driver is pointed at a registered dialer network that forwards each connection with `ssh -W`. Every MySQL connection spawns its own channel on the multiplexed SSH connection, so no persistent tunnel process has to be managed. When the database host is "localhost", PHP would connect through a unix socket, so the configured socket path is resolved on the remote host and forwarded instead of a TCP port.

func (*SSHExecutor) EnvironmentStatus

func (s *SSHExecutor) EnvironmentStatus(_ context.Context) (bool, error)

func (*SSHExecutor) GetLog

func (s *SSHExecutor) GetLog(ctx context.Context, file string, lines int, follow bool, w io.Writer) error

func (*SSHExecutor) NPMCommand

func (s *SSHExecutor) NPMCommand(ctx context.Context, args ...string) *Process

func (*SSHExecutor) NormalizePath

func (s *SSHExecutor) NormalizePath(hostPath string) string

NormalizePath translates a path below the local project root into the project directory on the remote host, mirroring the Docker executor. Paths outside the project root (or all paths when no project root is known) are returned unchanged.

func (*SSHExecutor) PHPCommand

func (s *SSHExecutor) PHPCommand(ctx context.Context, args ...string) *Process

func (*SSHExecutor) ShopConfig

func (s *SSHExecutor) ShopConfig() *shop.Config

func (*SSHExecutor) StartEnvironment

func (s *SSHExecutor) StartEnvironment(_ context.Context) error

func (*SSHExecutor) StopEnvironment

func (s *SSHExecutor) StopEnvironment(_ context.Context, _ StopOptions) error

func (*SSHExecutor) Type

func (s *SSHExecutor) Type() string

func (*SSHExecutor) WithEnv

func (s *SSHExecutor) WithEnv(env map[string]string) Executor

func (*SSHExecutor) WithRelDir

func (s *SSHExecutor) WithRelDir(relDir string) Executor

type StopOptions

type StopOptions struct {
	// RemoveVolumes also removes the named volumes declared in the compose
	// file, deleting all data stored in them.
	RemoveVolumes bool
}

StopOptions configures how the development environment is stopped.

type SymfonyCLIExecutor

type SymfonyCLIExecutor struct {
	BinaryPath string
	// contains filtered or unexported fields
}

func (*SymfonyCLIExecutor) AdminAPIClient

func (s *SymfonyCLIExecutor) AdminAPIClient(ctx context.Context) (*adminSdk.Client, error)

func (*SymfonyCLIExecutor) AvailableLogFiles

func (s *SymfonyCLIExecutor) AvailableLogFiles(_ context.Context) ([]LogFile, error)

func (*SymfonyCLIExecutor) ComposerCommand

func (s *SymfonyCLIExecutor) ComposerCommand(ctx context.Context, args ...string) *Process

func (*SymfonyCLIExecutor) ConsoleCommand

func (s *SymfonyCLIExecutor) ConsoleCommand(ctx context.Context, args ...string) *Process

func (*SymfonyCLIExecutor) DatabaseConnection

func (s *SymfonyCLIExecutor) DatabaseConnection(_ context.Context) (*DatabaseConnection, error)

func (*SymfonyCLIExecutor) EnvironmentStatus

func (s *SymfonyCLIExecutor) EnvironmentStatus(_ context.Context) (bool, error)

func (*SymfonyCLIExecutor) GetLog

func (s *SymfonyCLIExecutor) GetLog(ctx context.Context, file string, lines int, follow bool, w io.Writer) error

func (*SymfonyCLIExecutor) NPMCommand

func (s *SymfonyCLIExecutor) NPMCommand(ctx context.Context, args ...string) *Process

func (*SymfonyCLIExecutor) NormalizePath

func (s *SymfonyCLIExecutor) NormalizePath(hostPath string) string

func (*SymfonyCLIExecutor) PHPCommand

func (s *SymfonyCLIExecutor) PHPCommand(ctx context.Context, args ...string) *Process

func (*SymfonyCLIExecutor) ShopConfig

func (s *SymfonyCLIExecutor) ShopConfig() *shop.Config

func (*SymfonyCLIExecutor) StartEnvironment

func (s *SymfonyCLIExecutor) StartEnvironment(_ context.Context) error

func (*SymfonyCLIExecutor) StopEnvironment

func (s *SymfonyCLIExecutor) StopEnvironment(_ context.Context, _ StopOptions) error

func (*SymfonyCLIExecutor) Type

func (s *SymfonyCLIExecutor) Type() string

func (*SymfonyCLIExecutor) WithEnv

func (s *SymfonyCLIExecutor) WithEnv(env map[string]string) Executor

func (*SymfonyCLIExecutor) WithRelDir

func (s *SymfonyCLIExecutor) WithRelDir(relDir string) Executor

Jump to

Keyboard shortcuts

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