yaml

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package yaml implements yaml utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractClusterReferences

func ExtractClusterReferences(out *ParseOutput, c *clusterv1.Cluster) (res []*unstructured.Unstructured)

ExtractClusterReferences returns the references in a Cluster object.

func ExtractMachineReferences

func ExtractMachineReferences(out *ParseOutput, m *clusterv1.Machine) (res []*unstructured.Unstructured)

ExtractMachineReferences returns the references in a Machine object.

func FromUnstructured

func FromUnstructured(objs []unstructured.Unstructured) ([]byte, error)

FromUnstructured takes a list of Unstructured objects and converts it into a YAML.

func JoinYaml

func JoinYaml(yamls ...[]byte) []byte

JoinYaml takes a list of YAML files and join them ensuring each YAML that the yaml separator goes on a new line by adding \n where necessary.

func NewYAMLDecoder

func NewYAMLDecoder(r io.ReadCloser) streaming.Decoder

NewYAMLDecoder returns a new streaming Decoded that supports YAML.

func Raw

func Raw(raw string) string

Raw returns un-indented yaml string; it also remove the first empty line, if any. While writing yaml, always use space instead of tabs for indentation.

func ToUnstructured

func ToUnstructured(rawyaml []byte) ([]unstructured.Unstructured, error)

ToUnstructured takes a YAML and converts it to a list of Unstructured objects.

Types

type ParseInput

type ParseInput struct {
	File string
}

ParseInput is an input struct for the Parse function.

type ParseOutput

type ParseOutput struct {
	Clusters            []*clusterv1.Cluster
	Machines            []*clusterv1.Machine
	MachineSets         []*clusterv1.MachineSet
	MachineDeployments  []*clusterv1.MachineDeployment
	UnstructuredObjects []*unstructured.Unstructured
}

ParseOutput is the output given from the Parse function.

func Parse

func Parse(input ParseInput) (*ParseOutput, error)

Parse extracts runtime objects from a file.

func (*ParseOutput) Add

func (p *ParseOutput) Add(o *ParseOutput) *ParseOutput

Add adds the other ParseOutput slices to this instance.

func (*ParseOutput) FindUnstructuredReference

func (p *ParseOutput) FindUnstructuredReference(ref *corev1.ObjectReference) *unstructured.Unstructured

FindUnstructuredReference takes in an ObjectReference and tries to find an Unstructured object.

Jump to

Keyboard shortcuts

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