Documentation
¶
Index ¶
- Constants
- Variables
- func ChangeProductSymlink(product Product, binVersionPath string, userBinPath string) error
- func ChangeSymlink(binVersionPath string, binPath string)deprecated
- func CheckDirExist(dir string) bool
- func CheckDirHasTGBin(dir, prefix string) bool
- func CheckDirWritable(dir string) bool
- func CheckFileExist(file string) bool
- func CheckSymlink(symlinkPath string) bool
- func ConvertExecutableExt(fpath string) string
- func CreateSymlink(cwd string, dir string) error
- func DownloadFromURL(installLocation, mirrorURL, tfversion, versionPrefix, goos, goarch string) (string, error)
- func DownloadProductFromURL(product Product, ...) (string, error)
- func FileExistsAndIsNotDir(filename string) bool
- func GetCurrentDirectory() string
- func GetFileName(configfile string) string
- func GetHomeDirectory() string
- func GetInstallLocation(installPath string) string
- func GetSemver(tfconstraint string, mirrorURL string) (string, error)
- func InitLogger(logLevel string) *slog.Logger
- func InstallLatestImplicitVersion(dryRun bool, ...)deprecated
- func InstallLatestProductImplicitVersion(product Product, dryRun bool, ...) error
- func InstallLatestProductVersion(product Product, dryRun bool, ...) error
- func InstallLatestVersion(dryRun bool, customBinaryPath, installPath, mirrorURL, arch string)deprecated
- func InstallOption(listAll, dryRun bool, customBinaryPath, installPath, mirrorURL, arch string)deprecated
- func InstallProductOption(product Product, listAll, dryRun bool, ...) error
- func InstallProductVersion(product Product, dryRun bool, ...) error
- func InstallVersion(dryRun bool, version, customBinaryPath, installPath, mirrorURL, arch string)deprecated
- func IsDirEmpty(dir string) bool
- func NewStderrConsoleHandler(levels []slog.Level) *handler.ConsoleHandler
- func NewStderrConsoleWithLF(lf slog.LevelFormattable) *handler.ConsoleHandler
- func Path(value string) string
- func PrintInvalidMinorTFVersion()
- func PrintInvalidTFVersion()
- func ReadLines(path string) (lines []string, err error)deprecated
- func RemoveFiles(src string)
- func RemoveSymlink(symlinkPath string) error
- func RenameFile(src string, dest string)
- func SemVerParser(tfconstraint *string, tflist []string) (string, error)
- func ShowLatestImplicitVersion(requestedVersion, mirrorURL string, preRelease bool)
- func ShowLatestVersion(mirrorURL string)
- func Unzip(src string, dest string, fileToUnzipSlice ...string) ([]string, error)
- func UsageMessage()
- func WriteLines(lines []string, path string) (err error)deprecated
- type Command
- type OpenTofuProduct
- func (p OpenTofuProduct) GetArchivePrefix() string
- func (p OpenTofuProduct) GetArtifactUrl(mirrorURL string, version string) string
- func (p OpenTofuProduct) GetDefaultMirrorUrl() string
- func (p OpenTofuProduct) GetExecutableName() string
- func (p OpenTofuProduct) GetId() string
- func (p OpenTofuProduct) GetName() string
- func (p OpenTofuProduct) GetPublicKeyId() string
- func (p OpenTofuProduct) GetPublicKeyUrl() string
- func (p OpenTofuProduct) GetRecentVersionProduct(recentFile *RecentFile) []string
- func (p OpenTofuProduct) GetShaSignatureSuffix() string
- func (p OpenTofuProduct) GetVersionPrefix() string
- func (p OpenTofuProduct) SetRecentVersionProduct(recentFile *RecentFile, versions []string)
- type Product
- type ProductDetails
- type RecentFile
- type TerraformProduct
- func (p TerraformProduct) GetArchivePrefix() string
- func (p TerraformProduct) GetArtifactUrl(mirrorURL string, version string) string
- func (p TerraformProduct) GetDefaultMirrorUrl() string
- func (p TerraformProduct) GetExecutableName() string
- func (p TerraformProduct) GetId() string
- func (p TerraformProduct) GetName() string
- func (p TerraformProduct) GetPublicKeyId() string
- func (p TerraformProduct) GetPublicKeyUrl() string
- func (p TerraformProduct) GetRecentVersionProduct(recentFile *RecentFile) []string
- func (p TerraformProduct) GetShaSignatureSuffix() string
- func (p TerraformProduct) GetVersionPrefix() string
- func (p TerraformProduct) SetRecentVersionProduct(recentFile *RecentFile, versions []string)
- type VersionSelector
Constants ¶
const ( DefaultMirror = "https://releases.hashicorp.com/terraform" DefaultLatest = "" InstallDir = ".terraform.versions" DefaultProductId = "terraform" )
Variables ¶
var ( ErrorLogging = slog.Levels{slog.PanicLevel, slog.FatalLevel, slog.ErrorLevel} NormalLogging = slog.Levels{slog.PanicLevel, slog.FatalLevel, slog.ErrorLevel, slog.WarnLevel, slog.InfoLevel} NoticeLogging = slog.Levels{slog.PanicLevel, slog.FatalLevel, slog.ErrorLevel, slog.WarnLevel, slog.InfoLevel, slog.NoticeLevel} DebugLogging = slog.Levels{slog.PanicLevel, slog.FatalLevel, slog.ErrorLevel, slog.WarnLevel, slog.InfoLevel, slog.NoticeLevel, slog.DebugLevel} TraceLogging = slog.Levels{slog.PanicLevel, slog.FatalLevel, slog.ErrorLevel, slog.WarnLevel, slog.InfoLevel, slog.NoticeLevel, slog.DebugLevel, slog.TraceLevel} )
Functions ¶
func ChangeProductSymlink ¶ added in v1.2.0
ChangeProductSymlink : move symlink for product to existing binary
func ChangeSymlink
deprecated
added in
v1.1.0
func CheckDirExist ¶ added in v1.1.0
CheckDirExist : check if directory exist dir=path to file return bool
func CheckDirHasTGBin ¶ added in v1.1.0
CheckDirHasTGBin : // check binary exist (TODO UNIT TEST)
func CheckDirWritable ¶ added in v1.1.0
Check if user has permission to directory : dir=path to file return bool
func CheckFileExist ¶
CheckFileExist : check if file exist in directory
func CheckSymlink ¶ added in v1.1.0
CheckSymlink : check file is symlink
func ConvertExecutableExt ¶ added in v1.1.0
ConvertExecutableExt : convert executable with local OS extension
func CreateSymlink ¶
CreateSymlink : create symlink or copy file to bin directory if windows
func DownloadFromURL ¶
func DownloadFromURL(installLocation, mirrorURL, tfversion, versionPrefix, goos, goarch string) (string, error)
DownloadFromURL : Downloads the terraform binary and its hash from the source url
func DownloadProductFromURL ¶ added in v1.2.0
func FileExistsAndIsNotDir ¶ added in v1.1.0
FileExistsAndIsNotDir checks if a file exists and is not a directory before we try using it to prevent further errors
func GetCurrentDirectory ¶ added in v1.1.0
func GetCurrentDirectory() string
GetCurrentDirectory : return the current directory
func GetFileName ¶ added in v1.1.0
GetFileName : remove file ext. .tfswitch.config returns .tfswitch
func GetHomeDirectory ¶ added in v1.1.0
func GetHomeDirectory() string
GetHomeDirectory : return the user's home directory
func GetInstallLocation ¶ added in v1.2.0
GetInstallLocation : get location where the terraform binary will be installed, will create the installDir if it does not exist
func GetSemver ¶ added in v1.1.0
GetSemver : returns version that will be installed based on server constraint provided
func InitLogger ¶ added in v1.1.0
func InstallLatestImplicitVersion
deprecated
added in
v1.1.0
func InstallLatestImplicitVersion(dryRun bool, requestedVersion, customBinaryPath, installPath, mirrorURL, arch string, preRelease bool)
InstallLatestImplicitVersion install latest - argument (version) must be provided
Deprecated: This function has been deprecated in favor of InstallLatestProductImplicitVersion and will be removed in v2.0.0
func InstallLatestProductImplicitVersion ¶ added in v1.2.0
func InstallLatestProductImplicitVersion(product Product, dryRun bool, requestedVersion, customBinaryPath, installPath, mirrorURL, arch string, preRelease bool) error
InstallLatestProductImplicitVersion install latest - argument (version) must be provided
func InstallLatestProductVersion ¶ added in v1.2.0
func InstallLatestProductVersion(product Product, dryRun bool, customBinaryPath, installPath, mirrorURL, arch string) error
InstallLatestProductVersion install latest stable tf version
func InstallLatestVersion
deprecated
added in
v1.1.0
func InstallOption
deprecated
added in
v1.1.0
InstallProductOption displays & installs tf version listAll = true - all versions including beta and rc will be displayed */ listAll = false - only official stable release are displayed */
Deprecated: This function has been deprecated in favor of InstallProductOption and will be removed in v2.0.0
func InstallProductOption ¶ added in v1.2.0
func InstallProductOption(product Product, listAll, dryRun bool, customBinaryPath, installPath, mirrorURL, arch string) error
InstallProductOption displays & installs tf version
listAll = true - all versions including beta and rc will be displayed listAll = false - only official stable release are displayed
func InstallProductVersion ¶ added in v1.2.0
func InstallProductVersion(product Product, dryRun bool, version, customBinaryPath, installPath, mirrorURL, arch string) error
InstallProductVersion install with provided version as argument
func InstallVersion
deprecated
added in
v1.1.0
func IsDirEmpty ¶ added in v1.1.0
IsDirEmpty : check if directory is empty (TODO UNIT TEST)
func NewStderrConsoleHandler ¶ added in v1.2.3
func NewStderrConsoleHandler(levels []slog.Level) *handler.ConsoleHandler
func NewStderrConsoleWithLF ¶ added in v1.2.3
func NewStderrConsoleWithLF(lf slog.LevelFormattable) *handler.ConsoleHandler
func PrintInvalidMinorTFVersion ¶ added in v1.1.0
func PrintInvalidMinorTFVersion()
PrintInvalidMinorTFVersion Print invalid minor TF version
func PrintInvalidTFVersion ¶ added in v1.1.0
func PrintInvalidTFVersion()
PrintInvalidTFVersion Print invalid TF version
func SemVerParser ¶ added in v1.1.0
SemVerParser : Goes through the list of terraform version, return a valid tf version for contraint provided
func ShowLatestImplicitVersion ¶ added in v1.1.0
ShowLatestImplicitVersion show latest - argument (version) must be provided
func ShowLatestVersion ¶ added in v1.1.0
func ShowLatestVersion(mirrorURL string)
ShowLatestVersion show install latest stable tf version
func Unzip ¶
Unzip will decompress a zip archive, moving all files and folders within the zip file (parameter 1) to an output directory (parameter 2). fileToUnzip (parameter 3) specifies the file within the zipfile to be extracted. This is optional and default to "terraform"
func UsageMessage ¶ added in v1.1.0
func UsageMessage()
func WriteLines
deprecated
added in
v1.1.0
Types ¶
type Command ¶
type Command struct {
// contains filtered or unexported fields
}
Command : type string
type OpenTofuProduct ¶ added in v1.2.0
type OpenTofuProduct struct {
ProductDetails
}
func (OpenTofuProduct) GetArchivePrefix ¶ added in v1.2.0
func (p OpenTofuProduct) GetArchivePrefix() string
func (OpenTofuProduct) GetArtifactUrl ¶ added in v1.2.0
func (p OpenTofuProduct) GetArtifactUrl(mirrorURL string, version string) string
func (OpenTofuProduct) GetDefaultMirrorUrl ¶ added in v1.2.0
func (p OpenTofuProduct) GetDefaultMirrorUrl() string
func (OpenTofuProduct) GetExecutableName ¶ added in v1.2.0
func (p OpenTofuProduct) GetExecutableName() string
func (OpenTofuProduct) GetId ¶ added in v1.2.0
func (p OpenTofuProduct) GetId() string
OpenTofu methods
func (OpenTofuProduct) GetName ¶ added in v1.2.0
func (p OpenTofuProduct) GetName() string
func (OpenTofuProduct) GetPublicKeyId ¶ added in v1.2.0
func (p OpenTofuProduct) GetPublicKeyId() string
func (OpenTofuProduct) GetPublicKeyUrl ¶ added in v1.2.0
func (p OpenTofuProduct) GetPublicKeyUrl() string
func (OpenTofuProduct) GetRecentVersionProduct ¶ added in v1.2.0
func (p OpenTofuProduct) GetRecentVersionProduct(recentFile *RecentFile) []string
func (OpenTofuProduct) GetShaSignatureSuffix ¶ added in v1.2.0
func (p OpenTofuProduct) GetShaSignatureSuffix() string
func (OpenTofuProduct) GetVersionPrefix ¶ added in v1.2.0
func (p OpenTofuProduct) GetVersionPrefix() string
func (OpenTofuProduct) SetRecentVersionProduct ¶ added in v1.2.0
func (p OpenTofuProduct) SetRecentVersionProduct(recentFile *RecentFile, versions []string)
type Product ¶ added in v1.2.0
type Product interface { GetId() string GetName() string GetDefaultMirrorUrl() string GetVersionPrefix() string GetExecutableName() string GetArchivePrefix() string GetPublicKeyId() string GetPublicKeyUrl() string GetShaSignatureSuffix() string GetArtifactUrl(mirrorURL string, version string) string GetRecentVersionProduct(recentFile *RecentFile) []string SetRecentVersionProduct(recentFile *RecentFile, versions []string) }
func GetAllProducts ¶ added in v1.2.0
func GetAllProducts() []Product
func GetProductById ¶ added in v1.2.0
type ProductDetails ¶ added in v1.2.0
type RecentFile ¶ added in v1.2.0
type TerraformProduct ¶ added in v1.2.0
type TerraformProduct struct {
ProductDetails
}
func (TerraformProduct) GetArchivePrefix ¶ added in v1.2.0
func (p TerraformProduct) GetArchivePrefix() string
func (TerraformProduct) GetArtifactUrl ¶ added in v1.2.0
func (p TerraformProduct) GetArtifactUrl(mirrorURL string, version string) string
func (TerraformProduct) GetDefaultMirrorUrl ¶ added in v1.2.0
func (p TerraformProduct) GetDefaultMirrorUrl() string
func (TerraformProduct) GetExecutableName ¶ added in v1.2.0
func (p TerraformProduct) GetExecutableName() string
func (TerraformProduct) GetId ¶ added in v1.2.0
func (p TerraformProduct) GetId() string
Terraform Product
func (TerraformProduct) GetName ¶ added in v1.2.0
func (p TerraformProduct) GetName() string
func (TerraformProduct) GetPublicKeyId ¶ added in v1.2.0
func (p TerraformProduct) GetPublicKeyId() string
func (TerraformProduct) GetPublicKeyUrl ¶ added in v1.2.0
func (p TerraformProduct) GetPublicKeyUrl() string
func (TerraformProduct) GetRecentVersionProduct ¶ added in v1.2.0
func (p TerraformProduct) GetRecentVersionProduct(recentFile *RecentFile) []string
func (TerraformProduct) GetShaSignatureSuffix ¶ added in v1.2.0
func (p TerraformProduct) GetShaSignatureSuffix() string
func (TerraformProduct) GetVersionPrefix ¶ added in v1.2.0
func (p TerraformProduct) GetVersionPrefix() string
func (TerraformProduct) SetRecentVersionProduct ¶ added in v1.2.0
func (p TerraformProduct) SetRecentVersionProduct(recentFile *RecentFile, versions []string)