Documentation
¶
Index ¶
- func AddSSHKey(ctx context.Context, client *circleci.Client, ...) (*circleci.AddSSHKeyResponse, error)
- func Create(ctx context.Context, client *circleci.Client, orgID, name, image string) (*circleci.Sandbox, error)
- func Exec(ctx context.Context, client *circleci.Client, sandboxID, command string, ...) (*circleci.ExecResponse, error)
- func InteractiveShell(ctx context.Context, session *Session, envVars map[string]string) (err error)
- func List(ctx context.Context, client *circleci.Client, orgID string) ([]circleci.Sandbox, error)
- func LoadEnvFileAt(path string) (_ map[string]string, err error)
- func MergeEnv(layers ...map[string]string) map[string]string
- func ParseEnvFile(r io.Reader) (map[string]string, error)
- func ParseEnvPairs(pairs []string) (map[string]string, error)
- func SSH(ctx context.Context, client *circleci.Client, ...) error
- func ShellEscape(arg string) string
- func ShellJoin(args []string) string
- func Sync(ctx context.Context, client *circleci.Client, ...) error
- type ExecResult
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InteractiveShell ¶ added in v0.7.1
InteractiveShell opens an interactive shell session to the sandbox with PTY. It intentionally uses os.Stdin/os.Stdout/os.Stderr directly rather than iostream.Streams: term.MakeRaw and term.GetSize require a real *os.File fd, and PTY I/O must be wired to the process's actual terminal.
func LoadEnvFileAt ¶ added in v0.7.12
LoadEnvFileAt reads the env file at path. Returns nil, nil if the file does not exist. Returns an error for permission or parse failures.
func MergeEnv ¶ added in v0.7.8
MergeEnv merges maps left to right; later layers win on duplicate keys.
func ParseEnvFile ¶ added in v0.7.8
ParseEnvFile reads dotenv-format KEY=VALUE lines from r. Supports blank lines, # comments, optional "export " prefix, and optional single/double quoting of values. No variable interpolation.
func ParseEnvPairs ¶ added in v0.7.8
ParseEnvPairs parses a slice of KEY=VALUE strings and returns a map. Returns an error if any entry does not contain "=".
func SSH ¶
func SSH(ctx context.Context, client *circleci.Client, sandboxID, identityFile, authSock string, args []string, envVars map[string]string, io iostream.Streams) error
SSH opens a session and either runs a command or starts an interactive shell.
func ShellEscape ¶
ShellEscape escapes a string for safe use in a POSIX shell single-quoted context.
func Sync ¶
func Sync(ctx context.Context, client *circleci.Client, sandboxID, identityFile, authSock, workdir string, io iostream.Streams) error
Sync synchronises local changes to a sandbox over SSH. It ensures the workspace base exists, clones the repo into workdir if absent, then resets to the remote base and applies a patch of local changes. workdir overrides the destination path; defaults to /workspace/<repo>.
Types ¶
type ExecResult ¶
ExecResult holds the output of a command executed over SSH.
type Session ¶
type Session struct {
URL string // sandbox domain
IdentityFile string // path to SSH private key (empty when using agent)
KnownHosts string // path to known_hosts file
UseAgent bool // true when authenticating via ssh-agent
AuthSock string // SSH_AUTH_SOCK path (only used when UseAgent is true)
}
Session holds the info needed to SSH into a sandbox. It is a plain value type with no open connections or resources to close. Each call to ExecOverSSH opens and closes its own SSH connection.
func OpenSession ¶
func OpenSession(ctx context.Context, client *circleci.Client, sandboxID, identityFile, authSock string) (*Session, error)
OpenSession registers an SSH key with the sandbox and returns session info. authSock is the SSH_AUTH_SOCK path; when non-empty and no identityFile is given, the agent is tried first.