Documentation ¶
Index ¶
- Constants
- func AddFileToIgnoreFile(gitIgnoreFile, filename string) error
- func AddOdoFileIndex(gitIgnoreFile string) error
- func CaseInsensitive(parameter string) func(word string) bool
- func CheckGitIgnoreFile(directory string) (string, error)
- func CheckKubeConfigExist() bool
- func CheckOutputFlag(outputFlag string) bool
- func CheckPathExists(path string) bool
- func ConvertGitSSHRemoteToHTTPS(remote string) string
- func ConvertKeyValueStringToMap(params []string) map[string]string
- func ConvertLabelsToSelector(labels map[string]string) string
- func CopyFile(srcPath string, dstPath string, info os.FileInfo) error
- func CreateIfNotExists(configFile string) error
- func DeleteConfiguration(info interface{}, parameter string) error
- func DeleteIndexFile(directory string) error
- func DeletePath(path string) error
- func DisplayLog(followLog bool, rd io.ReadCloser, compName string) (err error)
- func DownloadFile(params DownloadParams) error
- func DownloadFileInMemory(url string) ([]byte, error)
- func ExtractComponentType(namespacedVersionedComponentType string) string
- func FilterIgnores(filesChanged, filesDeleted, absIgnoreRules []string) (filesChangedFiltered, filesDeletedFiltered []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 GetAndExtractZip(zipURL string, destination string, pathToUnzip string) error
- func GetBoolOrDefault(ptr *bool, defaultValue bool) bool
- func GetContainerPortsFromStrings(ports []string) ([]corev1.ContainerPort, error)
- func GetDNS1123Name(str string) string
- func GetFromFile(c interface{}, filename string) error
- func GetGitHubZipURL(repoURL string, branch string, startPoint string) (string, error)
- func GetHostWithPort(inputURL string) (string, error)
- func GetIgnoreRulesFromDirectory(directory string) ([]string, error)
- func GetIntOrDefault(ptr *int, defaultValue int) int
- func GetLowerCaseParameters(parameters []string) map[string]bool
- func GetRandomName(prefix string, prefixMaxLen int, existList []string, retries int) (string, error)
- func GetRemoteFilesMarkedForDeletion(delSrcRelPaths []string, remoteFolder string) []string
- func GetSortedKeys(mapping map[string]string) []string
- func GetSplitValuesFromStr(inputStr string) []string
- func GetStringOrDefault(ptr *string, defaultValue string) string
- func GetStringOrEmpty(ptr *string) string
- func HTTPGetFreePort() (int, error)
- func HTTPGetRequest(request HTTPRequestParams) ([]byte, error)
- func In(arr []string, value string) bool
- func IsEmpty(name string) (bool, error)
- func IsGlobExpMatch(strToMatch string, globExps []string) (bool, error)
- func IsSet(info interface{}, parameter string) bool
- func IsValidProjectDir(path string, devfilePath string) error
- func NamespaceOpenShiftObject(componentName string, applicationName string) (string, error)
- func OpenBrowser(url string) error
- func ParseComponentImageName(imageName string) (string, string, string, string)
- func PathEqual(firstPath string, secondPath string) bool
- func ReadFilePath(u *url.URL, os string) string
- func RemoveDuplicates(s []string) []string
- func RemoveRelativePathFromFiles(files []string, path string) ([]string, error)
- func SliceDifference(s1 []string, s2 []string) []string
- func TruncateString(str string, maxLen int) string
- func Unzip(src, dest, pathToUnzip string) ([]string, error)
- func ValidateFile(filePath string) error
- func ValidateK8sResourceName(key string, value string) error
- func ValidateURL(sourceURL string) error
- func WriteFile(newFileMap map[string]FileData, resolvedPath string) error
- func WriteToFile(c interface{}, filename string) error
- type ConcurrentTask
- type ConcurrentTasks
- type DownloadParams
- type FileData
- type FileIndex
- type HTTPRequestParams
- type IndexerRet
- type ResourceRequirementInfo
Constants ¶
const ( HTTPRequestTimeout = 30 * time.Second // HTTPRequestTimeout configures timeout of all HTTP requests ResponseHeaderTimeout = 30 * time.Second // ResponseHeaderTimeout is the timeout to retrieve the server's response headers ModeReadWriteFile = 0600 // default Permission for a file CredentialPrefix = "odo-" // CredentialPrefix is the prefix of the credential that uses to access secure registry )
HTTPRequestTimeout configures timeout of all HTTP requests
const WIN = "windows"
WIN represent the windows OS
Variables ¶
This section is empty.
Functions ¶
func AddFileToIgnoreFile ¶ added in v1.2.4
AddFileToIgnoreFile adds a file to the gitignore file. It only does that if the file doesn't exist
func AddOdoFileIndex ¶ added in v1.0.3
AddOdoFileIndex adds odo-file-index.json to .gitignore
func CaseInsensitive ¶ added in v1.0.0
CaseInsensitive returns a function which compares two words caseinsensitively
func CheckGitIgnoreFile ¶ added in v1.0.3
CheckGitIgnoreFile checks .gitignore file exists or not, if not then create it
func CheckKubeConfigExist ¶ added in v1.1.2
func CheckKubeConfigExist() bool
CheckKubeConfigExist checks for existence of kubeconfig
func CheckOutputFlag ¶ added in v1.0.0
CheckOutputFlag returns true if specified output format is supported
func CheckPathExists ¶ added in v0.0.17
CheckPathExists checks if a path exists or not
func ConvertGitSSHRemoteToHTTPS ¶ added in v1.2.0
Converts Git ssh remote to https
func ConvertKeyValueStringToMap ¶ added in v0.0.14
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 ¶ added in v1.0.0
CreateIfNotExists creates the directory and the file if it doesn't exist
func DeleteConfiguration ¶ added in v1.0.0
DeleteConfiguration sets a parameter to null in a struct using reflection
func DeleteIndexFile ¶ added in v1.0.2
DeleteIndexFile deletes the index file. It doesn't throw error if it doesn't exist
func DeletePath ¶ added in v1.0.2
DeletePath deletes a file/directory if it exists and doesn't throw error if it doesn't exist
func DisplayLog ¶ added in v1.2.4
func DisplayLog(followLog bool, rd io.ReadCloser, compName string) (err error)
DisplayLog displays logs to user stdout with some color formatting
func DownloadFile ¶ added in v1.1.2
func DownloadFile(params DownloadParams) error
DownloadFile downloads the file to the filepath given URL and token (if applicable)
func DownloadFileInMemory ¶ added in v1.2.4
DownloadFileInMemory uses the url to download the file and return bytes
func ExtractComponentType ¶ added in v0.0.11
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 FilterIgnores ¶ added in v1.1.2
func FilterIgnores(filesChanged, filesDeleted, absIgnoreRules []string) (filesChangedFiltered, filesDeletedFiltered []string)
FilterIgnores applies the glob rules on the filesChanged and filesDeleted and filters them returns the filtered results which match any of the glob rules
func GenFileURL ¶ added in v0.0.17
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 ¶ added in v0.0.20
GetAbsGlobExps converts the relative glob expressions into absolute glob expressions returns the absolute glob expressions
func GetAbsPath ¶ added in v0.0.17
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 GetAndExtractZip ¶ added in v1.2.0
GetAndExtractZip downloads a zip file from a URL with a http prefix or takes an absolute path prefixed with file:// and extracts it to a destination. pathToUnzip specifies the path within the zip folder to extract
func GetBoolOrDefault ¶ added in v1.2.4
func GetContainerPortsFromStrings ¶ added in v0.0.20
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 ¶ added in v0.0.15
GetDNS1123Name Converts passed string into DNS-1123 string
func GetFromFile ¶ added in v1.0.0
GetFromFile unmarshals a struct from a odo config file
func GetGitHubZipURL ¶ added in v1.2.0
GetGitHubZipURL downloads a repo from a URL to a destination
func GetHostWithPort ¶ added in v0.0.18
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
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 GetIntOrDefault ¶ added in v1.2.4
func GetLowerCaseParameters ¶ added in v1.0.0
GetLowerCaseParameters creates a set-like map of supported parameters from the supported parameter names
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:
- 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 GetRemoteFilesMarkedForDeletion ¶ added in v1.1.2
GetRemoteFilesMarkedForDeletion returns the list of remote files marked for deletion
func GetSortedKeys ¶ added in v0.0.19
GetSortedKeys retrieves the alphabetically-sorted keys of the specified map
func GetSplitValuesFromStr ¶ added in v0.0.20
GetSplitValuesFromStr returns a slice containing the split string, using ',' as a separator
func GetStringOrDefault ¶ added in v1.2.4
func GetStringOrEmpty ¶ added in v1.2.4
func HTTPGetFreePort ¶ added in v1.2.4
HTTPGetFreePort gets a free port from the system
func HTTPGetRequest ¶ added in v1.1.1
func HTTPGetRequest(request HTTPRequestParams) ([]byte, error)
HTTPGetRequest gets resource contents given URL and token (if applicable)
func IsEmpty ¶ added in v1.1.2
IsEmpty checks to see if a directory is empty shamelessly taken from: https://stackoverflow.com/questions/30697324/how-to-check-if-directory-on-path-is-empty this helps detect any edge cases where an empty directory is copied over
func IsGlobExpMatch ¶ added in v0.0.20
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 ¶ added in v1.0.0
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 IsValidProjectDir ¶ added in v1.2.0
IsValidProjectDir checks that the folder to download the project from devfile is either empty or only contains the devfile used.
func NamespaceOpenShiftObject ¶ added in v0.0.7
NamespaceOpenShiftObject hyphenates applicationName and componentName
func OpenBrowser ¶ added in v0.0.15
OpenBrowser opens the URL within the users default browser
func ParseComponentImageName ¶ added in v0.0.19
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 ¶ added in v0.0.11
ReadFilePath Reads file path form URL file:///C:/path/to/file to C:\path\to\file
func RemoveDuplicates ¶ added in v1.0.0
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 ¶ added in v1.0.0
RemoveRelativePathFromFiles removes a specified path from a list of files
func SliceDifference ¶ added in v0.0.15
SliceDifference returns the values of s2 that do not exist in s1
func TruncateString ¶ added in v0.0.15
TruncateString truncates passed string to given length Note: if -1 is passed, the original string is returned
func Unzip ¶ added in v1.2.0
Unzip will decompress a zip archive, moving specified files and folders within the zip file (parameter 1) to an output directory (parameter 2) Source: https://golangcode.com/unzip-files-in-go/ pathToUnzip (parameter 3) is the path within the zip folder to extract
func ValidateFile ¶ added in v1.2.3
ValidateFile validates the file
func ValidateK8sResourceName ¶ added in v1.1.2
ValidateK8sResourceName sanitizes kubernetes resource name with the following requirements: - Contain at most 63 characters - Contain only lowercase alphanumeric characters or ‘-’ - Start with an alphanumeric character - End with an alphanumeric character - Must not contain all numeric values
func ValidateURL ¶ added in v1.2.1
ValidateURL validates the URL
func WriteFile ¶ added in v1.2.4
WriteFile writes a file map to a file, the file map is given by newFileMap param and the file location is resolvedPath param
func WriteToFile ¶ added in v1.0.0
WriteToFile marshals a struct to a file
Types ¶
type ConcurrentTask ¶ added in v1.2.2
type ConcurrentTask struct {
ToRun func(errChannel chan error)
}
ConcurrentTask is a task to execute in a go-routine
type ConcurrentTasks ¶ added in v1.2.2
type ConcurrentTasks struct {
// contains filtered or unexported fields
}
ConcurrentTasks records tasks to be run concurrently with go-routines
func NewConcurrentTasks ¶ added in v1.2.2
func NewConcurrentTasks(taskNumber int) *ConcurrentTasks
NewConcurrentTasks creates a new ConcurrentTasks instance, dimensioned to accept at least the specified number of tasks
func (*ConcurrentTasks) Add ¶ added in v1.2.2
func (ct *ConcurrentTasks) Add(task ConcurrentTask)
Add adds the specified ConcurrentTask to the list of tasks to be run concurrently
func (*ConcurrentTasks) Run ¶ added in v1.2.2
func (ct *ConcurrentTasks) Run() error
Run concurrently runs the added tasks failing on the first error Based on https://garrypolley.com/2016/02/10/golang-routines-errors/
type DownloadParams ¶ added in v1.2.4
type DownloadParams struct { Request HTTPRequestParams Filepath string }
DownloadParams holds parameters of forming file download request
type FileIndex ¶ added in v1.0.0
FileIndex holds the file index used for storing local file state change
type HTTPRequestParams ¶ added in v1.2.4
HTTPRequestParams holds parameters of forming http request
type IndexerRet ¶ added in v1.2.4
type IndexerRet struct { FilesChanged []string FilesDeleted []string NewFileMap map[string]FileData ResolvedPath string }
A struct that represent return value of RunIndexer function
func RunIndexer ¶ added in v1.0.0
func RunIndexer(directory string, ignoreRules []string) (ret IndexerRet, 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
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, error)
FetchResourceQuantity takes passed min, max and requested resource quantities and returns min and max resource requests