kubecfg

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseResource

func ParseResource(data []byte) (*unstructured.Unstructured, error)

ParseResource parses a single resource. This MUST already be broken up from other files using a triple hyphen separator.

Types

type Client

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

Client grants access to locate, read, and process k8s resource/manifest files.

func New

func New(cloudHome string) *Client

New returns a client for reading kubernetes configuration files and processing them.

func (*Client) ReadResourceFile

func (c *Client) ReadResourceFile(rfile string) ([]RawResource, error)

ReadResourceFile reads a resource file and breaks it into parts by the triple hyphen separator. The parts are raw bytes. They may be in need of templating or otherwise incomplete. Empty parts (those consisting entirely of blank lines or comments) will be removed.

func (*Client) SetFunc

func (c *Client) SetFunc(
	name string,
	f any,
)

SetFunc modifies the function map associated with the Client to replace or add another function to it.

func (*Client) SetFuncMap added in v0.1.0

func (c *Client) SetFuncMap(
	funcMap template.FuncMap,
)

SetFuncMap sets the function map associated with the Client to the provided map.

func (*Client) TemplateConfigFile

func (c *Client) TemplateConfigFile(name string, data []byte) (string, error)

TemplateConfigFile takes the given template string and templates the file as a configuration. It returns the output of the templating.

func (*Client) WriteResourceFile

func (c *Client) WriteResourceFile(
	wfile string,
	bs []byte,
) error

WriteResourceFile writes out a resource to a configuration file.

type ProcessedResource

type ProcessedResource struct {
	Data interface{}

	ResourceOptions
}

ProcessedResource represents any parsed typed or unstructured kubernetes resource that can be applied via SSA patch after being converted to unstructured with its ResourceOptions.

type RawResource

type RawResource struct {
	Config []byte // The content of the configuration to apply.

	ResourceOptions
}

RawResource encapsulates a configuration file with its ResourceOptions.

type Resource

type Resource struct {
	Data *unstructured.Unstructured // The templated, parsed, and rewritten resource.

	ResourceOptions
}

Resource represents a parsed and unstructured kubernetes resource that can be applied via SSA patch with its ResourceOptions.

func (*Resource) ProcessedResource

func (r *Resource) ProcessedResource() ProcessedResource

ProcessedResource converts the Resource to a ProcessedResource without making any changes.

type ResourceOptions

type ResourceOptions struct {
	Validate     bool // Set by the ZZZ --validate option.
	NeedsRestart bool // Can be set by rewriters to trigger a rollout restart on a deployment
}

ResourceOptions encapsulates operational options associated with a resource that modify how these libraries work with it.

Jump to

Keyboard shortcuts

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