Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Docker describes the docker dependency Docker = &Dependency{ Bin: "docker", } // Yamllint describes the yamllint dependency Yamllint = &Dependency{ Bin: "yamllint", } // Golint describes the golint dependency Golint = &Dependency{ Bin: "golint", GoInstall: []string{"golang.org/x/lint/golint@latest"}, } // Htmltest describes the htmltest dependency Htmltest = &Dependency{ Bin: "htmltest", GoInstall: []string{"github.com/wjdp/htmltest@latest"}, } // Hugo describes the hugo dependency Hugo = &Dependency{ Bin: "hugo", Env: map[string]string{"CGO_ENABLED": "1"}, GoInstall: []string{"-tags", "extended", "github.com/gohugoio/hugo@latest"}, } // DartSass describes the Dart Sass dependency (https://sass-lang.com). // Version is intentionally unset — the latest published release is resolved // automatically via the GitHub API. Pin it in consumer code when reproducibility // is required: // // deps.DartSass.GithubRelease.Version = "1.103.1" DartSass = &Dependency{ Bin: "sass", GithubRelease: &GithubRelease{ Repo: "sass/dart-sass", AssetPattern: "dart-sass-{{.Version}}-{{.OS}}-{{.Arch}}.tar.gz", BinPath: "dart-sass/sass", }, } )
var ( // ExternalDependencies define the external app dependencies needed // to fullfill all automation tasks ExternalDependencies = []*Dependency{ Golint, } )
Functions ¶
func CheckDependencies ¶
func CheckDependencies(ctx context.Context, dependencies ...*Dependency) error
CheckDependencies determines if provided dependencies are available. If binary is not available os.ErrNotExist is returned
func InstallDependencies ¶
func InstallDependencies(ctx context.Context, dependencies ...*Dependency) (bool, error)
InstallDependencies makes sure to install provided dependencies and return if all installing all dependencies were successful
Types ¶
type Dependency ¶
type Dependency struct {
Bin string
// GoInstall holds the arguments passed to `go install` (build flags + package path).
// Example: []string{"-tags", "extended", "github.com/gohugoio/hugo@latest"}
GoInstall []string
// Env holds optional environment variables set when running go install.
// Example: map[string]string{"CGO_ENABLED": "1"}
Env map[string]string
// GithubRelease, when set, installs the binary by downloading a GitHub release asset.
// Mutually exclusive with GoInstall.
GithubRelease *GithubRelease
}
Dependency encapsulates attributes of a depending application
type GithubRelease ¶ added in v1.7.0
type GithubRelease struct {
// Repo is "owner/repo", e.g. "sass/dart-sass"
Repo string
// Version is the release tag, e.g. "1.103.1". Empty = resolve latest via API.
Version string
// AssetPattern is a Go text/template applied to [ReleaseAssetData] to produce
// the asset filename. Example: "dart-sass-{{.Version}}-{{.OS}}-{{.Arch}}.tar.gz"
AssetPattern string
// BinPath is the relative path inside the extracted archive to the binary.
// Example: "dart-sass/sass"
BinPath string
// InstallDir is the directory where the binary is placed.
// Defaults to $GOPATH/bin, then $HOME/.local/bin.
InstallDir string
}
GithubRelease describes how to fetch a binary from a GitHub Releases asset. AssetPattern is a Go text/template rendered with ReleaseAssetData. BinPath is the relative path inside the extracted archive to the executable. InstallDir is optional; defaults to the directory returned by [defaultInstallDir]. Version is optional; when empty the latest published release is resolved via the GitHub API.
type Installable ¶
type Installable interface {
Install() error
}
Installable describes something that can be installed
type ReleaseAssetData ¶ added in v1.7.0
type ReleaseAssetData struct {
// Version is the resolved release tag, e.g. "1.103.1"
Version string
// OS is the GOOS-mapped value used in release asset names: "linux", "macos", "windows"
OS string
// Arch is the GOARCH-mapped value used in release asset names: "x64", "arm64", "arm"
Arch string
}
ReleaseAssetData is the template context available in GithubRelease.AssetPattern.