package
1.2.6
Repository: https://github.com/redhat-developer/ocdev.git
Documentation: pkg.go.dev

# Functions

AddFileToIgnoreFile adds a file to the gitignore file.
AddOdoFileIndex adds odo-file-index.json to .gitignore.
CalculateFileDataKeyFromPath converts an absolute path to relative (and converts to OS-specific paths) for use as a map key in IndexerRet and FileIndex.
CaseInsensitive returns a function which compares two words caseinsensitively.
CheckGitIgnoreFile checks .gitignore file exists or not, if not then create it.
CheckKubeConfigExist checks for existence of kubeconfig.
CheckOutputFlag returns true if specified output format is supported.
CheckPathExists checks if a path exists or not.
Converts Git ssh remote to https.
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.
ConvertLabelsToSelector converts the given labels to selector.
CopyFile copies file from source path to destination path.
CreateIfNotExists creates the directory and the file if it doesn't exist.
DeleteConfiguration sets a parameter to null in a struct using reflection.
DeleteIndexFile deletes the index file.
DeletePath deletes a file/directory if it exists and doesn't throw error if it doesn't exist.
DisplayLog displays logs to user stdout with some color formatting.
DownloadFile downloads the file to the filepath given URL and token (if applicable).
DownloadFileInMemory uses the url to download the file and return bytes.
DownloadFileWithCache downloads the file to the filepath given URL and token (if applicable) cacheFor determines how long the response should be cached (in minutes), 0 for no caching.
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.
FetchResourceQuantity takes passed min, max and requested resource quantities and returns min and max resource requests.
FilterIgnores applies the glob rules on the filesChanged and filesDeleted and filters them returns the filtered results which match any of the glob rules.
GenerateNewFileDataEntry creates a new FileData entry for use by IndexerRet and/or FileIndex.
GenerateRandomString generates a random string of lower case characters of the given size.
GenFileURL Converts file path on windows to /C:/path/to/file to work in URL.
GetAbsGlobExps converts the relative glob expressions into absolute glob expressions returns the absolute glob expressions.
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.
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.
No description provided by the author
GetContainerPortsFromStrings generates ContainerPort values from the array of string port values ports is the array containing the string port values.
GetDNS1123Name Converts passed string into DNS-1123 string.
GetFromFile unmarshals a struct from a odo config file.
GetGitHubZipURL downloads a repo from a URL to a destination.
GetHostWithPort parses provided url and returns string formated as host:port even if port was not specifically specified in the origin url.
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).
No description provided by the author
GetLowerCaseParameters creates a set-like map of supported parameters from the supported parameter names.
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.
GetRemoteFilesMarkedForDeletion returns the list of remote files marked for deletion.
GetSortedKeys retrieves the alphabetically-sorted keys of the specified map.
GetSplitValuesFromStr returns a slice containing the split string, using ',' as a separator.
No description provided by the author
No description provided by the author
HTTPGetFreePort gets a free port from the system.
HTTPGetRequest gets resource contents given URL and token (if applicable) cacheFor determines how long the response should be cached (in minutes), 0 for no caching.
In checks if the value is in the array.
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.
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.
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.
IsValidProjectDir checks that the folder to download the project from devfile is either empty or only contains the devfile used.
NamespaceOpenShiftObject hyphenates applicationName and componentName.
NewConcurrentTasks creates a new ConcurrentTasks instance, dimensioned to accept at least the specified number of tasks.
NewFileIndex returns a fileIndex.
OpenBrowser opens the URL within the users default browser.
ParseComponentImageName returns 1.
PathEqual compare the paths to determine if they are equal.
ReadFileIndex tries to read the odo index file from the given location and returns the data from the file if no such file is present, it means the folder hasn't been walked and thus returns a empty list.
ReadFilePath Reads file path form URL file:///C:/path/to/file to C:\path\to\file.
RemoveDuplicates goes through a string slice and removes all duplicates.
RemoveRelativePathFromFiles removes a specified path from a list of files.
ResolveIndexFilePath resolves the filepath of the odo index file in the .odo folder.
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.
SliceDifference returns the values of s2 that do not exist in s1.
TruncateString truncates passed string to given length Note: if -1 is passed, the original string is returned.
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.
ValidateFile validates the file.
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.
ValidateURL validates the URL.
WriteFile writes a file map to a file, the file map is given by newFileMap param and the file location is resolvedPath param.
WriteToFile marshals a struct to a file.

# Constants

CredentialPrefix is the prefix of the credential that uses to access secure registry.
HTTPRequestTimeout configures timeout of all HTTP requests.
default Permission for a file.
ResponseHeaderTimeout is the timeout to retrieve the server's response headers.
WIN represent the windows OS.

# Structs

ConcurrentTask is a task to execute in a go-routine.
ConcurrentTasks records tasks to be run concurrently with go-routines.
DownloadParams holds parameters of forming file download request.
No description provided by the author
FileIndex holds the file index used for storing local file state change.
HTTPRequestParams holds parameters of forming http request.
IndexerRet is a struct that represent return value of RunIndexer function.
ResourceRequirementInfo holds resource quantity before transformation into its appropriate form in container spec.