Documentation
¶
Index ¶
- Constants
- Variables
- func AbsPkgArchivePath(archivePath string) (string, error)
- func AbsTarPath(tarPath string) (string, error)
- func CheckPackageSum(checkedSum, localPath string) bool
- func CreateFileIfNotExist(filePath string, storeFunc func() error) error
- func CreateSubdirInUserHome(subdir string) (string, error)
- func CreateSymlink(oldName, newName string) error
- func DataDir() (string, error)
- func DirExists(path string) bool
- func Exists(path string) (bool, error)
- func ExtractPkgArchive(archivePath string, destDir string) error
- func ExtractTarball(tarPath, destDir string) error
- func FindKFiles(path string) ([]string, error)
- func FindPackage(root, targetPackage string) (string, error)
- func FindPkgArchive(path string) (string, error)
- func GenerateModRelativePath(pkgName, path string) string
- func GetUsernamePassword(usernameOpt string, passwordOpt string, passwordFromStdinOpt bool) (string, string, error)
- func HashDir(dir string) (string, error)
- func IsGitRepoUrl(str string) bool
- func IsKfile(str string) bool
- func IsModRelativePath(s string) bool
- func IsPkgArchive(str string) bool
- func IsRef(str string) bool
- func IsSymlinkValidAndExists(symlinkPath string) (bool, bool, error)
- func IsTar(str string) bool
- func IsTgz(str string) bool
- func IsURL(str string) bool
- func JoinPath(elems ...string) string
- func MatchesPackageName(kclModPath, targetPackage string) bool
- func MoveFile(src, dest string) error
- func MoveOrCopy(src, dest string) error
- func NewProxyAwareClient(timeout time.Duration) *http.Client
- func ParseModRelativePath(s string) (string, string, error)
- func ParseRepoNameFromGitUrl(gitUrl string) string
- func ProxyFunc(req *http.Request) (*url.URL, error)
- func RmNewline(s string) string
- func ShortHash(input string) (string, error)
- func StoreToFile(filePath string, dataStr string) error
- func TarDir(srcDir string, tarPath string, include []string, exclude []string) error
- func UnTarDir(tarPath string, destDir string) error
Constants ¶
const KPM_PROXY = "KPM_PROXY"
KPM_PROXY is the environment variable kpm checks for an explicit proxy override. When set, it takes precedence over the standard HTTP_PROXY / HTTPS_PROXY / NO_PROXY variables consumed by http.ProxyFromEnvironment.
Supported forms:
KPM_PROXY=http://proxy.local:3128 KPM_PROXY=https://user:pass@proxy.local:3128
Set KPM_PROXY=direct to disable any inherited proxy for this process.
const ModRelativePathPattern = `\$\{([a-zA-Z0-9_-]+:)?KCL_MOD\}/`
Variables ¶
var PkgArchiveNotFound = goerrors.New("failed to find the downloaded kcl package tar file")
Functions ¶
func AbsPkgArchivePath ¶ added in v0.12.5
AbsPkgArchivePath checks whether path 'archivePath' exists and whether path 'archivePath' ends with '.tar' or '.tgz'. And after checking, it returns the absolute path.
func AbsTarPath ¶ added in v0.3.7
AbsTarPath checks whether path 'tarPath' exists and whether path 'tarPath' ends with '.tar' And after checking, absTarPath return the abs path for 'tarPath'.
func CheckPackageSum ¶ added in v0.3.7
CheckPackageSum will check whether the 'checkedSum' is equal to the hash of the package under 'localPath'.
func CreateFileIfNotExist ¶
CreateFileIfNotExist will check whether the file under a certain path 'filePath/fileName' exists, and return an error if it exists, and call the method 'storeFunc' to save the file if it does not exist.
func CreateSubdirInUserHome ¶
DefaultKpmHome create the '.kpm' in the user home and return the path of ".kpm".
func CreateSymlink ¶
CreateSymlink will create symbolic link named 'newName' for 'oldName', and if the symbolic link already exists, it will be deleted and recreated. Note: CreateSymlink is only useful on unix-like systems.
func DataDir ¶ added in v0.12.4
DataDir returns the XDG data directory for the current platform. It follows the XDG Base Directory Specification: - Returns $XDG_DATA_HOME if set - Returns ~/.local/share on Unix systems if XDG_DATA_HOME is not set - Returns ~/Library/Application Support on macOS - Returns %LOCALAPPDATA% on Windows
func ExtractPkgArchive ¶ added in v0.12.5
ExtractPkgArchive extracts a package archive in '.tar' or '.tgz' format to 'destDir'.
func ExtractTarball ¶ added in v0.8.3
ExtractTarball support extracting tarball with '.tgz' format.
func FindKFiles ¶
FindKFiles will find all the '.k' files in the 'path' directory.
func FindPackage ¶ added in v0.10.0
FindPackage finds the package with the package name 'targetPackage' under the 'root' directory kcl.mod file.
func FindPkgArchive ¶ added in v0.11.0
FindPkgArchive will find the full path of the KCL package archive in the 'path' directory.
func GenerateModRelativePath ¶ added in v0.11.0
GenerateModRelativePath generates a mod relative path from the package name and path
func GetUsernamePassword ¶
func GetUsernamePassword(usernameOpt string, passwordOpt string, passwordFromStdinOpt bool) (string, string, error)
Copied/Adapted from https://github.com/helm/helm
func HashDir ¶
HashDir computes the checksum of a directory by concatenating all files and hashing them by sha256.
func IsGitRepoUrl ¶ added in v0.8.0
IsGitRepoUrl will check whether the string 'str' is a git repo url
func IsModRelativePath ¶ added in v0.9.1
If the path preffix is `${KCL_MOD}` or `${KCL_MOD:xxx}`
func IsPkgArchive ¶ added in v0.12.5
IsPkgArchive will check whether the string 'str' is a supported package archive path.
func IsSymlinkValidAndExists ¶ added in v0.8.5
IsSymlinkValidAndExists will check whether the symlink exists and points to a valid target return three values: whether the symlink exists, whether it points to a valid target, and any error encountered Note: IsSymlinkValidAndExists is only useful on unix-like systems.
func MatchesPackageName ¶ added in v0.11.0
MatchesPackageName checks whether the package name in the kcl.mod file under 'kclModPath' is equal to 'targetPackage'.
func MoveFile ¶ added in v0.9.0
MoveFile will move the file from 'src' to 'dest'. On windows, it will copy the file from 'src' to 'dest', and then delete the file under 'src'. On unix-like systems, it will rename the file from 'src' to 'dest'.
func MoveOrCopy ¶ added in v0.11.0
MoveOrCopy moves or copies the tmpDir to localPath based on the OS and error conditions. On windows, it will copy the file from 'src' to 'dest'. On unix-like systems, it will rename the file from 'src' to 'dest'.
func NewProxyAwareClient ¶ added in v0.12.9
NewProxyAwareClient returns an *http.Client whose transport honours the KPM_PROXY env var on top of the standard HTTP_PROXY/HTTPS_PROXY/NO_PROXY variables. Pass timeout=0 for no client-side timeout.
func ParseModRelativePath ¶ added in v0.11.0
ParseModRelativePath parses the package name and path from a mod relative path
func ParseRepoNameFromGitUrl ¶
ParseRepoNameFromGitUrl get the repo name from git url, the repo name in 'https://github.com/xxx/kcl1.git' is 'kcl1'.
func ProxyFunc ¶ added in v0.12.9
ProxyFunc returns an http.RoundTripper proxy function that combines:
- The standard Go behaviour (HTTP_PROXY/HTTPS_PROXY/NO_PROXY via http.ProxyFromEnvironment), unless overridden by $KPM_PROXY.
- An optional explicit override via $KPM_PROXY, or "direct" to bypass every proxy.
The function is safe to assign directly to http.Transport.Proxy.
func ShortHash ¶ added in v0.11.0
ShortHash takes a string (in this case, the Git URL) and returns a siphash. The method name references `cargo` which means performs a simple and quick hash
func StoreToFile ¶
StoreToFile will store 'data' into toml file under 'filePath'.
Types ¶
This section is empty.