lib

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 26 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultMirror = "https://releases.hashicorp.com/terraform"
	DefaultLatest = ""

	InstallDir = ".terraform.versions"

	VersionPrefix = "terraform_"
)

Variables

View Source
var (
	PubKeyId     = "72D7468F"
	PubKeyPrefix = "hashicorp_"
	PubKeyUri    = "https://www.hashicorp.com/.well-known/pgp-key.txt"
)

Functions

func ChangeSymlink(binVersionPath string, binPath string)

ChangeSymlink : move symlink to existing binary

func CheckDirExist added in v1.1.0

func CheckDirExist(dir string) bool

CheckDirExist : check if directory exist dir=path to file return bool

func CheckDirHasTGBin added in v1.1.0

func CheckDirHasTGBin(dir, prefix string) bool

CheckDirHasTGBin : // check binary exist (TODO UNIT TEST)

func CheckDirWritable added in v1.1.0

func CheckDirWritable(dir string) bool

Check if user has permission to directory : dir=path to file return bool

func CheckFileExist

func CheckFileExist(file string) bool

CheckFileExist : check if file exist in directory

func CheckSymlink(symlinkPath string) bool

CheckSymlink : check file is symlink

func ConvertExecutableExt added in v1.1.0

func ConvertExecutableExt(fpath string) string

ConvertExecutableExt : convert excutable with local OS extension

func CreateRecentFile added in v1.1.0

func CreateRecentFile(requestedVersion string, installPath string)

CreateRecentFile : create RECENT file

func CreateSymlink(cwd string, dir string)

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

func FileExistsAndIsNotDir(filename string) bool

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

func GetFileName(configfile string) string

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

func GetSemver(tfconstraint string, mirrorURL string) (string, error)

GetSemver : returns version that will be installed based on server constraint provided

func InitLogger added in v1.1.0

func InitLogger(logLevel string) *slog.Logger

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

func InstallLatestVersion(customBinaryPath, installPath string, mirrorURL string)

InstallLatestVersion install latest stable tf version

func InstallOption added in v1.1.0

func InstallOption(listAll bool, customBinaryPath, installPath string, mirrorURL string)

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

func InstallVersion(arg, customBinaryPath, installPath string, mirrorURL string)

InstallVersion install with provided version as argument

func IsDirEmpty added in v1.1.0

func IsDirEmpty(name string) bool

IsDirEmpty : check if directory is empty (TODO UNIT TEST)

func Path added in v1.1.0

func Path(value string) string

Path : returns path of directory value=path to file

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

func ReadLines(path string) (lines []string, err error)

ReadLines : Read a whole file into the memory and store it as array of lines

func RemoveFiles

func RemoveFiles(src string)

RemoveFiles : remove file

func RemoveSymlink(symlinkPath string)

RemoveSymlink : remove symlink

func RenameFile

func RenameFile(src string, dest string)

RenameFile : rename file name

func SemVerParser added in v1.1.0

func SemVerParser(tfconstraint *string, tflist []string) (string, error)

SemVerParser : Goes through the list of terraform version, return a valid tf version for contraint provided

func ShowLatestImplicitVersion added in v1.1.0

func ShowLatestImplicitVersion(requestedVersion, mirrorURL string, preRelease bool)

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

func Unzip(src string, dest string) ([]string, error)

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

func WriteLines(lines []string, path string) (err error)

WriteLines : writes into file

Types

type Command

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

Command : type string

func NewCommand

func NewCommand(name string) *Command

NewCommand : get command

func (*Command) Find

func (cmd *Command) Find() func() string

Find : find all bin path

func (*Command) PathList

func (cmd *Command) PathList() []string

PathList : get bin path list

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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