yml

package
v0.0.0-...-33ef25c Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 14 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyAnnotation

func ApplyAnnotation(yamlText, k, v string) (string, error)

func ApplyNamespace

func ApplyNamespace(yamlText, ns string) (string, error)

ApplyNamespace applies the given namespaces to the resources in the yamlText if not set.

func ApplyPullSecret

func ApplyPullSecret(deploymentYaml string, pullSecret string) (string, error)

ApplyPullSecrets applies the given pullsecret to the deployment resource

func GetMetadata

func GetMetadata(content string) []metav1.ObjectMeta

SplitYamlByKind splits the given YAML into parts indexed by kind.

func JoinString

func JoinString(parts ...string) string

JoinString joins the given yaml parts into a single multipart document.

func MustApplyNamespace

func MustApplyNamespace(t test.Failer, yamlText, ns string) string

MustApplyNamespace applies the given namespaces to the resources in the yamlText if not set.

func SplitString

func SplitString(yamlText string) []string

SplitString splits the given yaml doc if it's multipart document.

func SplitYamlByKind

func SplitYamlByKind(content string) map[string]string

SplitYamlByKind splits the given YAML into parts indexed by kind.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache tracks the life-cycle of Yaml based resources. It stores single-part Yaml files on disk and updates the files as needed, as the resources change.

func (*Cache) AllKeys

func (c *Cache) AllKeys() []CacheKey

AllKeys returns all resource keys in the tracker.

func (*Cache) Apply

func (c *Cache) Apply(yamlText string) ([]CacheKey, error)

Apply adds the given yamlText contents as part of a given context name. If there is an existing context with the given name, then a diffgram will be generated.

func (*Cache) Clear

func (c *Cache) Clear() error

Clear all tracked yaml content.

func (*Cache) Delete

func (c *Cache) Delete(yamlText string) error

Delete the resources from the given yamlText

func (*Cache) GetFileFor

func (c *Cache) GetFileFor(k CacheKey) string

GetFileFor returns the file that keeps the on-disk state for the given key.

type CacheKey

type CacheKey struct {
	// contains filtered or unexported fields
}

CacheKey is a key representing a tracked Yaml based resource.

type Descriptor

type Descriptor struct {
	Kind       string   `json:"kind"`
	Group      string   `json:"group"`
	APIVersion string   `json:"apiVersion"`
	Metadata   Metadata `json:"metadata"`
}

Descriptor a descriptor for a kubernetes resource.

func ParseDescriptor

func ParseDescriptor(yamlText string) (Descriptor, error)

ParseDescriptor parses the given single-part yaml and generates the descriptor.

type FileWriter

type FileWriter interface {
	// WriteYAML writes the given YAML content to one or more YAML files.
	WriteYAML(filenamePrefix string, contents ...string) ([]string, error)

	// WriteYAMLOrFail calls WriteYAML and fails the test if an error occurs.
	WriteYAMLOrFail(t test.Failer, filenamePrefix string, contents ...string) []string
}

FileWriter write YAML content to files.

func NewFileWriter

func NewFileWriter(workDir string) FileWriter

NewFileWriter creates a new FileWriter that stores files under workDir.

type Metadata

type Metadata struct {
	Name      string `json:"name"`
	Namespace string `json:"namespace"`
}

Metadata metadata for a kubernetes resource.

type Part

type Part struct {
	Contents   string
	Descriptor Descriptor
}

Part is a single-part yaml source, along with its descriptor.

func Parse

func Parse(yamlText string) ([]Part, error)

Parse parses the given multi-part yaml text, and returns as Parts.

Jump to

Keyboard shortcuts

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