Documentation
¶
Overview ¶
Package sync copies a project's working tree to the test host: worktree to a local staging directory to the host, followed by a secrets overlay that adds files which are deliberately not tracked by git.
Index ¶
- func CheckSecretsPerms(secretsDir string) error
- func OverlayFiles(secretsDir string) ([]string, error)
- func Preflight(ctx context.Context, r execx.Runner) error
- func SourceFiles(ctx context.Context, r execx.Runner, worktree string) ([]string, error)
- type Options
- type PermError
- type Stats
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckSecretsPerms ¶
CheckSecretsPerms fails with a *PermError if any file or directory under secretsDir (the root included) has any of the 0o077 mode bits set. Only paths are reported, never contents. An empty secretsDir is a no-op.
func OverlayFiles ¶
OverlayFiles returns the repo-relative, slash-separated paths of the regular files under secretsDir, sorted. An empty secretsDir means no overlay is configured and yields nil, nil.
The overlay is deliberately simple and predictable: symlinks and any other non-regular entries are rejected, as is any path with a .git component. Because the paths are later used as rsync protect filters, names containing the rsync wildcard characters '*', '?', '[' or a newline are rejected too.
func SourceFiles ¶
SourceFiles returns the repo-relative, slash-separated files that make up the worktree's source: tracked and untracked files that are not ignored. Files deleted from disk and anything inside a .git directory are dropped. Order follows git's output.
Types ¶
type Options ¶
type Options struct {
// Worktree is the source git worktree.
Worktree string
// SecretsDir is the optional secrets overlay directory; "" disables it.
SecretsDir string
// Target is the destination.
Target Target
// contains filtered or unexported fields
}
Options configures one Sync.
type PermError ¶
type PermError struct {
Dir string
Paths []string // offending paths, relative to Dir ("." is the root)
}
PermError reports files or directories in the secrets directory that are accessible to group or others.
type Stats ¶
type Stats struct {
Files int // files transferred by the push
Bytes int64
OverlayFiles int
Duration time.Duration
}
Stats summarizes a Sync. Overlay sizes are deliberately not reported.
type Target ¶
type Target struct {
// Host is the tailnet hostname of the preview host.
Host string
// User is the SSH user; empty means "provr".
User string
// PreviewID selects /srv/provr/previews/<id>/src/ on the host.
PreviewID string
// LocalDir is a local destination directory (test seam only). Only
// honored when Host is empty.
LocalDir string
}
Target is where a Preview's source tree is pushed.
A remote Target has a Host (tailnet hostname) and a PreviewID. A Target with an empty Host and a non-empty LocalDir is a plain local destination with no ssh; it exists as a test seam only.