const notCloned … type RepoSpec … // CloneSpec returns a string suitable for "git clone {spec}". func (x *RepoSpec) CloneSpec() string { … } func (x *RepoSpec) CloneDir() filesys.ConfirmedDir { … } func (x *RepoSpec) Raw() string { … } func (x *RepoSpec) AbsPath() string { … } func (x *RepoSpec) Cleaner(fSys filesys.FileSystem) func() error { … } const refQuery … const gitSuffix … const gitRootDelimiter … const pathSeparator … // NewRepoSpecFromURL parses git-like urls. // From strings like [email protected]:someOrg/someRepo.git or // https://github.com/someOrg/someRepo?ref=someHash, extract // the different parts of URL, set into a RepoSpec object and return RepoSpec object. // It MUST return an error if the input is not a git-like URL, as this is used by some code paths // to distinguish between local and remote paths. // // In particular, NewRepoSpecFromURL separates the URL used to clone the repo from the // elements Kustomize uses for other purposes (e.g. query params that turn into args, and // the path to the kustomization root within the repo). func NewRepoSpecFromURL(n string) (*RepoSpec, error) { … } const allSegments … const orgRepoSegments … func defaultRepoPathLength(host string) int { … } // parsePathParts splits the repo path that will ultimately be passed to git to clone the // repo from the kustomization root path, which Kustomize will execute the build in after the repo // is cloned. // // We first try to do this based on explicit markers in the URL (e.g. _git, .git or //). // If none are present, we try to apply a historical default repo path length that is derived from // Github URLs. If there aren't enough segments, we have historically considered the URL invalid. func parsePathParts(n string, defaultSegmentLength int) (string, string, error) { … } func tryExplicitMarkerSplit(n string) (string, string, bool) { … } func tryDefaultLengthSplit(n string, defaultSegmentLength int) (string, string, bool) { … } func kustRootPathExitsRepo(kustRootPath string) bool { … } const defaultSubmodules … const defaultTimeout … func parseQuery(query string) (string, time.Duration, bool) { … } func extractHost(n string) (string, string, error) { … } // ignoreForcedGitProtocol strips the "git::" prefix from URLs. // We used to use go-getter to handle our urls: https://github.com/hashicorp/go-getter. // The git:: prefix signaled go-getter to use the git protocol to fetch the url's contents. // We silently strip this prefix to allow these go-getter-style urls to continue to work, // although the git protocol (which is insecure and unsupported on many platforms, including Github) // will not actually be used as intended. func ignoreForcedGitProtocol(n string) string { … } // acceptSCPStyle returns true if the scheme and username indicate potential use of an SCP-style URL. // With this style, the scheme is not explicit and the path is delimited by a colon. // Strictly speaking the username is optional in SCP-like syntax, but Kustomize has always // required it for non-Github URLs. // Example: [email protected]:path/to/repo.git/ func acceptSCPStyle(scheme, username string, isGithubURL bool) bool { … } func validateScheme(scheme string, acceptSCPStyle bool) error { … } const fileScheme … const httpScheme … const httpsScheme … const sshScheme … func extractScheme(s string) (string, string) { … } func extractUsername(s string) (string, string) { … } func isStandardGithubHost(s string) bool { … } // trimPrefixIgnoreCase returns the rest of s and true if prefix, ignoring case, prefixes s. // Otherwise, trimPrefixIgnoreCase returns s and false. func trimPrefixIgnoreCase(s, prefix string) (string, bool) { … } func findPathSeparator(hostPath string, acceptSCP bool) int { … } func normalizeGithubHostParts(scheme, username string) (string, string, string) { … }