Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoVersionFile = errors.New("no VERSION file found") ErrMultipleVersionFiles = errors.New("multiple VERSION files found") // WorktreeStateFunc can be overridden in tests to generate stable // source hashes and dirty file lists. WorktreeStateFunc = getWorktreeState )
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct { // Name is the base name of the file. Name string // OriginalPath is the absolute path this file was written to. OriginalPath string // Size is the size of the file in bytes. Size int64 // SHA256Sum is the digest of the file. SHA256Sum string }
File is a file produced during the build.
type FileHashes ¶
func NewFileHashes ¶
func NewFileHashes(desc, primaryPath, verificationPath string) (FileHashes, error)
type FilePair ¶
type FilePair struct {
Primary, Verification File
}
FilePair represents a pair of files that should be identical. (The primary and verirication build's version of each file.)
type FileSetHashes ¶
type FileSetHashes struct { Bin FileHashes Zip FileHashes AllMatch bool }
func NewFileSetHashes ¶
func NewFileSetHashes(bin, zip FileHashes) FileSetHashes
func (FileSetHashes) Error ¶
func (fsh FileSetHashes) Error() error
type HashPair ¶
func NewHashPair ¶
type Product ¶
type Product struct { // Repository is the product repository URL minus the scheme. // E.g. github.com/hashicorp/lockbox Repository string `env:"PRODUCT_REPOSITORY"` // Module is the name of the Go module this product is defined in. Module string // Name is the product name. This is used to derive the default names // for the executable binary, the zip package, deb and rpm packages, // container image tags, and other artifacts in the future. // // Name defaults to the last path segment of Repository, when running // in the root of the repository. Otherwise it defaults to the base name of // the working directory in which the product is built. Name string `env:"PRODUCT_NAME"` // CoreName is the product's core name. This is the same as Name, // minus any "-enterprise" suffix. This is a derived value not read from // the env directly. CoreName string // ExecutableName is the name of the executable binary representing this // product. Defaults to CoreName. ExecutableName string `env:"BIN_NAME"` // Version is the version of the product being built. Version ProductVersion // Revision is the commit SHA of the product being built. Revision string // RevisionTime is the commit timestamp of Revision in RFC3339 format. // This is useful when we need to include a timestamp in a binary whilst // keeping the binary reproducible. (It can be used as a sort of "build // time"). RevisionTime string // SourceHash is either the same as the Revision if the worktree is not // dirty, or else it's a SHA1 hash of the HEAD commit plus all the contents // of all dirty files. SourceHash string DirtyFiles []string `json:",omitempty"` }
Product represents a single logical product. There may be multiple products per repository. One product typically maps to multiple Go binaries (one per platform). It may also map to different binaries based on different build parameters e.g. build tags being used.
func (Product) VersionCommandOutput ¶
func (Product) VersionCommandOutputShort ¶
type ProductVersion ¶
type ProductVersion struct { // Full is the full version string made up of Core + Meta. // If this is set externally, then `Meta` must not also be set, if it is // that's a validation error. Full string `env:"PRODUCT_VERSION"` // Core is the base version + prerelease, not including any metadata. // It is used alongside Name to derive default names for the zip package, // deb and rpm packages, and container image tags. Core string // Meta is the metadata portion of the version string. Meta string `env:"PRODUCT_VERSION_META"` }
func NewProductVersion ¶
func NewProductVersion(coreVersion, fullVersion string) (ProductVersion, error)
NewProductVersion accepts a coreVersion and a fullVersion. The fullVersion may be empty, in which case the full version will be set to coreVersion-local indicating a "local" build, without proper version information. If the coreVersion is also empty, then we set it to 0.0.0-unversioned.
func (ProductVersion) Init ¶
func (pv ProductVersion) Init() (ProductVersion, error)
Init ensures that all fields in the ProductVersion are consistent, and fills in any missing fields.
func (ProductVersion) InitWithCoreVersion ¶
func (pv ProductVersion) InitWithCoreVersion(coreVersion string) (ProductVersion, error)
func (ProductVersion) String ¶
func (p ProductVersion) String() string
type RepoContext ¶
type RepoContext struct { RepoName string ModuleName string Dir string RootDir string CommitSHA string CommitTime time.Time CoreVersion version.Version SourceHash string DirtyFiles []string `json:",omitempty"` }
func GetRepoContext ¶
func GetRepoContext(dir string, ignoreDirs []string) (RepoContext, error)
GetRepoContext reads the repository context from the directory specified.
func (RepoContext) IsDirty ¶
func (rc RepoContext) IsDirty() bool
IsDirty returns true if the worktree is dirty, ignoring the dist, out, and meta directories.