util

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWritePermissions = 0760

	MaximumNewDirectoryAttempts = 1000
)
View Source
const (
	ALIGN_LEFT   = 0
	ALIGN_CENTER = 1
	ALIGN_RIGHT  = 2
)
View Source
const (
	CONFIGFILENAME = "config"
)
View Source
const (
	DefaultSuggestionsMinimumDistance = 2
)

Variables

View Source
var ColorError = color.New(color.FgRed).SprintFunc()
View Source
var ColorInfo = color.New(color.FgGreen).SprintFunc()
View Source
var ColorStatus = color.New(color.FgBlue).SprintFunc()
View Source
var ColorWarning = color.New(color.FgYellow).SprintFunc()

Functions

func BinaryLocation

func BinaryLocation() (string, error)

func CacheDir

func CacheDir() (string, error)

func ConfigDir

func ConfigDir() (string, error)

func Confirm

func Confirm(message string, defaultValue bool, help string) bool

Confirm prompts the user to confirm something

func CopyDirOverwrite

func CopyDirOverwrite(src string, dst string) (err error)

CopyDirOverwrite copies from the source dir to the destination dir overwriting files along the way

func CreateUniqueDirectory

func CreateUniqueDirectory(dir string, name string, maximumAttempts int) (string, error)

CreateUniqueDirectory creates a new directory but if the combination of dir and name exists then append a number until a unique name is found

func DownloadArtifactoryFile

func DownloadArtifactoryFile(url string, filepath string) (err error)

DownloadArtifactoryFile will download a file from the given Artifactory URL

func DownloadFile

func DownloadFile(filepath string, url string) (err error)

Download a file from the given URL

func DownloadGitHubReleaseAsset added in v0.16.3

func DownloadGitHubReleaseAsset(fullUrl string, filepath string) (err error)

DownloadGitHubReleaseAsset will download a file from the given GitHUb release area

func EdgeControllerCreate

func EdgeControllerCreate(entityType string, body string, out io.Writer, logJSON bool, timeout int, verbose bool) (*gabs.Container, error)

EdgeControllerCreate will create entities of the given type in the given Edge Controller

func EdgeControllerDelete

func EdgeControllerDelete(entityType string, id string, out io.Writer, logJSON bool, timeout int, verbose bool) (*gabs.Container, error)

EdgeControllerDelete will delete entities of the given type in the given Edge Controller

func EdgeControllerDetailEntity added in v0.15.1

func EdgeControllerDetailEntity(entityType, entityId string, logJSON bool, out io.Writer, timeout int, verbose bool) (*gabs.Container, error)

func EdgeControllerList

func EdgeControllerList(path string, params url.Values, logJSON bool, out io.Writer, timeout int, verbose bool) (*gabs.Container, error)

EdgeControllerList will list entities of the given type in the given Edge Controller

func EdgeControllerListSubEntities

func EdgeControllerListSubEntities(entityType, subType, entityId string, filter string, logJSON bool, out io.Writer, timeout int, verbose bool) (*gabs.Container, error)

EdgeControllerListSubEntities will list entities of the given type in the given Edge Controller

func EdgeControllerLogin

func EdgeControllerLogin(url string, cert string, authentication string, out io.Writer, logJSON bool, timeout int, verbose bool) (*gabs.Container, error)

EdgeControllerLogin will authenticate to the given Edge Controller

func EdgeControllerRequest

func EdgeControllerRequest(entityType string, out io.Writer, logJSON bool, timeout int, verbose bool, doRequest func(*resty.Request, string) (*resty.Response, error)) (*gabs.Container, error)

func EdgeControllerUpdate

func EdgeControllerUpdate(entityType string, body string, out io.Writer, method string, logRequestJson, logResponseJSON bool, timeout int, verbose bool) (*gabs.Container, error)

EdgeControllerUpdate will update entities of the given type in the given Edge Controller

func EdgeControllerVerify

func EdgeControllerVerify(entityType, id, body string, out io.Writer, logJSON bool, timeout int, verbose bool) error

EdgeControllerVerify will create entities of the given type in the given Edge Controller

func EnvironmentsDir

func EnvironmentsDir() (string, error)

func FabricConfigDir

func FabricConfigDir() (string, error)

func FileExists

func FileExists(path string) (bool, error)

func FirstNotEmptyString

func FirstNotEmptyString(values ...string) string

FirstNotEmptyString returns the first non empty string or the empty string if none can be found

func GetArtifactoryPath

func GetArtifactoryPath(staging bool, appName string, branch string) string

