Documentation ¶
Index ¶
Constants ¶
View Source
const ( // All resources are output into a single YAML file. YamlOutputTypeSingleFile yamlOutputType = "single" // Resources are split into seperate files by scope. YamlOutputTypeFilePerScope yamlOutputType = "scope" // Each resource is output to its own file. YamlOutputTypeFilePerResource yamlOutputType = "resource" // Each resource is output to its own file in a folder named after the scope. YamlOutputTypeFolderPerScopeFilePerResource yamlOutputType = "folder" // Resources are split into seperate files by scope, while creating a folder for each scope. YamlOutputTypeFolderPerScopeFilePerLeafScope yamlOutputType = "folder-per-parent" )
inspired by cdk8s (https://cdk8s.io/docs/latest/reference/cdk8s/python/#yamloutputtype)
Variables ¶
This section is empty.
Functions ¶
func GenerateContextKey ¶
func GenerateContextKey() string
GenerateContextKey generates a random string to be used as a context key
Types ¶
type ApiObject ¶
type ApiObject interface { metav1.Type metav1.Object // ToYAML returns the YAML representation of the object. ToYAML() []byte // GetObject returns the underlying Kubernetes object. GetObject() runtime.Object // ReplaceObject replaces the underlying Kubernetes object. ReplaceObject(v runtime.Object) }
ApiObject is an interface that represents a Kubernetes object.
type Builder ¶
type Builder interface { Scope // RenderManifests writes the Kubernetes API objects to disk or stdout in YAML format. RenderManifests(opts RenderManifestsOptions) }
Builder is the main interface for adding Kubernetes API objects and rendering them to YAML files.
func NewBuilder ¶
func NewBuilder(opts BuilderOptions) Builder
NewBuilder creates a new Builder instance.
type BuilderOptions ¶
type BuilderOptions struct { // SchemeBuilder is used to add custom Kubernetes API types to the scheme. SchemeBuilder runtime.SchemeBuilder // Logger is used to log messages. If not set, a default logger is used. Logger Logger }
type CustomLoggerOptions ¶ added in v0.0.2
type CustomLoggerOptions struct { // InfofFn is a custom function that logs an info message. If not provided, log.Printf is used. InfofFn func(msg string, args ...any) // WarnfFn is a custom function that logs a warning message. If not provided, log.Printf is used. WarnfFn func(msg string, args ...any) // PanicfFn is a custom function that logs a panic message and panics. If not provided, log.Panicf is used. PanicfFn func(msg string, args ...any) }
CustomLoggerOptions is a struct that contains the options for a custom logger
type Logger ¶ added in v0.0.2
type Logger interface { // Infof logs an info message Infof(msg string, args ...any) // Warnf logs a warning message Warnf(msg string, args ...any) // Panicf logs a panic message and panics Panicf(msg string, args ...any) }
Logger is an interface for logging
func NewCustomLogger ¶ added in v0.0.2
func NewCustomLogger(props *CustomLoggerOptions) Logger
NewCustomLogger creates a new custom logger.
type RenderManifestsOptions ¶ added in v0.0.2
type RenderManifestsOptions struct { // The directory to write the YAML files to. If set to "-", the YAML files will be written to stdout. Outdir string // The output format for the YAML files. YamlOutputType yamlOutputType // Include a number in the filenames to maintain order. IncludeNumberInFilenames bool // Delete the output directory before writing the YAML files. DeleteOutDir bool // PatchObject is a function that can be used to modify the ApiObjects before they are rendered. PatchObject func(ApiObject) error }
type Scope ¶
type Scope interface { // ID returns the identifier of the scope. ID() string // Namespace returns the namespace of the scope. It searches the current scope and its parents. Namespace() string // CreateScope creates a new scope, nested under the current scope. CreateScope(id string, props ScopeProps) Scope // GetContext returns the value of the given context key. It searches the current scope and its parents. GetContext(key string) any // SetContext sets the value of the given context key. SetContext(key string, value any) // AddApiObject adds a new API object to the scope. AddApiObject(obj runtime.Object) ApiObject // AddApiObjectFromMap adds a new API object to the scope from an arbitrary map. AddApiObjectFromMap(props map[string]any) ApiObject // WalkApiObjects walks through all the API objects in the scope and its children. WalkApiObjects(walkFn func(ApiObject) error) error // Children returns the child scopes of the current scope. Children() iter.Seq[Scope] // Logger returns the logger that was passed to the builder. Logger() Logger }
type ScopeProps ¶
type ScopeProps struct { // Namespace is the default kubernetes namespace that should be used for the k8s resources in the scope. Namespace string }
ScopeProps is the properties for creating a new scope.
Click to show internal directories.
Click to hide internal directories.