lib

package
v0.13.1275 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRecent added in v0.13.1

func AddRecent(requestedVersion string)

AddRecent : add to recent file

func ChangeSymlink(binVersionPath string, binPath string)

ChangeSymlink : move symlink to existing binary

func CheckDirExist added in v0.13.1

func CheckDirExist(dir string) bool

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

func CheckDirHasTGBin added in v0.13.1

func CheckDirHasTGBin(dir, prefix string) bool

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

func CheckDirWritable added in v0.13.1

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 v0.13.1

func ConvertExecutableExt(fpath string) string

ConvertExecutableExt : convert excutable with local OS extension

func CreateDirIfNotExist

func CreateDirIfNotExist(dir string)

CreateDirIfNotExist : create directory if directory does not exist

func CreateRecentFile added in v0.13.1

func CreateRecentFile(requestedVersion string)

CreateRecentFile : create a recent file

func CreateSymlink(cwd string, dir string)

CreateSymlink : create symlink

func DownloadFromURL

func DownloadFromURL(installLocation string, url string) (string, error)

DownloadFromURL : Downloads the binary from the source url

func GetCurrentDirectory added in v0.13.1

func GetCurrentDirectory() string

GetCurrentDirectory : return the current directory

func GetFileName added in v0.13.1

func GetFileName(configfile string) string

GetFileName : remove file ext. .tfswitch.config returns .tfswitch

func GetHomeDirectory added in v0.13.1

func GetHomeDirectory() string

GetHomeDirectory : return the home directory

func GetInstallLocation added in v0.13.1

func GetInstallLocation() string

GetInstallLocation : get location where the terraform binary will be installed, will create a directory in the home location if it does not exist

func GetRecentVersions added in v0.13.1

func GetRecentVersions() ([]string, error)

GetRecentVersions : get recent version from file

func GetSemver added in v0.13.1

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

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

func GetTFLatest added in v0.13.1

func GetTFLatest(mirrorURL string) (string, error)

GetTFLatest : Get the latest terraform version given the hashicorp url

func GetTFLatestImplicit added in v0.13.1

func GetTFLatestImplicit(mirrorURL string, preRelease bool, version string) (string, error)

GetTFLatestImplicit : Get the latest implicit terraform version given the hashicorp url

func GetTFList added in v0.13.1

func GetTFList(mirrorURL string, preRelease bool) ([]string, error)

GetTFList : Get the list of available terraform version given the hashicorp url

func GetTFURLBody added in v0.13.1

func GetTFURLBody(mirrorURL string) ([]string, error)

GetTFURLBody : Get list of terraform versions from hashicorp releases

func Install added in v0.13.1

func Install(tfversion string, binPath string, mirrorURL string)

Install : Install the provided version in the argument

func InstallableBinLocation added in v0.13.1

func InstallableBinLocation(userBinPath string) string

InstallableBinLocation : Checks if terraform is installable in the location provided by the user. If not, create $HOME/bin. Ask users to add $HOME/bin to $PATH and return $HOME/bin as install location

func IsDirEmpty added in v0.13.1

func IsDirEmpty(name string) bool

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

func Path added in v0.13.1

func Path(value string) string

Path : returns path of directory value=path to file

func PrintInvalidMinorTFVersion added in v0.13.1

func PrintInvalidMinorTFVersion()

Print invalid TF version

func PrintInvalidTFVersion added in v0.13.1

func PrintInvalidTFVersion()

Print invalid TF version

func ReadLines added in v0.13.1

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

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

func RemoveDuplicateVersions added in v0.13.1

func RemoveDuplicateVersions(elements []string) []string

RemoveDuplicateVersions : remove duplicate version

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 v0.13.1

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

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

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 ValidMinorVersionFormat added in v0.13.1

func ValidMinorVersionFormat(version string) bool

ValidMinorVersionFormat : returns valid MINOR version format

For example: 0.1 = valid

// For example: a.1.2 = invalid // For example: 0.1.2 = invalid

func ValidVersionFormat added in v0.13.1

func ValidVersionFormat(version string) bool

ValidVersionFormat : returns valid version format

For example: 0.1.2 = valid

// For example: 0.1.2-beta1 = valid // For example: 0.1.2-alpha = valid // For example: a.1.2 = invalid // For example: 0.1. 2 = invalid

func VersionExist added in v0.13.1

func VersionExist(val interface{}, array interface{}) (exists bool)

VersionExist : check if requested version exist

func WriteLines added in v0.13.1

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

Jump to

Keyboard shortcuts

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