Documentation ¶
Index ¶
- Constants
- func AddOdoFileIndex(gitIgnoreFile string) error
- func CaseInsensitive(parameter string) func(word string) bool
- func CheckGitIgnoreFile(directory string) (string, error)
- func CheckOutputFlag(outputFlag string) bool
- func CheckPathExists(path string) bool
- func ConvertKeyValueStringToMap(params []string) map[string]string
- func ConvertLabelsToSelector(labels map[string]string) string
- func CreateIfNotExists(configFile string) error
- func DeleteConfiguration(info interface{}, parameter string) error
- func DeleteIndexFile(directory string) error
- func DeletePath(path string) error
- func ExtractComponentType(namespacedVersionedComponentType string) string
- func GenFileURL(location string, os ...string) string
- func GenerateRandomString(n int) string
- func GetAbsGlobExps(directory string, globExps []string) []string
- func GetAbsPath(path string) (string, error)
- func GetContainerPortsFromStrings(ports []string) ([]corev1.ContainerPort, error)
- func GetDNS1123Name(str string) string
- func GetFromFile(c interface{}, filename string) error
- func GetHostWithPort(inputURL string) (string, error)
- func GetIgnoreRulesFromDirectory(directory string) ([]string, error)
- func GetLowerCaseParameters(parameters []string) map[string]bool
- func GetRandomName(prefix string, prefixMaxLen int, existList []string, retries int) (string, error)
- func GetSortedKeys(mapping map[string]string) []string
- func GetSplitValuesFromStr(inputStr string) []string
- func In(arr []string, value string) bool
- func IsGlobExpMatch(strToMatch string, globExps []string) (bool, error)
- func IsSet(info interface{}, parameter string) bool
- func NamespaceOpenShiftObject(componentName string, applicationName string) (string, error)
- func OpenBrowser(url string) error
- func ParseComponentImageName(imageName string) (string, string, string, string)
- func ReadFilePath(u *url.URL, os string) string
- func RemoveDuplicates(s []string) []string
- func RemoveRelativePathFromFiles(files []string, path string) ([]string, error)
- func RunIndexer(directory string, ignoreRules []string) (filesChanged []string, filesDeleted []string, err error)
- func SliceDifference(s1 []string, s2 []string) []string
- func TruncateString(str string, maxLen int) string
- func WriteToFile(c interface{}, filename string) error
- type FileData
- type FileIndex
- type ResourceRequirementInfo
Constants ¶
const WIN = "windows"
Variables ¶
This section is empty.
Functions ¶
func AddOdoFileIndex ¶
AddOdoFileIndex adds odo-file-index.json to .gitignore
func CaseInsensitive ¶
CaseInsensitive returns a function which compares two words caseinsensitively
func CheckGitIgnoreFile ¶
CheckGitIgnoreFile checks .gitignore file exists or not, if not then create it
func CheckOutputFlag ¶
CheckOutputFlag returns true if specified output format is supported
func CheckPathExists ¶
CheckPathExists checks if a path exists or not
func ConvertKeyValueStringToMap ¶
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 ¶
ConvertLabelsToSelector converts the given labels to selector
func CreateIfNotExists ¶
CreateIfNotExists creates the directory and the file if it doesn't exist
func DeleteConfiguration ¶
DeleteConfiguration sets a parameter to null in a struct using reflection
func DeleteIndexFile ¶
DeleteIndexFile deletes the index file. It doesn't throw error if it doesn't exist
func DeletePath ¶
DeletePath deletes a file/directory if it exists and doesn't throw error if it doesn't exist
func ExtractComponentType ¶
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 ¶
GenFileURL Converts file path on windows to /C:/path/to/file to work in URL
func GenerateRandomString ¶
GenerateRandomString generates a random string of lower case characters of the given size
func GetAbsGlobExps ¶
GetAbsGlobExps converts the relative glob expressions into absolute glob expressions returns the absolute glob expressions
func GetAbsPath ¶
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 GetContainerPortsFromStrings ¶
func GetContainerPortsFromStrings(ports []string) ([]corev1.ContainerPort, error)
GetContainerPortsFromStrings generates ContainerPort values from the array of string port values ports is the array containing the string port values
func GetDNS1123Name ¶
GetDNS1123Name Converts passed string into DNS-1123 string
func GetFromFile ¶
GetFromFile unmarshals a struct from a odo config file
func GetHostWithPort ¶
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 ¶
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 empty 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 GetLowerCaseParameters ¶
GetLowerCaseParameters creates a set-like map of supported parameters from the supported parameter names
func GetRandomName ¶
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:
- 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
- error: if requested number of retries also failed to generate unique name
func GetSortedKeys ¶
GetSortedKeys retrieves the alphabetically-sorted keys of the specified map
func GetSplitValuesFromStr ¶
returns a slice containing the split string, using ',' as a separator
func IsGlobExpMatch ¶
IsGlobExpMatch compiles strToMatch against each of the passed globExps Parameters: strToMatch : a string for matching against the rules globExps : a list of glob patterns to match strToMatch with Returns: true if there is any match else false the error (if any) Notes: Source as well as glob expression to match is changed to forward slashes due to supporting Windows as well as support with the "github.com/gobwas/glob" library that we use.
func IsSet ¶
IsSet uses reflection to check if a parameter is set in a struct using the name in a case insensitive manner only supports flat structs TODO: support deeper struct using recursion
func NamespaceOpenShiftObject ¶
Hyphenate applicationName and componentName
func OpenBrowser ¶
OpenBrowser opens the URL within the users default browser
func ParseComponentImageName ¶
ParseComponentImageName 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 ¶
ReadFilePath Reads file path form URL file:///C:/path/to/file to C:\path\to\file
func RemoveDuplicates ¶
RemoveDuplicates goes through a string slice and removes all duplicates. Reference: https://siongui.github.io/2018/04/14/go-remove-duplicates-from-slice-or-array/
func RemoveRelativePathFromFiles ¶
RemoveRelativePathFromFiles removes a specified path from a list of files
func RunIndexer ¶
func RunIndexer(directory string, ignoreRules []string) (filesChanged []string, filesDeleted []string, err error)
RunIndexer walks the given directory and finds the files which have changed and which were deleted/renamed it reads the odo index file from the .odo folder if no such file is present, it means it's the first time the folder is being walked and thus returns a empty list after the walk, it stores the list of walked files with some information in a odo index file in the .odo folder The filemap stores the values as "relative filepath" => FileData but it the filesChanged and filesDeleted are absolute paths to the files
func SliceDifference ¶
SliceDifference returns the values of s2 that do not exist in s1
func TruncateString ¶
TruncateString truncates passed string to given length Note: if -1 is passed, the original string is returned
func WriteToFile ¶
WriteToFile marshals a struct to a file
Types ¶
type ResourceRequirementInfo ¶
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 ¶
func FetchResourceQuantity(resourceType corev1.ResourceName, min string, max string, request string) (*ResourceRequirementInfo, error)
FetchResourceQuantity takes passed min, max and requested resource quantities and returns min and max resource requests