Documentation
¶
Overview ¶
Package manifest provides structured YAML manifest mutation utilities. This package replaces regex-based YAML manipulation with proper structured editing.
Index ¶
- func SimpleManifestRenderer(content string, images map[string]string) string
- type Mutator
- func (m *Mutator) FindDeployment(name, namespace string) map[string]any
- func (m *Mutator) MergeDeploymentArgs(deploymentName, containerName string, newArgs []string) error
- func (m *Mutator) MergeDeploymentEnv(deploymentName, containerName string, envVars map[string]string) error
- func (m *Mutator) MergeDeploymentTemplateAnnotations(deploymentName string, annotations map[string]string) error
- func (m *Mutator) MergeDeploymentVolumeMounts(deploymentName, containerName string, volumeMounts []map[string]any) error
- func (m *Mutator) MergeDeploymentVolumes(deploymentName string, volumes []map[string]any) error
- func (m *Mutator) SetDeploymentArgs(deploymentName, containerName string, args []string) error
- func (m *Mutator) SetDeploymentEnv(deploymentName, containerName string, envVars map[string]string) error
- func (m *Mutator) SetDeploymentImage(deploymentName, containerName, image string) error
- func (m *Mutator) SetDeploymentImagePullPolicy(deploymentName, containerName, pullPolicy string) error
- func (m *Mutator) ToYAML() ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SimpleManifestRenderer ¶
SimpleManifestRenderer performs simple string-based replacements in a manifest. This is a convenience function for basic use cases where structured mutation is not needed. For complex Kubernetes manifest manipulation, use Mutator instead. Note: This uses string replacement and may not handle all YAML edge cases correctly. Deprecated: Use Mutator for structured, safer manifest manipulation.
Types ¶
type Mutator ¶
type Mutator struct {
// contains filtered or unexported fields
}
Mutator provides structured mutation capabilities for Kubernetes manifests.
func NewMutator ¶
NewMutator creates a new manifest mutator from YAML content.
func (*Mutator) FindDeployment ¶
FindDeployment finds a Deployment document by name and optionally namespace. If namespace is empty, it matches any namespace. Returns nil if no matching deployment is found.
func (*Mutator) MergeDeploymentArgs ¶
MergeDeploymentArgs merges command-line arguments with existing ones. If containerName is empty, it merges for the first container. Args with the same key (extracted from the flag name) will be replaced; new args will be appended.
func (*Mutator) MergeDeploymentEnv ¶
func (m *Mutator) MergeDeploymentEnv(deploymentName, containerName string, envVars map[string]string) error
MergeDeploymentEnv merges environment variables with existing ones. If containerName is empty, it merges for the first container.
func (*Mutator) MergeDeploymentTemplateAnnotations ¶
func (m *Mutator) MergeDeploymentTemplateAnnotations(deploymentName string, annotations map[string]string) error
MergeDeploymentTemplateAnnotations merges annotations into a deployment pod template.
func (*Mutator) MergeDeploymentVolumeMounts ¶
func (m *Mutator) MergeDeploymentVolumeMounts(deploymentName, containerName string, volumeMounts []map[string]any) error
MergeDeploymentVolumeMounts merges volume mounts by name into a deployment container.
func (*Mutator) MergeDeploymentVolumes ¶
MergeDeploymentVolumes merges volumes by name into a deployment pod spec.
func (*Mutator) SetDeploymentArgs ¶
SetDeploymentArgs sets the command-line arguments for a specific container. If containerName is empty, it sets for the first container.
func (*Mutator) SetDeploymentEnv ¶
func (m *Mutator) SetDeploymentEnv(deploymentName, containerName string, envVars map[string]string) error
SetDeploymentEnv sets environment variables for a specific container. If containerName is empty, it sets for the first container.
func (*Mutator) SetDeploymentImage ¶
SetDeploymentImage sets the container image for a specific container in a deployment. If containerName is empty, it sets the image for the first container.
func (*Mutator) SetDeploymentImagePullPolicy ¶
func (m *Mutator) SetDeploymentImagePullPolicy(deploymentName, containerName, pullPolicy string) error
SetDeploymentImagePullPolicy sets the image pull policy for a specific container. If containerName is empty, it sets for the first container.