func GetCommandOutput

func GetCommandOutput(dir string, name string, args ...string) (string, error)

GetCommandOutput evaluates the given command and returns the trimmed output

func GetLatestGitHubReleaseAsset added in v0.16.3

func GetLatestGitHubReleaseAsset(verbose bool, appName string) (string, error)

func GetLatestGitHubReleaseVersion added in v0.16.3

func GetLatestGitHubReleaseVersion(verbose bool, appName string) (semver.Version, error)

func GetLatestSemanticVersionFromArtifactory

func GetLatestSemanticVersionFromArtifactory(verbose bool, staging bool, branch string, appName string, versionWildcard string) (semver.Version, error)

func GetLatestTerraformProviderVersionFromArtifactory

func GetLatestTerraformProviderVersionFromArtifactory(branch string, provider string) (semver.Version, error)

func GetLatestVersionFromArtifactory

func GetLatestVersionFromArtifactory(verbose bool, staging bool, branch string, appName string) (semver.Version, error)

func GetTerraformProviderArtifactoryPath

func GetTerraformProviderArtifactoryPath(provider string, branch string) string

func HomeDir

func HomeDir() string

func InvalidArg

func InvalidArg(value string, values []string) error

func InvalidArgError

func InvalidArgError(value string, err error) error

func InvalidArgf

func InvalidArgf(value string, message string, a ...interface{}) error

func InvalidOption

func InvalidOption(name string, value string, values []string) error

func InvalidOptionError

func InvalidOptionError(option string, value string, err error) error

func InvalidOptionf

func InvalidOptionf(option string, value string, message string, a ...interface{}) error

func IsEmpty

func IsEmpty(name string) (bool, error)

func LoadBytes

func LoadBytes(dir, name string) ([]byte, error)

loads a file

func MissingOption

func MissingOption(name string) error

func NewEmptyParentCmd

func NewEmptyParentCmd(name string, description string) *cobra.Command

NewEmptyParentCmd creates a new cobra command with no parent

func NewEnvironmentDir

func NewEnvironmentDir(envName string) (string, error)

func PKIRootDir

func PKIRootDir() (string, error)

func Pad

func Pad(s, pad string, width int, align int) string

func PadCenter

func PadCenter(s, pad string, width int) string

func PadLeft

func PadLeft(s, pad string, width int) string

func PadRight

func PadRight(s, pad string, width int) string

func PathWithBinary

func PathWithBinary() string

func PickName

func PickName(names []string, message string) (string, error)

func PickNameWithDefault

func PickNameWithDefault(names []string, message string, defaultValue string) (string, error)

func PickNames

func PickNames(names []string, message string) ([]string, error)

func PickPassword

func PickPassword(message string) (string, error)

func PickRequiredNameWithDefault

func PickRequiredNameWithDefault(names []string, message string, defaultValue string) (string, error)

func PickValue

func PickValue(message string, defaultValue string, required bool) (string, error)

func ReadZitiAppConfigFile

func ReadZitiAppConfigFile(zitiApp string, configData interface{}) error

ReadZitiAppConfigFile reads in the config file data for the given Ziti application from an appropriate location

func ReadZitiAppFile

func ReadZitiAppFile(zitiApp string, fileType string, configData interface{}) error

ReadZitiAppFile reads application data (config, session, preferences, etc) for the given Ziti application from an appropriate location

func RegexpSplit

func RegexpSplit(text string, regexSeperator string) []string

RegexpSplit splits a string into an array using the regexSep as a separator

func RenameDir

func RenameDir(src string, dst string, force bool) (err error)

func RenameFile

func RenameFile(src string, dst string) (err error)

func ReverseStrings

func ReverseStrings(a []string)

func RunAWSCommand

func RunAWSCommand(args ...string) error

RunAWSCommand evaluates the given AWS CLI command and returns the trimmed output

func RunCommand

func RunCommand(dir string, name string, args ...string) error

RunCommand evaluates the given command and returns the trimmed output

func SelectNames

func SelectNames(names []string, message string, selectAll bool) ([]string, error)

SelectNames select which names from the list should be chosen

func SelectNamesWithFilter

func SelectNamesWithFilter(names []string, message string, selectAll bool, filter string) ([]string, error)

SelectNamesWithFilter selects from a list of names with a given filter. Optionally selecting them all

func SortedMapKeys

func SortedMapKeys(m map[string]string) []string

SortedMapKeys returns the sorted keys of the given map

func StringArrayIndex

func StringArrayIndex(array []string, value string) int

