Documentation ¶
Index ¶
- Constants
- func Build(pkg *Package, opts ...BuildOption) (err error)
- func CopyWorkspace(dst string, workspace *Workspace, strict bool) error
- func DeleteNonWorkspaceFiles(dst string, workspace *Workspace, strict bool) (err error)
- func FindUnresolvedArguments(pkg *Package) ([]string, error)
- func FormatBUILDyaml(out io.Writer, in io.Reader, fixIssues bool) error
- func TopologicalSort(pkgs []*Package)
- func WatchSources(ctx context.Context, pkgs []*Package) (changed <-chan string, errs <-chan error)
- type Arguments
- type BuildOption
- func WithAdditionalRemoteCaches(caches []RemoteCache) BuildOption
- func WithBuildPlan(out io.Writer) BuildOption
- func WithCoverageOutputPath(output string) BuildOption
- func WithDontRetag(dontRetag bool) BuildOption
- func WithDontTest(dontTest bool) BuildOption
- func WithDryRun(dryrun bool) BuildOption
- func WithLocalCache(cache Cache) BuildOption
- func WithMaxConcurrentTasks(n int64) BuildOption
- func WithRemoteCache(cache RemoteCache) BuildOption
- func WithReporter(reporter Reporter) BuildOption
- type Cache
- type CacheLevel
- type Component
- type ConsoleReporter
- func (r *ConsoleReporter) BuildFinished(pkg *Package, err error)
- func (r *ConsoleReporter) BuildStarted(pkg *Package, status map[*Package]PackageBuildStatus)
- func (r *ConsoleReporter) PackageBuildFinished(pkg *Package, err error)
- func (r *ConsoleReporter) PackageBuildLog(pkg *Package, isErr bool, buf []byte)
- func (r *ConsoleReporter) PackageBuildStarted(pkg *Package)
- type DockerPkgConfig
- type EnvironmentManifest
- type EnvironmentManifestEntry
- type FilesystemCache
- type GSUtilRemoteCache
- type GenericPkgConfig
- type GoPackaging
- type GoPkgConfig
- type NoRemoteCache
- type Package
- func (p *Package) BuildLayoutLocation(dependency *Package) (loc string)
- func (p *Package) ContentManifest() ([]string, error)
- func (p *Package) DefinitionHash() (string, error)
- func (p *Package) FilesystemSafeName() string
- func (p *Package) FullName() string
- func (p *Package) GetDependencies() []*Package
- func (p *Package) GetTransitiveDependencies() []*Package
- func (p *Package) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (p *Package) Version() (string, error)
- func (p *Package) WriteVersionManifest(out io.Writer) error
- type PackageBuildStatus
- type PackageConfig
- type PackageNotFoundErr
- type PackageType
- type PackageVariant
- func (v *PackageVariant) Config(t PackageType) (cfg PackageConfig, ok bool)
- func (v *PackageVariant) ExcludeComponent(name string) bool
- func (v *PackageVariant) ResolveSources(workspace *Workspace, loc string) (incl []string, excl []string, err error)
- func (v *PackageVariant) UnmarshalYAML(unmarshal func(interface{}) error) error
- type PkgNotBuiltErr
- type RemoteCache
- type Reporter
- type Script
- type ScriptType
- type WerftReporter
- type WorkdirLayout
- type Workspace
- type YarnPackaging
- type YarnPkgConfig
Constants ¶
const ( // EnvvarCacheDir names the environment variable we take the cache dir location from EnvvarCacheDir = "LEEWAY_CACHE_DIR" // EnvvarBuildDir names the environment variable we take the build dir location from EnvvarBuildDir = "LEEWAY_BUILD_DIR" // EnvvarYarnMutex configures the mutex flag leeway will pass to yarn. // See https://yarnpkg.com/lang/en/docs/cli/#toc-concurrency-and-mutex for possible values. // Defaults to "network". EnvvarYarnMutex = "LEEWAY_YARN_MUTEX" )
const ( // BuiltinArgPackageVersion is a builtin argument/variable which contains the version of the package currently building BuiltinArgPackageVersion = "__pkg_version" // BuildinArgGitCommit is a builtin argument/variable which contains the current Git commit if the build is executed from within a Git working copy. // If this variable is used and the build is not executed from within a Git working copy the variable resolution will fail. BuildinArgGitCommit = "__git_commit" )
Variables ¶
This section is empty.
Functions ¶
func Build ¶
func Build(pkg *Package, opts ...BuildOption) (err error)
Build builds the packages in the order they're given. It's the callers responsibility to ensure the dependencies are built in order.
func CopyWorkspace ¶ added in v0.0.8
CopyWorkspace copies all folders/files from a workspace to a destination. If strict is true we'll only copy the files that leeway actully knows are source files. Otherwise we'll copy all files that are not excluded by the variant.
func DeleteNonWorkspaceFiles ¶ added in v0.0.8
DeleteNonWorkspaceFiles removes all files that do not belong to a workspace. If strict is true this function deletes all files that are not listed as source in a package. If strict is fales this function deletes files excluded by a variant.
func FindUnresolvedArguments ¶
FindUnresolvedArguments finds any still unresolved build arguments in a set of packages
func FormatBUILDyaml ¶ added in v0.0.8
FormatBUILDyaml formats a component's build.yaml file
func TopologicalSort ¶ added in v0.1.0
func TopologicalSort(pkgs []*Package)
TopologicalSort sorts the list of packages by its build order according to the dependency tree
Types ¶
type BuildOption ¶
type BuildOption func(*buildOptions) error
BuildOption configures the build behaviour
func WithAdditionalRemoteCaches ¶ added in v0.2.0
func WithAdditionalRemoteCaches(caches []RemoteCache) BuildOption
WithAdditionalRemoteCaches configures the remote cache
func WithBuildPlan ¶
func WithBuildPlan(out io.Writer) BuildOption
WithBuildPlan writes the build plan as JSON to the writer
func WithCoverageOutputPath ¶ added in v0.2.1
func WithCoverageOutputPath(output string) BuildOption
WithCoverageOutputPath configures coverage output directory
func WithDontRetag ¶ added in v0.2.4
func WithDontRetag(dontRetag bool) BuildOption
WithDontRetag disables the Docker image retagging
func WithDontTest ¶ added in v0.0.7
func WithDontTest(dontTest bool) BuildOption
WithDontTest disables package-level tests
func WithLocalCache ¶
func WithLocalCache(cache Cache) BuildOption
WithLocalCache configures the local cache
func WithMaxConcurrentTasks ¶ added in v0.2.0
func WithMaxConcurrentTasks(n int64) BuildOption
WithMaxConcurrentTasks limits the number of concurrent tasks during the build
func WithRemoteCache ¶
func WithRemoteCache(cache RemoteCache) BuildOption
WithRemoteCache configures the remote cache
func WithReporter ¶
func WithReporter(reporter Reporter) BuildOption
WithReporter sets the reporter which is notified about the build progress
type Cache ¶
type Cache interface { // Location returns the absolute filesystem path for a package build artifact Location(pkg *Package) (path string, exists bool) }
Cache provides filesystem locations for package build artifacts.
type CacheLevel ¶ added in v0.0.7
type CacheLevel string
CacheLevel describes a level of package cache
const ( // CacheUnspecified allows all downloads/uploads/caching operations CacheUnspecified CacheLevel = "" // CacheNone means no caching happens at all CacheNone CacheLevel = "none" // CacheLocal means a package is only cached locally CacheLocal CacheLevel = "local" // CacheRemote means a package is downloaded from and uploaded to a remote cache CacheRemote CacheLevel = "remote" // CacheRemotePush means a package is cached locally and possibly uploaded to a remote cache, // but it will never be downloaded from a remote cache. CacheRemotePush CacheLevel = "remote-push" // CacheRemotePull means a package is cached locally and possibly downloaded from a remote cache, // but it will never be uploaded to a remote cache. CacheRemotePull CacheLevel = "remote-pull" )
func (CacheLevel) RemoteDownload ¶ added in v0.0.7
func (c CacheLevel) RemoteDownload() bool
RemoteDownload returns true if this cache level permitts local download
func (CacheLevel) RemoteUpload ¶ added in v0.0.7
func (c CacheLevel) RemoteUpload() bool
RemoteUpload retruns true if the cache level permitts remote upload
func (*CacheLevel) UnmarshalYAML ¶ added in v0.0.7
func (c *CacheLevel) UnmarshalYAML(unmarshal func(interface{}) error) (err error)
UnmarshalYAML unmarshals and validates a package type
type Component ¶
type Component struct { // W is the workspace this component belongs to W *Workspace // Origin is the absolute location of this Component in the filepath Origin string // Name is the name of the Component as computed from its location in the workspace Name string Constants Arguments `yaml:"const"` Packages []*Package `yaml:"packages"` Scripts []*Script `yaml:"scripts"` }
Component contains a single component that we wish to build
type ConsoleReporter ¶
type ConsoleReporter struct {
// contains filtered or unexported fields
}
ConsoleReporter reports build progress by printing to stdout/stderr
func NewConsoleReporter ¶
func NewConsoleReporter() *ConsoleReporter
NewConsoleReporter produces a new console logger
func (*ConsoleReporter) BuildFinished ¶
func (r *ConsoleReporter) BuildFinished(pkg *Package, err error)
BuildFinished is called when the build of a package whcih was started by the user has finished.
func (*ConsoleReporter) BuildStarted ¶
func (r *ConsoleReporter) BuildStarted(pkg *Package, status map[*Package]PackageBuildStatus)
BuildStarted is called when the build of a package is started by the user.
func (*ConsoleReporter) PackageBuildFinished ¶
func (r *ConsoleReporter) PackageBuildFinished(pkg *Package, err error)
PackageBuildFinished is called when the package build has finished.
func (*ConsoleReporter) PackageBuildLog ¶
func (r *ConsoleReporter) PackageBuildLog(pkg *Package, isErr bool, buf []byte)
PackageBuildLog is called during a package build whenever a build command produced some output.
func (*ConsoleReporter) PackageBuildStarted ¶
func (r *ConsoleReporter) PackageBuildStarted(pkg *Package)
PackageBuildStarted is called when a package build actually gets underway.
type DockerPkgConfig ¶
type DockerPkgConfig struct { Dockerfile string `yaml:"dockerfile,omitempty"` Image []string `yaml:"image,omitempty"` BuildArgs map[string]string `yaml:"buildArgs,omitempty"` Squash bool `yaml:"squash,omitempty"` Metadata map[string]string `yaml:"metadata,omitempty"` }
DockerPkgConfig configures a Docker package
func (DockerPkgConfig) AdditionalSources ¶
func (cfg DockerPkgConfig) AdditionalSources() []string
AdditionalSources returns a list of unresolved sources coming in through this configuration
type EnvironmentManifest ¶ added in v0.2.0
type EnvironmentManifest []EnvironmentManifestEntry
EnvironmentManifest is a collection of environment manifest entries
func (EnvironmentManifest) Hash ¶ added in v0.2.0
func (mf EnvironmentManifest) Hash() (string, error)
Hash produces the hash of this manifest
type EnvironmentManifestEntry ¶ added in v0.2.0
type EnvironmentManifestEntry struct { Name string `yaml:"name"` Command []string `yaml:"command"` Value string `yaml:"-"` Builtin bool `yaml:"-"` }
EnvironmentManifestEntry represents an entry in the environment manifest
type FilesystemCache ¶
type FilesystemCache struct {
Origin string
}
FilesystemCache implements a flat folder cache
func NewFilesystemCache ¶
func NewFilesystemCache(location string) (*FilesystemCache, error)
NewFilesystemCache creates a new filesystem cache
type GSUtilRemoteCache ¶
type GSUtilRemoteCache struct {
BucketName string
}
GSUtilRemoteCache uses the gsutil command to implement a remote cache
type GenericPkgConfig ¶
type GenericPkgConfig struct {
Commands [][]string `yaml:"commands"`
}
GenericPkgConfig configures a generic package
func (GenericPkgConfig) AdditionalSources ¶
func (cfg GenericPkgConfig) AdditionalSources() []string
AdditionalSources returns a list of unresolved sources coming in through this configuration
type GoPackaging ¶
type GoPackaging string
GoPackaging configures the packaging method of a Go package
const ( // GoLibrary means the package can be imported in another package GoLibrary GoPackaging = "library" // GoApp runs go build and tars the build directory GoApp GoPackaging = "app" )
type GoPkgConfig ¶
type GoPkgConfig struct { Packaging GoPackaging `yaml:"packaging,omitempty"` Generate bool `yaml:"generate,omitempty"` DontTest bool `yaml:"dontTest,omitempty"` DontCheckGoFmt bool `yaml:"dontCheckGoFmt,omitempty"` DontLint bool `yaml:"dontLint,omitempty"` BuildFlags []string `yaml:"buildFlags,omitempty"` BuildCommand []string `yaml:"buildCommand,omitempty"` LintCommand []string `yaml:"lintCommand,omitempty"` GoVersion string `yaml:"goVersion,omitempty"` }
GoPkgConfig configures a Go package
func (GoPkgConfig) AdditionalSources ¶
func (cfg GoPkgConfig) AdditionalSources() []string
AdditionalSources returns a list of unresolved sources coming in through this configuration
func (GoPkgConfig) Validate ¶
func (cfg GoPkgConfig) Validate() error
Validate ensures this config can be acted upon/is valid
type NoRemoteCache ¶
type NoRemoteCache struct{}
NoRemoteCache implements the default no-remote cache behavior
type Package ¶
type Package struct { C *Component Config PackageConfig `yaml:"config"` // Definition is the raw package definition YAML Definition []byte `yaml:"-"` // contains filtered or unexported fields }
Package is a single buildable artifact within a component
func (*Package) BuildLayoutLocation ¶ added in v0.1.1
BuildLayoutLocation returns the filesystem path a dependency is expected at during the build. This path will always be relative. If the provided package is not a depedency of this package, we'll still return a valid path.
func (*Package) ContentManifest ¶
ContentManifest produces an ordered list of content hashes (<filename>:<hash>) for each source file. Expects the sources to be resolved.
func (*Package) DefinitionHash ¶ added in v0.0.8
DefinitionHash hashes the package definition
func (*Package) FilesystemSafeName ¶
FilesystemSafeName returns a string that is safe to use in a Unix filesystem as directory or filename
func (*Package) GetDependencies ¶
GetDependencies returns the linked package dependencies or nil if not linked yet
func (*Package) GetTransitiveDependencies ¶
GetTransitiveDependencies returns all transitive dependencies of a package.
func (*Package) UnmarshalYAML ¶
UnmarshalYAML unmarshals the package definition
type PackageBuildStatus ¶
type PackageBuildStatus string
PackageBuildStatus denotes the status of a package during build
const ( // PackageNotBuiltYet means that the package has not been built yet PackageNotBuiltYet PackageBuildStatus = "not-built-yet" // PackageBuilding means we're building this package at the moment PackageBuilding PackageBuildStatus = "building" // PackageBuilt means the package has been built already PackageBuilt PackageBuildStatus = "built" )
type PackageConfig ¶
type PackageConfig interface {
AdditionalSources() []string
}
PackageConfig is the YAML unmarshalling config type of packages. This is one of YarnPkgConfig, GoPkgConfig, DockerPkgConfig or GenericPkgConfig.
type PackageNotFoundErr ¶
type PackageNotFoundErr struct {
Package string
}
PackageNotFoundErr is used when something references a package we don't know about
func (PackageNotFoundErr) Error ¶
func (n PackageNotFoundErr) Error() string
type PackageType ¶
type PackageType string
PackageType describes the way a package is built and what it produces
const ( // DeprecatedTypescriptPackage runs tsc in a package and produces a yarn offline mirror DeprecatedTypescriptPackage PackageType = "typescript" // YarnPackage uses the yarn package manager to download dependencies and build the package YarnPackage PackageType = "yarn" // GoPackage runs go build and produces a binary file GoPackage PackageType = "go" // DockerPackage runs docker build DockerPackage PackageType = "docker" // GenericPackage runs an arbitary shell command GenericPackage PackageType = "generic" )
func (*PackageType) UnmarshalYAML ¶ added in v0.0.7
func (p *PackageType) UnmarshalYAML(unmarshal func(interface{}) error) (err error)
UnmarshalYAML unmarshals and validates a package type
type PackageVariant ¶ added in v0.0.8
type PackageVariant struct {
// contains filtered or unexported fields
}
PackageVariant provides a variation point for a package's sources, environment variables and config.
func (*PackageVariant) Config ¶ added in v0.0.8
func (v *PackageVariant) Config(t PackageType) (cfg PackageConfig, ok bool)
Config returns this package variants configuration
func (*PackageVariant) ExcludeComponent ¶ added in v0.2.0
func (v *PackageVariant) ExcludeComponent(name string) bool
ExcludeComponent returns true if this variants excludes the component
func (*PackageVariant) ResolveSources ¶ added in v0.0.8
func (v *PackageVariant) ResolveSources(workspace *Workspace, loc string) (incl []string, excl []string, err error)
ResolveSources lists all files which are explicitely included or excluded by this variant. Inclusion takes precedence over exclusion.
func (*PackageVariant) UnmarshalYAML ¶ added in v0.0.8
func (v *PackageVariant) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML unmarshals a package variant
type PkgNotBuiltErr ¶
type PkgNotBuiltErr struct {
Package *Package
}
PkgNotBuiltErr is used when a package's dependency hasn't been built yet
func (PkgNotBuiltErr) Error ¶
func (p PkgNotBuiltErr) Error() string
type RemoteCache ¶
type RemoteCache interface { // Download makes a best-effort attempt at downloading previously cached build artifacts for the given packages // in their current version. A cache miss (i.e. a build artifact not being available) does not constitute an // error. Get should try and download as many artifacts as possible. Download(dst Cache, pkgs []*Package) error // Upload makes a best effort to upload the build arfitacts to a remote cache. If uploading an artifact fails, that // does not constitute an error. Upload(src Cache, pkgs []*Package) error }
RemoteCache can download and upload build artifacts into a local cache
type Reporter ¶
type Reporter interface { // BuildStarted is called when the build of a package is started by the user. // This is not the same as a dependency beeing built (see PackageBuildStarted for that). // The root package will also be passed into PackageBuildStarted once all its depepdencies // have been built. BuildStarted(pkg *Package, status map[*Package]PackageBuildStatus) // BuildFinished is called when the build of a package whcih was started by the user has finished. // This is not the same as a dependency build finished (see PackageBuildFinished for that). // The root package will also be passed into PackageBuildFinished once it's been built. BuildFinished(pkg *Package, err error) // PackageBuildStarted is called when a package build actually gets underway. At this point // all transitive dependencies of the package have been built. PackageBuildStarted(pkg *Package) // PackageBuildLog is called during a package build whenever a build command produced some output. PackageBuildLog(pkg *Package, isErr bool, buf []byte) // PackageBuildFinished is called when the package build has finished. If an error is passed in // the package build was not succesfull. PackageBuildFinished(pkg *Package, err error) }
Reporter provides feedback about the build progress to the user.
Implementers beware: all these functions will be called in the hotpath of the build system.
That means that blocking in those functions will block the actual build.
type Script ¶ added in v0.0.8
type Script struct { C *Component Name string `yaml:"name"` Description string `yaml:"description"` Dependencies []string `yaml:"deps"` Environment []string `yaml:"env"` WorkdirLayout WorkdirLayout `yaml:"workdir"` Type ScriptType `yaml:"type"` Script string `yaml:"script"` // contains filtered or unexported fields }
Script is an executable, uncacheable unit that does not result in build artefacts
func (*Script) FilesystemSafeName ¶ added in v0.0.8
FilesystemSafeName returns a string that is safe to use in a Unix filesystem as directory or filename
func (*Script) FullName ¶ added in v0.0.8
FullName returns the packages fully qualified name (component:package)
func (*Script) GetDependencies ¶ added in v0.0.8
GetDependencies returns the linked package dependencies or nil if not linked yet
func (*Script) Run ¶ added in v0.0.8
func (p *Script) Run(opts ...BuildOption) error
Run executes the script
type ScriptType ¶ added in v0.0.8
type ScriptType string
ScriptType defines the type a script is of
const ( // BashScript means the script is executed by bash. // The shebang is added automatically. BashScript ScriptType = "bash" )
type WerftReporter ¶
type WerftReporter struct {
*ConsoleReporter
}
WerftReporter works like the console reporter but adds werft output
func NewWerftReporter ¶
func NewWerftReporter() *WerftReporter
NewWerftReporter craetes a new werft compatible reporter
func (*WerftReporter) BuildStarted ¶
func (r *WerftReporter) BuildStarted(pkg *Package, status map[*Package]PackageBuildStatus)
BuildStarted is called when the build of a package is started by the user.
func (*WerftReporter) PackageBuildFinished ¶
func (r *WerftReporter) PackageBuildFinished(pkg *Package, err error)
PackageBuildFinished is called when the package build has finished.
type WorkdirLayout ¶ added in v0.0.8
type WorkdirLayout string
WorkdirLayout describes the layout of the working dir a script gets executed in
const ( // WorkdirOrigin means the script is executed in the original location of the component where it's defined, // in the original workspace. WorkdirOrigin WorkdirLayout = "origin" // WorkdirPackages replicates the structure leeway produces during a package build based on the script's dependencies. WorkdirPackages WorkdirLayout = "packages" )
type Workspace ¶
type Workspace struct { DefaultTarget string `yaml:"defaultTarget,omitempty"` ArgumentDefaults map[string]string `yaml:"defaultArgs,omitempty"` DefaultVariant *PackageVariant `yaml:"defaultVariant,omitempty"` Variants []*PackageVariant `yaml:"variants,omitempty"` EnvironmentManifest EnvironmentManifest `yaml:"environmentManifest,omitempty"` Origin string `yaml:"-"` Components map[string]*Component `yaml:"-"` Packages map[string]*Package `yaml:"-"` Scripts map[string]*Script `yaml:"-"` SelectedVariant *PackageVariant `yaml:"-"` // contains filtered or unexported fields }
Workspace is the root container of all compoments. All components are named relative to the origin of this workspace.
func FindNestedWorkspaces ¶ added in v0.0.8
FindNestedWorkspaces loads nested workspaces
func FindWorkspace ¶
FindWorkspace looks for a WORKSPACE.yaml file within the path. If multiple such files are found, an error is returned.
func (*Workspace) ShouldIgnoreComponent ¶ added in v0.2.0
ShouldIgnoreComponent returns true if a file should be ignored for a component listing
func (*Workspace) ShouldIgnoreSource ¶ added in v0.2.0
ShouldIgnoreSource returns true if a file should be ignored for a source listing
type YarnPackaging ¶ added in v0.1.0
type YarnPackaging string
YarnPackaging configures the packaging method of a yarn package
const ( // YarnLibrary means the package will be created using `yarn pack` YarnLibrary YarnPackaging = "library" // YarnOfflineMirror means that the package will become a yarn offline mirror YarnOfflineMirror YarnPackaging = "offline-mirror" // YarnApp installs the package using an empty package.json and tars the resulting node_modules/ YarnApp YarnPackaging = "app" // YarnArchive simply tars the build directory YarnArchive YarnPackaging = "archive" )
type YarnPkgConfig ¶ added in v0.1.0
type YarnPkgConfig struct { YarnLock string `yaml:"yarnLock,omitempty"` TSConfig string `yaml:"tsconfig"` Packaging YarnPackaging `yaml:"packaging,omitempty"` DontTest bool `yaml:"dontTest,omitempty"` Commands struct { Install []string `yaml:"install,omitempty"` Build []string `yaml:"build,omitempty"` Test []string `yaml:"test,omitempty"` } `yaml:"commands,omitempty"` }
YarnPkgConfig configures a yarn package
func (YarnPkgConfig) AdditionalSources ¶ added in v0.1.0
func (cfg YarnPkgConfig) AdditionalSources() []string
AdditionalSources returns a list of unresolved sources coming in through this configuration
func (YarnPkgConfig) Validate ¶ added in v0.1.0
func (cfg YarnPkgConfig) Validate() error
Validate ensures this config can be acted upon/is valid