repolayout

package
v1.5.10 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 24 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 repolayout inspects a repository's file tree to suggest where its build context and Dockerfile should point, so a monorepo does not silently fall back to auto-detecting the repository root.

Index

Constants

View Source
const (
	ReasonTurboPrune     = "turbo_prune"
	ReasonRootCopy       = "root_copy"
	ReasonAppDeployDir   = "app_deploy_dir"
	ReasonRootDockerfile = "root_dockerfile"
	ReasonNestedDocker   = "nested_dockerfile"
	ReasonAppRailpack    = "app_railpack"
)

Suggestion reason codes. The dashboard translates these; Reason carries the same sentence in English for the CLI and API consumers.

View Source
const (
	ProviderGitHub = "github"
	ProviderGitLab = "gitlab"
	ProviderGitea  = "gitea"
)

Provider names for CommitSource.Provider.

View Source
const EnvMaxPackages = "APP_WIZARD_MAX_PACKAGES"

EnvMaxPackages caps how many workspace packages one analysis returns.

Variables

View Source
var ErrUnsupportedHost = errors.New("repolayout: no provider API for this host")

ErrUnsupportedHost means no provider API matches the repository URL, and the caller should fall back to a shallow in-memory clone.

Functions

func Affected

func Affected(changed []string, pkgs []Package) []string

Affected returns the directories of the packages whose watch paths match any changed file. Callers pass both sides of a rename. An empty diff affects nothing, so a no-op push never rebuilds every service.

func NewSSHDeployKeyAuth

func NewSSHDeployKeyAuth(user string, privateKeyPEM []byte) (transport.AuthMethod, error)

NewSSHDeployKeyAuth builds clone auth from a PEM deploy key. Host keys are checked against known_hosts by the transport, never skipped.

func PackageCap

func PackageCap() int

PackageCap is the effective package cap, read from the environment on each call.

Types

type Commit

type Commit struct {
	SHA        string    `json:"sha"`
	Message    string    `json:"message"`
	Author     string    `json:"author"`
	AuthoredAt time.Time `json:"authored_at"`
	URL        string    `json:"url,omitempty"`
}

Commit is one entry of a branch's history, reduced to what a deploy picker shows.

type CommitSource

type CommitSource interface {
	Provider() string
	Commits(ctx context.Context, limit int) ([]Commit, error)
	Branches(ctx context.Context) ([]string, error)
}

CommitSource lists recent commits and branches through a provider API.

type DefaultBrancher

type DefaultBrancher interface {
	DefaultBranch(ctx context.Context) (string, error)
}

DefaultBrancher is implemented by sources whose provider can name the repository's default branch, so callers need not guess main or master.

type Hosts

type Hosts struct {
	GitHub          string
	GitLab          string
	Gitea           string
	BitbucketServer string
}

Hosts names self-hosted instances so their API base can be inferred from a repository URL. The public hosts are always recognised.

type Package

type Package struct {
	Name       string   `json:"name"`
	Dir        string   `json:"dir"`
	Tool       string   `json:"tool"`
	Dockerfile string   `json:"dockerfile,omitempty"`
	DependsOn  []string `json:"depends_on"`
	// WatchPaths is the deploy filter that redeploys only this package:
	// its own directory, its workspace dependencies and the shared root files.
	WatchPaths []string `json:"watch_paths"`
}

Package is one workspace member that can run as its own service.

type Reader

type Reader func(p string, limit int) ([]byte, error)

Reader returns the first max bytes of a file, or an error when it cannot be read. Analyze treats a read failure as "no signal", never as a failure.

type Result

type Result struct {
	LooksLikeMonorepo bool         `json:"looks_like_monorepo"`
	RootHasApp        bool         `json:"root_has_app"`
	Tools             []string     `json:"tools"`
	Dockerfiles       []string     `json:"dockerfiles"`
	ComposeFiles      []string     `json:"compose_files"`
	Suggestions       []Suggestion `json:"suggestions"`
	Truncated         bool         `json:"truncated"`
	Packages          []Package    `json:"packages"`
	// PackagesTotal is the member count before the package cap, 0 when no workspace.
	PackagesTotal int `json:"packages_total,omitempty"`
	// StaticBuild is set when the repository root is a static-site
	// framework, to prefill the build command and publish directory.
	StaticBuild *StaticBuildSuggestion `json:"static_build,omitempty"`
}

Result is what detection found in one repository at one ref.

func Analyze

func Analyze(paths []string, read Reader) Result

Analyze inspects the file paths of a repository (blobs only, slash separated) and returns layout findings. read supplies file contents for the few files whose text decides a suggestion.

func Detect

func Detect(ctx context.Context, src Source) (Result, error)

Detect lists src and returns the layout analysis.

type Source

type Source interface {
	// Paths returns every blob path. truncated is true when the provider
	// capped the listing.
	Paths(ctx context.Context) (paths []string, truncated bool, err error)
	Read(ctx context.Context, p string, limit int) ([]byte, error)
}

Source lists a repository's files at one ref and reads single files, without cloning the repository to disk.

func NewAPISource

func NewAPISource(client *http.Client, repoURL, branch, token string, hosts Hosts) (Source, error)

NewAPISource picks a provider API source for repoURL. token may be empty for a public repository.

func NewCloneSource

func NewCloneSource(ctx context.Context, repoURL, branch, token string) (Source, error)

NewCloneSource fetches branch of repoURL at depth 1 into memory. Nothing is written to disk.

func NewCloneSourceAuth

func NewCloneSourceAuth(ctx context.Context, repoURL, branch string, auth transport.AuthMethod) (Source, error)

NewCloneSourceAuth is NewCloneSource with a caller-built auth method, used for ssh deploy keys. A nil auth clones anonymously.

type StaticBuildSuggestion

type StaticBuildSuggestion struct {
	PresetID   string `json:"preset_id"`
	PresetName string `json:"preset_name"`
	Command    string `json:"command"`
	PublishDir string `json:"publish_dir"`
}

StaticBuildSuggestion is a framework preset's build command and output directory.

type StatusError

type StatusError struct {
	Status int
	Body   string
}

StatusError is a non-2xx answer from a provider API.

func (*StatusError) Error

func (e *StatusError) Error() string

type Suggestion

type Suggestion struct {
	BuildType      string `json:"build_type"`
	DockerfilePath string `json:"dockerfile_path,omitempty"`
	BaseDirectory  string `json:"base_directory,omitempty"`
	Reason         string `json:"reason"`
	ReasonCode     string `json:"reason_code"`
	Recommended    bool   `json:"recommended"`
	Score          int    `json:"-"`
}

Suggestion is one candidate build setting.

Jump to

Keyboard shortcuts

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