func StringArrayToLower

func StringArrayToLower(values []string) []string

StringArrayToLower returns a string slice with all the values converted to lower case

func StringIndexes

func StringIndexes(text string, value string) []int

StringIndexes returns all the indices where the value occurs in the given string

func StringMatchesAny

func StringMatchesAny(text string, includes []string, excludes []string) bool

StringMatches returns true if the given text matches the includes/excludes lists

func StringMatchesPattern

func StringMatchesPattern(text string, pattern string) bool

StringMatchesPattern returns true if the given text matches the includes/excludes lists

func SuggestionsFor

func SuggestionsFor(typedName string, values []string, suggestionsMinimumDistance int, explicitSuggestions ...string) []string

func TerraformProviderBinaryLocation

func TerraformProviderBinaryLocation() (string, error)

TerraformProviderBinaryLocation provides the proper location to place a Terraform provider based on the currently running OS. In Mac/Linux, it's `~/.terraform.d/plugins` and on Windows it's `%APPDATA%\terraform.d\plugins`

func UnTargz

func UnTargz(tarball, target string, onlyFiles []string) error

untargz a tarball to a target, from http://blog.ralch.com/tutorial/golang-working-with-tar-and-gzip

func Unzip added in v0.16.3

func Unzip(src, dest string) error

func WriteZitiAppConfigFile

func WriteZitiAppConfigFile(zitiApp string, configData interface{}) error

WriteZitiAppConfigFile writes out the config file data for the given Ziti application to the appropriate config file

func WriteZitiAppFile

func WriteZitiAppFile(zitiApp string, fileType string, appData interface{}) error

WriteZitiAppFile writes application data (config, session, preferences, etc) to an appropriate location

func ZitiAppConfigDir

func ZitiAppConfigDir(zitiApp string) (string, error)

Types

type AQLResult

type AQLResult struct {
	Repo       string
	Path       string
	Name       string
	Type       string
	Size       int
	Created    string
	CreatedBy  string
	Modified   string
	ModifiedBy string
	Updated    string
	Properties []struct {
		Key   string
		Value string
	}
}

Used to parse the '/api/search/aql' response from Artifactory

type AQLVars

type AQLVars struct {
	SemverMajor    string
	SemverMaxMinor string
	SemverMinMinor string
	App            string
	Arch           string
	OS             string
}

type ArtifactoryAQLData

type ArtifactoryAQLData struct {
	Results []AQLResult
}

type ArtifactoryStorageChildrenData

type ArtifactoryStorageChildrenData struct {
	URI    string `json:"uri"`
	Folder bool   `json:"folder"`
}

Used to parse the '/api/storage' response from Artifactory

func GetCurrentSnapshotListFromArtifactory

func GetCurrentSnapshotListFromArtifactory(verbose bool) ([]ArtifactoryStorageChildrenData, error)

type ArtifactoryStorageData

type ArtifactoryStorageData struct {
	Repo         string                           `json:"repo"`
	Path         string                           `json:"path"`
	Created      string                           `json:"created"`
	LastModified string                           `json:"lastModified"`
	LastUpdated  string                           `json:"lastUpdated"`
	Children     []ArtifactoryStorageChildrenData `json:"children"`
	URI          string                           `json:"uri"`
}

type ArtifactoryVersionsData

type ArtifactoryVersionsData struct {
	Version   string `json:"version"`
	Artifacts []struct {
	}
}

Used to parse the '/api/versions' response from Artifactory

type Data

type Data struct {
	TagSet []struct {
		Value string `json:"Value"`
		Key   string `json:"Key"`
	}
}

Used to parse the 'get-object-tagging' response

type GitHubReleasesData added in v0.16.3

type GitHubReleasesData struct {
	Version string `json:"tag_name"`
	Assets  []struct {
		BrowserDownloadURL string `json:"browser_download_url"`
	}
}

Used to parse the '/releases/latest' response from GitHub

type Session

type Session struct {
	Host  string
	Token string
	Cert  string
}

Session stores configuration options for the CLI

func (*Session) GetBaseUrl

func (session *Session) GetBaseUrl() string

func (*Session) GetCert

func (session *Session) GetCert() string

func (*Session) GetToken

func (session *Session) GetToken() string

func (*Session) Load

func (session *Session) Load() error

Load reads in the Ziti CLI session file

func (*Session) Persist

func (session *Session) Persist() error

Persist writes out the Ziti CLI session file

func (*Session) String

func (session *Session) String() string

Jump to

Keyboard shortcuts

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