profile

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 4 Imported by: 0

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

View Source
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

func AddToGitignore(dir string) (string, error)

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

func GitignoreHasLocal(dir string) (bool, error)

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

func InGitRepo(dir string) bool

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

func LocalExists(dir string) bool

LocalExists reports whether dir already contains a .gcloudenv file.

func WriteLocal

func WriteLocal(dir, name string) (string, error)

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.

type Source

type Source string

Source describes where a resolved profile name came from, for display.

const (
	SourceFlag  Source = "flag"
	SourceLocal Source = "local file"
	SourceEnv   Source = "environment"
	SourceNone  Source = "none"
)

The possible Source values, in resolution-precedence order.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL