sync

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckSecretsPerms

func CheckSecretsPerms(secretsDir string) error

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

func OverlayFiles(secretsDir string) ([]string, error)

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 Preflight

func Preflight(ctx context.Context, r execx.Runner) error

Preflight verifies git and rsync are runnable on the dev server.

func SourceFiles

func SourceFiles(ctx context.Context, r execx.Runner, worktree string) ([]string, error)

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.

func (*PermError) Error

func (e *PermError) Error() string

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.

func Sync

func Sync(ctx context.Context, r execx.Runner, opts Options) (stats Stats, err error)

Sync pushes the worktree's source files (and the secrets overlay, if any) to the target.

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.

func (Target) Dest

func (t Target) Dest() string

Dest returns the rsync destination, with a trailing slash: provr@<host>:/srv/provr/previews/<id>/src/ (or LocalDir/ for local targets). It assumes Validate passed.

func (Target) Validate

func (t Target) Validate() error

Validate checks the fields that end up in rsync's argv.

Jump to

Keyboard shortcuts

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