Documentation ¶
Index ¶
Constants ¶
const RepoCacheDirEnv = "KPT_CACHE_DIR"
RepoCacheDirEnv is the name of the environment variable that controls the cache directory for remote repos. Defaults to UserHomeDir/.kpt/repos if unspecified.
Variables ¶
var DefaultRef = func(repo string) (string, error) { masterRef := "master" mainRef := "main" masterExists, err := branchExists(repo, masterRef) if err != nil { return "", err } mainExists, err := branchExists(repo, mainRef) if err != nil { return "", err } if masterExists { return masterRef, nil } else if mainExists { return mainRef, nil } return masterRef, nil }
DefaultRef returns the DefaultRef to "master" if master branch exists in remote repository, falls back to "main" if master branch doesn't exist Making it a var so that it can be overridden for local testing
Functions ¶
This section is empty.
Types ¶
type GitRunner ¶
type GitRunner struct { // Dir is the directory the commands are run in. Dir string // RepoDir is the directory of the git repo containing the package RepoDir string // Stderr is where the git command Stderr is written Stderr *bytes.Buffer // Stdin is where the git command Stdin is read from Stdin *bytes.Buffer // Stdout is where the git command Stdout is written Stdout *bytes.Buffer // Verbose prints verbose command information Verbose bool }
GitRunner runs git commands in a git repo.
func NewLocalGitRunner ¶
NewLocalGitRunner returns a new GitRunner for a local package.
func NewUpstreamGitRunner ¶
func NewUpstreamGitRunner(uri, dir string, required []string, optional []string) (*GitRunner, error)
NewUpstreamGitRunner returns a new GitRunner for an upstream package.
The upstream package repo will be fetched to a local cache directory under $HOME/.kpt and hard reset to origin/main. The refs will also be fetched so they are available locally.