Documentation
¶
Overview ¶
This package is taken from github.com/docker/docker/pkg/stringid It is used for generating and validating unique identifiers such as generating random strings, validating imageIds and validating truncated imageIDs
Index ¶
- func CheckPathValid(path string) (os.FileInfo, error)
- func CopyDirectory(src, dst string) error
- func CopyFile(src, dst string) error
- func CreateFileIfNotExist(filePath string) error
- func CreateIfNotExistDir(dirPath string) error
- func GenerateNonCryptoID() string
- func GenerateRandomID() string
- func GetAllDirectoriesName(dirPath string) []string
- func GetDirsInDir(dirPath string) (error, []string)
- func GetDurationFromTimestamp(ts string) (time.Duration, error)
- func GetUniqueStrings(list []string) []string
- func IsShortID(id string) bool
- func ParsePortMapping(portMap string) (uint32, uint32, error)
- func RemoveDirRecursively(dirPath string) error
- func RemoveFileIfExists(filePath string) error
- func StringInSlice(a string, list []string) bool
- func Tar(contextDir string, compression Compression, destinationDir string, ...) error
- func TruncateID(id string, maxLen int) string
- func TruncateString(str string, maxLen int) string
- func UInt32InList(a uint32, list []uint32) bool
- func ValidateDirExists(dirPath string) error
- func ValidateFileExists(filePath string) error
- func ValidateID(id string) error
- type Compression
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPathValid ¶
Check if the path provided is a valid path, by calling stat on it if the path is invalid due to either non accesibility or existence an error is returned else FileInfo type is returned.
func CopyDirectory ¶
func CreateFileIfNotExist ¶
func CreateIfNotExistDir ¶
Create the directory sequence in dirPath if it does not exist if there was an error while creating the directory it returns the error else it returns nil indicating success
func GenerateNonCryptoID ¶
func GenerateNonCryptoID() string
GenerateNonCryptoID generates unique id without using cryptographically secure sources of random. It helps you to save entropy.
func GetAllDirectoriesName ¶
This is very flexible and will not report any error even though it is not able to access the directory. It will return an empty list in such cases. The caller must take care of this.
func GetDirsInDir ¶
Returns a list of directory present in the provided directory
func GetUniqueStrings ¶
From a list of strings generate a list containing only unique strings from the list.
func ParsePortMapping ¶
ParsePortMapping parses the port mapping string and return the required ports If the portMapping string is not valid, this returns an error. The format of the port mapping is `HOST_PORT:CONTAINER_PORT`
func RemoveDirRecursively ¶
func RemoveFileIfExists ¶
func Tar ¶
func Tar(contextDir string, compression Compression, destinationDir string, additionalCtx map[string]string, subDirToSkip []string) error
Tar the provided context directory into the destination directory, additionalCtx is the context of one or more file which is to be added to the tar file
In this function the contextDir is the absolute path of the directory to be compressed to the tar archive. DestincationDir is the directory to put the obtained tar file into.
func TruncateID ¶
TruncateID returns a shorthand version of a string identifier for convenience. A collision with other shorthands is very unlikely, but possible. In case of a collision a lookup with TruncIndex.Get() will fail, and the caller will need to use a longer prefix, or the full-length Id.
func TruncateString ¶
func UInt32InList ¶
func ValidateDirExists ¶
Validates if the directory pointed by `dirPath` exists If the directory does not exist or is not accessible it will return an error. The path specified must also be a directory and not just a regular file.
func ValidateFileExists ¶
Validates if the file pointed by `filePath` exists. If the file does not exist or is not accessible it will return an error. The path specified must also be a valid file
func ValidateID ¶
ValidateID checks whether an ID string is a valid image ID.