util

package
v5.4.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FromFileFlag              = "from-file"
	FromLiteralFlag           = "from-literal"
	FromEnvFileFlag           = "from-env-file"
	DisableNameSuffixHashFlag = "disableNameSuffixHash"
	BehaviorFlag              = "behavior"
	NamespaceFlag             = "namespace"
	NewNamespaceFlag          = "new-namespace"
	FlagFormat                = "--%s=%s"
)
View Source
const DefaultNamespace = "default"

DefaultNamespace is the default namespace name in Kubernetes.

Variables

This section is empty.

Functions

func ConvertSliceToMap

func ConvertSliceToMap(inputs []string, kind string) (map[string]string, error)

ConvertSliceToMap converts a slice of strings in the form of `key:value` into a map.

func ConvertToMap

func ConvertToMap(input string, kind string) (map[string]string, error)

ConvertToMap converts a string in the form of `key:value,key:value,...` into a map.

func GlobPatterns

func GlobPatterns(fSys filesys.FileSystem, patterns []string) ([]string, error)

GlobPatterns accepts a slice of glob strings and returns the set of matching file paths.

func GlobPatternsWithLoader

func GlobPatternsWithLoader(fSys filesys.FileSystem, ldr ifc.Loader, patterns []string, skipValidation bool) ([]string, error)

GlobPatternsWithLoader accepts a slice of glob strings and returns the set of matching file paths. If validation is skipped, then it will return the patterns as provided. Otherwise, It will try to load the files from the filesystem. If files are not found in the filesystem, it will try to load from remote. It returns an error if validation is not skipped and there are no matching files or it can't load from remote.

func MergeFlagsIntoGeneratorArgs added in v5.3.0

func MergeFlagsIntoGeneratorArgs(args *types.GeneratorArgs, flags ConfigMapSecretFlagsAndArgs)

func NamespaceEqual added in v5.3.0

func NamespaceEqual(namespace string, otherNamespace string) bool

NamespaceEqual checks if two namespaces are the same. It considers the empty namespace and the default namespace to be the same. As such, when one namespace is the empty string ('""') and the other namespace is "default", this function will return true.

func UpdateLiteralSources added in v5.3.0

func UpdateLiteralSources(
	args *types.GeneratorArgs,
	flags ConfigMapSecretFlagsAndArgs,
) error

UpdateLiteralSources looks for literal sources that already exist and tries to replace their values with new values. The key specified must exist in the target resource (ConfigMap or Secret).

Types

type BuildMetadataValidator

type BuildMetadataValidator struct{}

func (*BuildMetadataValidator) Validate

func (b *BuildMetadataValidator) Validate(args []string) ([]string, error)

type ConfigMapSecretFlagsAndArgs added in v5.3.0

type ConfigMapSecretFlagsAndArgs struct {
	// Name of ConfigMap/Secret (required)
	Name string
	// FileSources to derive the ConfigMap/Secret from (optional)
	FileSources []string
	// LiteralSources to derive the ConfigMap/Secret from (optional)
	LiteralSources []string
	// EnvFileSource to derive the ConfigMap/Secret from (optional)
	// TODO: Rationalize this name with Generic.EnvSource
	EnvFileSource string
	// Resource generation behavior (optional)
	Behavior string
	// Type of secret to create
	Type string
	// Namespace of ConfigMap/Secret (optional) -- if unspecified, default is assumed
	Namespace string
	// Disable name suffix
	DisableNameSuffixHash bool
	// NewNamespace for ConfigMap/Secret (optional) -- only for 'edit set' command
	NewNamespace string
}

ConfigMapSecretFlagsAndArgs encapsulates the options for add secret/configmap commands.

func (*ConfigMapSecretFlagsAndArgs) ExpandFileSource added in v5.3.0

func (a *ConfigMapSecretFlagsAndArgs) ExpandFileSource(fSys filesys.FileSystem) error

ExpandFileSource normalizes a string list, possibly containing globs, into a validated, globless list. For example, this list: - some/path - some/dir/a* - bfile=some/dir/b* becomes: - some/path - some/dir/airplane - some/dir/ant - some/dir/apple - bfile=some/dir/banana i.e. everything is converted to a key=value pair, where the value is always a relative file path, and the key, if missing, is the same as the value. In the case where the key is explicitly declared, the globbing, if present, must have exactly one match.

func (*ConfigMapSecretFlagsAndArgs) ValidateAdd added in v5.3.0

func (a *ConfigMapSecretFlagsAndArgs) ValidateAdd(args []string) error

ValidateAdd validates required fields are set to support structured generation for the edit add command.

func (*ConfigMapSecretFlagsAndArgs) ValidateSet added in v5.3.0

func (a *ConfigMapSecretFlagsAndArgs) ValidateSet(args []string) error

ValidateSet validates required fields are set to support structured generation for the edit set command.

Jump to

Keyboard shortcuts

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