Documentation
¶
Overview ¶
Package render implements the template rendering related subcommands.
Index ¶
Constants ¶
const ( LocTypeLocalGit = "local_git" LocTypeRemoteGit = "remote_git" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DownloadMetadata ¶
type DownloadMetadata struct { // A "canonical" location is one that's the same for everybody. When // installing a template source like // "~/my_downloaded_templates/foo_template", that location is not canonical, // because not every has that directory downloaded on their machine. On the // other hand, a template location like // github.com/abcxyz/gcp-org-terraform-template *is* canonical because // everyone everywhere can access it by that name. // // Canonical template locations are preferred because they make automatic // template upgrades easier. Given a destination directory that is the // output of a template, we can easily upgrade it if we know the canonical // location of the template that created it. We just go look for new git // tags at the canonical location. // // A local template directory is not a canonical location except for one // special case: when the template source directory and the destination // directory are within the same repo. This supports the case where a single // git repo contains templates that are rendered into that repo. Since the // relative path between the template directory and the destination // directory are the same for everyone who clones the repo, that means the // relative path counts as a canonical source. // // IsCanonical is true if and only if CanonicalSource and LocationType are // non-empty. IsCanonical bool CanonicalSource string LocationType string // Depending on where the template was taken from, there might be a version // string associated with it (e.g. a git tag or a git SHA). // // HasVersion is true if and only if Version is non-empty. HasVersion bool Version string // Values for template variables like _git_tag and _git_sha. Vars DownloaderVars }
type Downloader ¶
type Downloader interface { // Download downloads this template into the given directory. Download(ctx context.Context, cwd, destDir string) (*DownloadMetadata, error) }
A Downloader is returned by a sourceParser. It offers the ability to download a template, and provides some metadata.
func ForUpgrade ¶ added in v0.6.0
func ForUpgrade(ctx context.Context, canonicalLocation, locType, gitProtocol, destDir string) (Downloader, error)
ForUpgrade takes a location type and canonical location from a manifest file, and returns a downloader that will download the latest version of that template.
func ParseSource ¶
func ParseSource(ctx context.Context, params *ParseSourceParams) (Downloader, error)
ParseSource maps the input template source to a particular kind of source (e.g. git) and returns a downloader that will download that source.
source is a template location, like "github.com/foo/bar@v1.2.3". protocol is the value of the --protocol flag, like "https".
A list of sourceParsers is accepted as input for the purpose of testing, rather than hardcoding the real list of sourceParsers.
type DownloaderVars ¶ added in v0.5.0
Values for template variables like _git_tag and _git_sha.
type LocalDownloader ¶ added in v0.6.0
type LocalDownloader struct { // This path uses the OS-native file separator and is an absolute path. SrcPath string // contains filtered or unexported fields }
LocalDownloader implements Downloader.
func (*LocalDownloader) Download ¶ added in v0.6.0
func (l *LocalDownloader) Download(ctx context.Context, cwd, destDir string) (*DownloadMetadata, error)
type ParseSourceParams ¶
type ParseSourceParams struct { // The working directory that we're in. Used to resolve relative paths. CWD string // Source could be any of the template source types we accept. Examples: // - github.com/foo/bar@latest // - /a/local/path // - a/relative/path // // In the case where the source is a local filesystem path, it uses native // filesystem separators. Source string // The value of --git-protocol. GitProtocol string }
ParseSourceParams contains the arguments to ParseSource.