util

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const WIN = "windows"

Variables

This section is empty.

Functions

func CheckPathExists added in v0.0.17

func CheckPathExists(path string) bool

CheckPathExists checks if a path exists or not

func ConvertKeyValueStringToMap added in v0.0.14

func ConvertKeyValueStringToMap(params []string) map[string]string

ConvertKeyValueStringToMap converts String Slice of Parameters to a Map[String]string Each value of the slice is expected to be in the key=value format Values that do not conform to this "spec", will be ignored

func ConvertLabelsToSelector

func ConvertLabelsToSelector(labels map[string]string) string

ConvertLabelsToSelector converts the given labels to selector

func ExtractComponentType added in v0.0.11

func ExtractComponentType(namespacedVersionedComponentType string) string

ExtractComponentType returns only component type part from passed component type(default unqualified, fully qualified, versioned, etc...and their combinations) for use as component name Possible types of parameters: 1. "myproject/python:3.5" -- Return python 2. "python:3.5" -- Return python 3. nodejs -- Return nodejs

func GenFileURL added in v0.0.17

func GenFileURL(location string, os string) string

Converts file path on windows to /C:/path/to/file to work in URL

func GenerateRandomString

func GenerateRandomString(n int) string

GenerateRandomString generates a random string of lower case characters of the given size

func GetAbsPath added in v0.0.17

func GetAbsPath(path string) (string, error)

GetAbsPath returns absolute path from passed file path resolving even ~ to user home dir and any other such symbols that are only shell expanded can also be handled here

func GetDNS1123Name added in v0.0.15

func GetDNS1123Name(str string) string

GetDNS1123Name Converts passed string into DNS-1123 string

func GetHostWithPort added in v0.0.18

func GetHostWithPort(inputURL string) (string, error)

GetHostWithPort parses provided url and returns string formated as host:port even if port was not specifically specified in the origin url. If port is not specified, standart port corresponding to url schema is provided. example: for url https://example.com function will return "example.com:443"

for url https://example.com:8443 function will return "example:8443"

func GetIgnoreRulesFromDirectory added in v0.0.18

func GetIgnoreRulesFromDirectory(directory string) ([]string, error)

GetIgnoreRulesFromDirectory reads the .odoignore file, if present, and reads the rules from it if the .odoignore file is not found, then .gitignore is searched for the rules if both are not found, return emtpy array directory is the name of the directory to look into for either of the files rules is the array of rules (in string form)

func GetRandomName added in v0.0.15

func GetRandomName(prefix string, prefixMaxLen int, existList []string, retries int) (string, error)

GetRandomName returns a randomly generated name which can be used for naming odo and/or openshift entities prefix: Desired prefix part of the name prefixMaxLen: Desired maximum length of prefix part of random name; if -1 is passed, no limit on length will be enforced existList: List to verify that the returned name does not already exist retries: number of retries to try generating a unique name Returns:

  1. randomname: is prefix-suffix, where: prefix: string passed as prefix or fetched current directory of length same as the passed prefixMaxLen suffix: 4 char random string
  2. error: if requested number of retries also failed to generate unique name

func NamespaceOpenShiftObject added in v0.0.7

func NamespaceOpenShiftObject(componentName string, applicationName string) (string, error)

Hyphenate applicationName and componentName

func OpenBrowser added in v0.0.15

func OpenBrowser(url string) error

OpenBrowser opens the URL within the users default browser

func ParseCreateCmdArgs added in v0.0.11

func ParseCreateCmdArgs(args []string) (string, string, string, string)

parseCreateCmdArgs returns 1. image name 2. component type i.e, builder image name 3. component name default value is component type else the user requested component name 4. component version which is by default latest else version passed with builder image name

func ReadFilePath added in v0.0.11

func ReadFilePath(u *url.URL, os string) string

Reads file path form URL file:///C:/path/to/file to C:\path\to\file

func SliceDifference added in v0.0.15

func SliceDifference(s1 []string, s2 []string) []string

SliceDifference returns the values of s2 that do not exist in s1

func TruncateString added in v0.0.15

func TruncateString(str string, maxLen int) string

TruncateString truncates passed string to given length Note: if -1 is passed, the original string is returned

Types

type ResourceRequirementInfo added in v0.0.17

type ResourceRequirementInfo struct {
	ResourceType corev1.ResourceName
	MinQty       resource.Quantity
	MaxQty       resource.Quantity
}

ResourceRequirementInfo holds resource quantity before transformation into its appropriate form in container spec

func FetchResourceQuantity added in v0.0.17

func FetchResourceQuantity(resourceType corev1.ResourceName, min string, max string, request string) *ResourceRequirementInfo

FetchResourceQuantity takes passed min, max and requested resource quantities and returns min and max resource requests

Jump to

Keyboard shortcuts

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