Documentation
¶
Overview ¶
Package profile resolves which gcloud configuration should be active, following the same precedence philosophy as nvm/rbenv: an explicit choice beats a directory-local file, which beats the environment, which beats the configured global default.
Index ¶
Constants ¶
const LocalFile = ".gcloudenv"
LocalFile is the per-directory marker, analogous to .nvmrc / .ruby-version.
Variables ¶
This section is empty.
Functions ¶
func AddToGitignore ¶ added in v1.2.0
AddToGitignore appends the .gcloudenv pattern to dir's .gitignore, creating the file if it does not exist, and returns the .gitignore path.
func GitignoreHasLocal ¶ added in v1.2.0
GitignoreHasLocal reports whether dir's .gitignore already lists the .gcloudenv pattern. A missing .gitignore counts as "not listed".
func InGitRepo ¶ added in v1.2.0
InGitRepo reports whether dir is inside a git working tree, by walking up looking for a .git entry (a directory for normal repos, a file for worktrees and submodules).
func LocalExists ¶ added in v1.2.0
LocalExists reports whether dir already contains a .gcloudenv file.
func WriteLocal ¶
WriteLocal writes a .gcloudenv file naming the profile in dir.
Types ¶
type Resolution ¶
type Resolution struct {
Name string
Source Source
// Path is the .gcloudenv file used, when Source is SourceLocal.
Path string
}
Resolution is the outcome of resolving the active profile.
func Resolve ¶
func Resolve(flag, startDir, envValue string) Resolution
Resolve picks a profile name given an explicit flag value (may be empty), the starting directory to search upward from, and the current environment. It does not consult gcloud's own global default; callers fall back to that when Source is SourceNone.