Documentation ¶
Index ¶
- Constants
- Variables
- func ChangeSymlink(binVersionPath string, binPath string)
- 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 CreateRecentFile(requestedVersion string, installPath string)
- func CreateSymlink(cwd string, dir string)
- func DownloadFromURL(installLocation string, mirrorURL string, tfversion string, ...) (string, error)
- func FileExistsAndIsNotDir(filename string) bool
- func GetCurrentDirectory() string
- func GetDefaultBin() string
- func GetFileName(configfile string) string
- func GetHomeDirectory() string
- func GetSemver(tfconstraint string, mirrorURL string) (string, error)
- func InitLogger(logLevel string) *slog.Logger
- func InstallLatestImplicitVersion(requestedVersion, customBinaryPath, installPath string, mirrorURL string, ...)
- func InstallLatestVersion(customBinaryPath, installPath string, mirrorURL string)
- func InstallOption(listAll bool, customBinaryPath, installPath string, mirrorURL string)
- func InstallVersion(arg, customBinaryPath, installPath string, mirrorURL string)
- func IsDirEmpty(name string) bool
- func Path(value string) string
- func PrintInvalidMinorTFVersion()
- func PrintInvalidTFVersion()
- func ReadLines(path string) (lines []string, err error)
- func RemoveFiles(src string)
- func RemoveSymlink(symlinkPath string)
- 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) ([]string, error)
- func UsageMessage()
- func WriteLines(lines []string, path string) (err error)
- type Command
Constants ¶
const ( DefaultMirror = "https://releases.hashicorp.com/terraform" DefaultLatest = "" InstallDir = ".terraform.versions" VersionPrefix = "terraform_" )
Variables ¶
var ( PubKeyId = "72D7468F" PubKeyPrefix = "hashicorp_" PubKeyUri = "https://www.hashicorp.com/.well-known/pgp-key.txt" )
var ( 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 ChangeSymlink ¶ added in v1.1.0
ChangeSymlink : move symlink to existing binary
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 excutable with local OS extension
func CreateRecentFile ¶ added in v1.1.0
CreateRecentFile : create RECENT file
func CreateSymlink ¶
CreateSymlink : create symlink or copy file to bin directory if windows
func DownloadFromURL ¶
func DownloadFromURL(installLocation string, mirrorURL string, tfversion string, versionPrefix string, goos string, goarch string) (string, error)
DownloadFromURL : Downloads the terraform binary and its hash from the source url
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 GetDefaultBin ¶ added in v1.1.0
func GetDefaultBin() string
GetDefaultBin Get default binary path
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 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 ¶ added in v1.1.0
func InstallLatestImplicitVersion(requestedVersion, customBinaryPath, installPath string, mirrorURL string, preRelease bool)
InstallLatestImplicitVersion install latest - argument (version) must be provided
func InstallLatestVersion ¶ added in v1.1.0
InstallLatestVersion install latest stable tf version
func InstallOption ¶ added in v1.1.0
InstallOption displays & installs tf version
listAll = true - all versions including beta and rc will be displayed listAll = false - only official stable release are displayed
func InstallVersion ¶ added in v1.1.0
InstallVersion install with provided version as argument
func IsDirEmpty ¶ added in v1.1.0
IsDirEmpty : check if directory is empty (TODO UNIT TEST)
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 ReadLines ¶ added in v1.1.0
ReadLines : Read a whole file into the memory and store it as array of lines
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).
func UsageMessage ¶ added in v1.1.0
func UsageMessage()
func WriteLines ¶ added in v1.1.0
WriteLines : writes into file