Documentation
¶
Overview ¶
Package renderer simulates the Datadog Operator's reconciliation loop offline. Given a DatadogAgent (and optional DatadogAgentProfiles), Render returns the complete set of Kubernetes resources the operator would create — without needing a running cluster. Useful for golden-file regression tests and the operator-render CLI.
Index ¶
- Constants
- func BuildScheme() *runtime.Scheme
- func LoadDAPs(paths []string) ([]*datadoghqv1alpha1.DatadogAgentProfile, error)
- func LoadDDA(path string) (*datadoghqv2alpha1.DatadogAgent, error)
- func Render(opts Options) ([]client.Object, *runtime.Scheme, error)
- func Serialize(objects []client.Object, scheme *runtime.Scheme, format string, ...) ([]byte, error)
- func SortResources(objects []client.Object, scheme *runtime.Scheme) []client.Object
- type Options
Constants ¶
const DefaultKubernetesVersion = "v1.28.0"
DefaultKubernetesVersion is the simulated server version used when Options.KubernetesVersion is empty (>= 1.22, matching a modern cluster).
Variables ¶
This section is empty.
Functions ¶
func BuildScheme ¶
BuildScheme returns a runtime.Scheme registered with all the API groups the operator's reconcilers and resource builders need.
func LoadDAPs ¶
func LoadDAPs(paths []string) ([]*datadoghqv1alpha1.DatadogAgentProfile, error)
LoadDAPs reads DatadogAgentProfile YAML manifests from disk.
func LoadDDA ¶
func LoadDDA(path string) (*datadoghqv2alpha1.DatadogAgent, error)
LoadDDA reads a DatadogAgent YAML manifest from disk.
func Render ¶
Render runs the operator reconcilers against the provided DDA and DAPs using a fake client, and returns all Kubernetes resources the operator would create. The returned scheme can be used to restore GVK on the collected objects (for serialization).
func Serialize ¶
func Serialize(objects []client.Object, scheme *runtime.Scheme, format string, keepStatus bool) ([]byte, error)
Serialize converts resources to YAML or JSON with consistent, sorted key ordering. Key ordering is guaranteed because we round-trip through map[string]interface{} first; encoding/json sorts map keys alphabetically, and sigs.k8s.io/yaml converts via JSON. Supported formats: "yaml" (default), "json". When keepStatus is true, the status field is preserved for datadoghq.com resources (DDA, DDAI, DAP) so reconciler-set conditions are visible in the output.
Types ¶
type Options ¶
type Options struct {
// DDA is the input DatadogAgent. Required.
DDA *datadoghqv2alpha1.DatadogAgent
// DAPs are optional DatadogAgentProfiles. They are passed to the
// reconciler regardless of ProfileEnabled, but only take effect when
// ProfileEnabled is true.
DAPs []*datadoghqv1alpha1.DatadogAgentProfile
// ProfileEnabled toggles DatadogAgentProfile reconciliation, mirroring
// the operator's --datadogAgentProfileEnabled flag.
ProfileEnabled bool
// SupportCilium emits CiliumNetworkPolicy resources alongside NetworkPolicy.
SupportCilium bool
// Logger is used for reconciler and controller-runtime output. Zero value
// (logr.Logger{}) silences all logging, equivalent to logr.Discard().
Logger logr.Logger
// IncludeInputStatuses re-fetches the DDA and DAPs from the fake client
// after reconciliation and appends them to the resource list so their
// reconciler-set status fields are visible in the serialized output.
IncludeInputStatuses bool
// KubernetesVersion is the simulated server GitVersion (e.g. "v1.28.0").
// It gates version-dependent resources such as the local agent service
// (k8s >= 1.22). Empty defaults to DefaultKubernetesVersion.
KubernetesVersion string
}
Options configures a Render invocation.