Documentation ¶
Index ¶
- Variables
- func AddFile(a Archive, file string) error
- func DownloadGo(csdb *ChecksumDB, version string) string
- func ExtractArchive(archive string, dest string) error
- func FindMainPackages(dir string) []string
- func MustRun(cmd *exec.Cmd)
- func MustRunCommand(cmd string, args ...string)
- func Render(templateFile, outputFile string, outputPerm os.FileMode, x interface{})
- func RenderString(templateContent, outputFile string, outputPerm os.FileMode, x interface{})
- func RunGit(args ...string) string
- func UploadSFTP(identityFile, host, dir string, files []string) error
- func WriteArchive(name string, files []string) (err error)
- type Archive
- type ChecksumDB
- type Environment
- type GoToolchain
- type TarballArchive
- type ZipArchive
Constants ¶
This section is empty.
Variables ¶
var ( // These flags override values in build env. GitCommitFlag = flag.String("git-commit", "", `Overrides git commit hash embedded into executables`) GitBranchFlag = flag.String("git-branch", "", `Overrides git branch being built`) GitTagFlag = flag.String("git-tag", "", `Overrides git tag being built`) BuildnumFlag = flag.String("buildnum", "", `Overrides CI build number`) PullRequestFlag = flag.Bool("pull-request", false, `Overrides pull request status of the build`) CronJobFlag = flag.Bool("cron-job", false, `Overrides cron job status of the build`) UbuntuVersionFlag = flag.String("ubuntu", "", `Sets the ubuntu version being built for`) )
var DryRunFlag = flag.Bool("n", false, "dry run, don't execute commands")
Functions ¶
func DownloadGo ¶
func DownloadGo(csdb *ChecksumDB, version string) string
DownloadGo downloads the Go binary distribution and unpacks it into a temporary directory. It returns the GOROOT of the unpacked toolchain.
func ExtractArchive ¶
ExtractArchive unpacks a .zip or .tar.gz archive to the destination directory.
func FindMainPackages ¶
FindMainPackages finds all 'main' packages in the given directory and returns their package paths.
func MustRunCommand ¶
func RenderString ¶
RenderString renders the given template string into outputFile.
func RunGit ¶
RunGit runs a git subcommand and returns its output. The command must complete successfully.
func UploadSFTP ¶
UploadSFTP uploads files to a remote host using the sftp command line tool. The destination host may be specified either as [user@]host: or as a URI in the form sftp://[user@]host[:port].
func WriteArchive ¶
WriteArchive creates an archive containing the given files.
Types ¶
type Archive ¶
type Archive interface { // Directory adds a new directory entry to the archive and sets the // directory for subsequent calls to Header. Directory(name string) error // Header adds a new file to the archive. The file is added to the directory // set by Directory. The content of the file must be written to the returned // writer. Header(os.FileInfo) (io.Writer, error) // Close flushes the archive and closes the underlying file. Close() error }
func NewTarballArchive ¶
func NewTarballArchive(w io.WriteCloser) Archive
func NewZipArchive ¶
func NewZipArchive(w io.WriteCloser) Archive
type ChecksumDB ¶
type ChecksumDB struct {
// contains filtered or unexported fields
}
ChecksumDB keeps file checksums.
func MustLoadChecksums ¶
func MustLoadChecksums(file string) *ChecksumDB
MustLoadChecksums loads a file containing checksums.
func (*ChecksumDB) DownloadFile ¶
func (db *ChecksumDB) DownloadFile(url, dstPath string) error
DownloadFile downloads a file and verifies its checksum.
func (*ChecksumDB) Verify ¶
func (db *ChecksumDB) Verify(path string) error
Verify checks whether the given file is valid according to the checksum database.
type Environment ¶
type Environment struct { CI bool Name string // name of the environment Repo string // name of GitHub repo Commit, Date, Branch, Tag string // Git info Buildnum string UbuntuVersion string // Ubuntu version being built for IsPullRequest bool IsCronJob bool }
Environment contains metadata provided by the build environment.
func Env ¶
func Env() Environment
Env returns metadata about the current CI environment, falling back to LocalEnv if not running on CI.
func LocalEnv ¶
func LocalEnv() Environment
LocalEnv returns build environment metadata gathered from git.
func (Environment) String ¶
func (env Environment) String() string
type GoToolchain ¶
type TarballArchive ¶
type TarballArchive struct {
// contains filtered or unexported fields
}
func (*TarballArchive) Close ¶
func (a *TarballArchive) Close() error
func (*TarballArchive) Directory ¶
func (a *TarballArchive) Directory(name string) error
type ZipArchive ¶
type ZipArchive struct {
// contains filtered or unexported fields
}
func (*ZipArchive) Close ¶
func (a *ZipArchive) Close() error
func (*ZipArchive) Directory ¶
func (a *ZipArchive) Directory(name string) error