internal

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const TerraformBlockType string = "module"

TerraformBlockType denotes the parent block type for a source ref in a terraform file

View Source
const TerragruntBlockType string = "terraform"

TerragruntBlockType denotes the parent block type for a source ref in a terragrunt file

Variables

View Source
var SourceCache sourceCache

SourceCache is a global cache of repo URL's and available remote versions, used to reduce network calls to find verisons.

Functions

func RemoteTags

func RemoteTags(repositoryURL string) (semver.Collection, error)

RemoteTags returns a colelction of SemVer tags, if the tags are not in SemVer format and Error is returned.

Types

type BlockSource

type BlockSource struct {
	Name string
	// contains filtered or unexported fields
}

BlockSource contains the name of a given module containing a source ref,in the case of terraform this is file path + module name, in the case of terragrunt it's the filepath only. This also contains the raw URL extracted from that block.

type GitSource

type GitSource struct {
	LatestRemoteVersion *semver.Version
	RemoteVersions      semver.Collection
	LocalVersionIsMain  bool
	BlockIndex          int
	SourceURL           *url.URL
	RemoteURL           *url.URL
	Prefixes            []string
	// contains filtered or unexported fields
}

GitSource holds the metadata about a given git source, such as it's verion, available remote versions, and whether it is locally versioned.

func (*GitSource) FindLatestTagForConstraint

func (gs *GitSource) FindLatestTagForConstraint(constraint *semver.Constraints) *semver.Version

FindLatestTagForConstraint finds the latest tag in RemoteVersions matching the given constraint.

func (*GitSource) HCLSafeSourceURL

func (gs *GitSource) HCLSafeSourceURL() string

HCLSafeSourceURL retruns a url in string form matching the original HCL source (with prefixes attached)

func (*GitSource) IsVersion

func (gs *GitSource) IsVersion(version *semver.Version) bool

IsVersion returns true if the source version is the same as the supplied version

func (*GitSource) LocalVersionString

func (gs *GitSource) LocalVersionString() string

LocalVersionString returns either `HEAD` (in the case of no local version being set) or it returns the current local version.

func (*GitSource) SetSourceVersion

func (gs *GitSource) SetSourceVersion(version *semver.Version)

SetSourceVersion updates the git source in memory to change the given sources' version to the version specified.

func (*GitSource) UpdateRemoteTags

func (gs *GitSource) UpdateRemoteTags() error

UpdateRemoteTags requests a list of git tags from the source origin, and sets them against this GitSource object.

func (*GitSource) WouldForceDowngrade

func (gs *GitSource) WouldForceDowngrade(version *semver.Version) bool

WouldForceDowngrade returns true of the current local version is greater than the provided version.

type HclParser

type HclParser struct {
	// contains filtered or unexported fields
}

HclParser presides over a given HCL formatted file and can be used to both read and udpate it.

func NewHclParser

func NewHclParser(filePath string) (*HclParser, []error)

NewHclParser reads in a given HCL file and instansiates a new instance of HclParser

func (*HclParser) FindGitSources

func (p *HclParser) FindGitSources(includeRemote bool) (map[string]GitSource, error)

FindGitSources searches the current HCL for blocks which contain a `source` attribute, and then extracts the version references from it. Optionally, it may also retrieve information about the versions of the module available remotely.

func (*HclParser) Save

func (p *HclParser) Save() error

Save updates the target file

func (*HclParser) UpdateBlockSource

func (p *HclParser) UpdateBlockSource(source *GitSource)

UpdateBlockSource udpates the block source in the HCL, in memory, to match the source contained in the GitSource

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL