setters

package
v0.39.2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GcloudProject       = "gcloud.core.project"
	GcloudProjectNumber = "gcloud.project.projectNumber"
)

Variables

View Source
var GetProjectNumberFromProjectID = func(projectID string) (string, error) {
	gcloudCmd := exec.Command("gcloud",
		"projects", "describe", projectID, "--format", "value(projectNumber)")
	b, err := gcloudCmd.Output()
	if err != nil {
		return "", errors.Wrapf(err, "failed to get project number for %s, please verify gcloud "+
			"credentials are valid and try again", projectID)
	}
	return strings.TrimSpace(string(b)), nil
}

Functions

func CheckForRequiredSetters added in v0.38.0

func CheckForRequiredSetters(path string) error

CheckForRequiredSetters takes the package path, checks if there is a KrmFile and checks if all the required setters are set

func DefExists added in v0.26.0

func DefExists(resourcePath, setterName string) bool

DefExists returns true if the setterName exists in Kptfile definitions

func SetV2AutoSetter added in v0.34.0

func SetV2AutoSetter(name, value, root string, w io.Writer) error

SetV2AutoSetter sets the input auto setter recursively in all the sub-packages of root Sets GcloudProjectNumber as well, if input setter is GcloudProject

Types

type AutoSet added in v0.36.0

type AutoSet struct {
	// Writer is the output writer
	Writer io.Writer

	// PackagePath is the path of the package to apply auto-setters
	PackagePath string
}

func (AutoSet) PerformAutoSetters added in v0.36.0

func (a AutoSet) PerformAutoSetters() error

PerformAutoSetters auto-fills the setter values from the local environment in the target path for the setters which are not already set previously Auto setters are applied in the following order of precedence 1. Setter values from the parent package 2. Setter values from the environment variables 3. Setter values from gcloud configs The auto setters are applied for all the subpackages with in the directory tree of input PackagePath Only the setters which are NOT set locally (identified by isSet flag in setter definition of Kptfile), are only set by this operation

func (AutoSet) SetEnvAutoSetters added in v0.36.0

func (a AutoSet) SetEnvAutoSetters() error

SetEnvAutoSetters auto-fills setters from the environment

func (AutoSet) SetGcloudAutoSetters added in v0.36.0

func (a AutoSet) SetGcloudAutoSetters() error

SetGcloudAutoSetters auto-fills setters from gcloud config

func (AutoSet) SetInheritedSetters added in v0.36.0

func (a AutoSet) SetInheritedSetters() error

SetInheritedSetters traverses the absolute parentPath all the way to the root of file system to find a kpt package with Kptfile and auto-fills the setter values in targetPath and all its subpackages

Jump to

Keyboard shortcuts

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