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 ¶
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.
const ( ProviderGitHub = "github" ProviderGitLab = "gitlab" ProviderGitea = "gitea" )
Provider names for CommitSource.Provider.
const EnvMaxPackages = "APP_WIZARD_MAX_PACKAGES"
EnvMaxPackages caps how many workspace packages one analysis returns.
Variables ¶
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 ¶
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 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 ¶
DefaultBrancher is implemented by sources whose provider can name the repository's default branch, so callers need not guess main or master.
type Hosts ¶
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 ¶
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.
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 ¶
NewAPISource picks a provider API source for repoURL. token may be empty for a public repository.
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 ¶
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.