Documentation
¶
Overview ¶
Package editors provides editors for mutating Kubernetes objects.
Index ¶
- type BindingSubjectsEditor
- func (e *BindingSubjectsEditor) EnsureServiceAccount(name, namespace string)
- func (e *BindingSubjectsEditor) EnsureSubject(subject rbacv1.Subject)
- func (e *BindingSubjectsEditor) Raw() *[]rbacv1.Subject
- func (e *BindingSubjectsEditor) RemoveServiceAccount(name, namespace string)
- func (e *BindingSubjectsEditor) RemoveSubject(kind, name, namespace string)
- type ConfigMapDataEditor
- func (e *ConfigMapDataEditor) MergeYAML(key, yamlPatch string) error
- func (e *ConfigMapDataEditor) Raw() map[string]string
- func (e *ConfigMapDataEditor) RawBinary() map[string][]byte
- func (e *ConfigMapDataEditor) Remove(key string)
- func (e *ConfigMapDataEditor) RemoveBinary(key string)
- func (e *ConfigMapDataEditor) Set(key, value string)
- func (e *ConfigMapDataEditor) SetBinary(key string, value []byte)
- type ContainerEditor
- func (e *ContainerEditor) EnsureArg(arg string)
- func (e *ContainerEditor) EnsureArgs(args []string)
- func (e *ContainerEditor) EnsureEnvVar(ev corev1.EnvVar)
- func (e *ContainerEditor) EnsureEnvVars(vars []corev1.EnvVar)
- func (e *ContainerEditor) Raw() *corev1.Container
- func (e *ContainerEditor) RemoveArg(arg string)
- func (e *ContainerEditor) RemoveArgs(args []string)
- func (e *ContainerEditor) RemoveEnvVar(name string)
- func (e *ContainerEditor) RemoveEnvVars(names []string)
- func (e *ContainerEditor) SetResourceLimit(name corev1.ResourceName, quantity resource.Quantity)
- func (e *ContainerEditor) SetResourceRequest(name corev1.ResourceName, quantity resource.Quantity)
- func (e *ContainerEditor) SetResources(res corev1.ResourceRequirements)
- type CronJobSpecEditor
- func (e *CronJobSpecEditor) Raw() *batchv1.CronJobSpec
- func (e *CronJobSpecEditor) SetConcurrencyPolicy(policy batchv1.ConcurrencyPolicy)
- func (e *CronJobSpecEditor) SetFailedJobsHistoryLimit(n int32)
- func (e *CronJobSpecEditor) SetSchedule(cron string)
- func (e *CronJobSpecEditor) SetStartingDeadlineSeconds(seconds int64)
- func (e *CronJobSpecEditor) SetSuccessfulJobsHistoryLimit(n int32)
- func (e *CronJobSpecEditor) SetTimeZone(tz string)
- type DaemonSetSpecEditor
- type DeploymentSpecEditor
- func (e *DeploymentSpecEditor) Raw() *appsv1.DeploymentSpec
- func (e *DeploymentSpecEditor) SetMinReadySeconds(seconds int32)
- func (e *DeploymentSpecEditor) SetPaused(paused bool)
- func (e *DeploymentSpecEditor) SetProgressDeadlineSeconds(seconds int32)
- func (e *DeploymentSpecEditor) SetReplicas(replicas int32)
- func (e *DeploymentSpecEditor) SetRevisionHistoryLimit(limit int32)
- type HPASpecEditor
- func (e *HPASpecEditor) EnsureMetric(metric autoscalingv2.MetricSpec)
- func (e *HPASpecEditor) Raw() *autoscalingv2.HorizontalPodAutoscalerSpec
- func (e *HPASpecEditor) RemoveMetric(metricType autoscalingv2.MetricSourceType, name string)
- func (e *HPASpecEditor) SetBehavior(behavior *autoscalingv2.HorizontalPodAutoscalerBehavior)
- func (e *HPASpecEditor) SetMaxReplicas(n int32)
- func (e *HPASpecEditor) SetMinReplicas(n *int32)
- func (e *HPASpecEditor) SetScaleTargetRef(ref autoscalingv2.CrossVersionObjectReference)
- type IngressSpecEditor
- func (e *IngressSpecEditor) EnsureRule(rule networkingv1.IngressRule)
- func (e *IngressSpecEditor) EnsureTLS(tls networkingv1.IngressTLS)
- func (e *IngressSpecEditor) Raw() *networkingv1.IngressSpec
- func (e *IngressSpecEditor) RemoveRule(host string)
- func (e *IngressSpecEditor) RemoveTLS(hosts ...string)
- func (e *IngressSpecEditor) SetDefaultBackend(backend *networkingv1.IngressBackend)
- func (e *IngressSpecEditor) SetIngressClassName(name string)
- type JobSpecEditor
- func (e *JobSpecEditor) Raw() *batchv1.JobSpec
- func (e *JobSpecEditor) SetActiveDeadlineSeconds(seconds int64)
- func (e *JobSpecEditor) SetBackoffLimit(n int32)
- func (e *JobSpecEditor) SetCompletionMode(mode batchv1.CompletionMode)
- func (e *JobSpecEditor) SetCompletions(n int32)
- func (e *JobSpecEditor) SetParallelism(n int32)
- func (e *JobSpecEditor) SetTTLSecondsAfterFinished(seconds int32)
- type NetworkPolicySpecEditor
- func (e *NetworkPolicySpecEditor) AppendEgressRule(rule networkingv1.NetworkPolicyEgressRule)
- func (e *NetworkPolicySpecEditor) AppendIngressRule(rule networkingv1.NetworkPolicyIngressRule)
- func (e *NetworkPolicySpecEditor) Raw() *networkingv1.NetworkPolicySpec
- func (e *NetworkPolicySpecEditor) RemoveEgressRules()
- func (e *NetworkPolicySpecEditor) RemoveIngressRules()
- func (e *NetworkPolicySpecEditor) SetPodSelector(selector metav1.LabelSelector)
- func (e *NetworkPolicySpecEditor) SetPolicyTypes(types []networkingv1.PolicyType)
- type ObjectMetaEditor
- type ObjectMutator
- type PVCSpecEditor
- func (e *PVCSpecEditor) Raw() *corev1.PersistentVolumeClaimSpec
- func (e *PVCSpecEditor) SetAccessModes(modes []corev1.PersistentVolumeAccessMode)
- func (e *PVCSpecEditor) SetStorageClassName(name string)
- func (e *PVCSpecEditor) SetStorageRequest(quantity resource.Quantity)
- func (e *PVCSpecEditor) SetVolumeMode(mode corev1.PersistentVolumeMode)
- func (e *PVCSpecEditor) SetVolumeName(name string)
- type PVSpecEditor
- func (e *PVSpecEditor) Raw() *corev1.PersistentVolumeSpec
- func (e *PVSpecEditor) SetAccessModes(modes []corev1.PersistentVolumeAccessMode)
- func (e *PVSpecEditor) SetCapacity(storage resource.Quantity)
- func (e *PVSpecEditor) SetMountOptions(options []string)
- func (e *PVSpecEditor) SetNodeAffinity(affinity *corev1.VolumeNodeAffinity)
- func (e *PVSpecEditor) SetPersistentVolumeReclaimPolicy(policy corev1.PersistentVolumeReclaimPolicy)
- func (e *PVSpecEditor) SetStorageClassName(name string)
- func (e *PVSpecEditor) SetVolumeMode(mode corev1.PersistentVolumeMode)
- type PodDisruptionBudgetSpecEditor
- func (e *PodDisruptionBudgetSpecEditor) ClearMaxUnavailable()
- func (e *PodDisruptionBudgetSpecEditor) ClearMinAvailable()
- func (e *PodDisruptionBudgetSpecEditor) ClearUnhealthyPodEvictionPolicy()
- func (e *PodDisruptionBudgetSpecEditor) Raw() *policyv1.PodDisruptionBudgetSpec
- func (e *PodDisruptionBudgetSpecEditor) SetMaxUnavailable(val intstr.IntOrString)
- func (e *PodDisruptionBudgetSpecEditor) SetMinAvailable(val intstr.IntOrString)
- func (e *PodDisruptionBudgetSpecEditor) SetSelector(selector *metav1.LabelSelector)
- func (e *PodDisruptionBudgetSpecEditor) SetUnhealthyPodEvictionPolicy(policy policyv1.UnhealthyPodEvictionPolicyType)
- type PodSpecEditor
- func (e *PodSpecEditor) EnsureImagePullSecret(name string)
- func (e *PodSpecEditor) EnsureNodeSelector(key, value string)
- func (e *PodSpecEditor) EnsureToleration(t corev1.Toleration)
- func (e *PodSpecEditor) EnsureVolume(v corev1.Volume)
- func (e *PodSpecEditor) Raw() *corev1.PodSpec
- func (e *PodSpecEditor) RemoveImagePullSecret(name string)
- func (e *PodSpecEditor) RemoveNodeSelector(key string)
- func (e *PodSpecEditor) RemoveTolerations(match func(corev1.Toleration) bool)
- func (e *PodSpecEditor) RemoveVolume(name string)
- func (e *PodSpecEditor) SetHostIPC(enabled bool)
- func (e *PodSpecEditor) SetHostNetwork(enabled bool)
- func (e *PodSpecEditor) SetHostPID(enabled bool)
- func (e *PodSpecEditor) SetPriorityClassName(name string)
- func (e *PodSpecEditor) SetSecurityContext(ctx *corev1.PodSecurityContext)
- func (e *PodSpecEditor) SetServiceAccountName(name string)
- type PolicyRulesEditor
- type RawEditor
- type ReplicaSetSpecEditor
- type SecretDataEditor
- func (e *SecretDataEditor) Raw() map[string][]byte
- func (e *SecretDataEditor) RawStringData() map[string]string
- func (e *SecretDataEditor) Remove(key string)
- func (e *SecretDataEditor) RemoveString(key string)
- func (e *SecretDataEditor) Set(key string, value []byte)
- func (e *SecretDataEditor) SetString(key, value string)
- type ServiceSpecEditor
- func (e *ServiceSpecEditor) EnsurePort(port corev1.ServicePort)
- func (e *ServiceSpecEditor) EnsureSelector(key, value string)
- func (e *ServiceSpecEditor) Raw() *corev1.ServiceSpec
- func (e *ServiceSpecEditor) RemovePort(name string)
- func (e *ServiceSpecEditor) RemoveSelector(key string)
- func (e *ServiceSpecEditor) SetExternalName(name string)
- func (e *ServiceSpecEditor) SetExternalTrafficPolicy(policy corev1.ServiceExternalTrafficPolicy)
- func (e *ServiceSpecEditor) SetInternalTrafficPolicy(policy *corev1.ServiceInternalTrafficPolicy)
- func (e *ServiceSpecEditor) SetLoadBalancerSourceRanges(ranges []string)
- func (e *ServiceSpecEditor) SetPublishNotReadyAddresses(v bool)
- func (e *ServiceSpecEditor) SetSelector(selector map[string]string)
- func (e *ServiceSpecEditor) SetSessionAffinity(affinity corev1.ServiceAffinity)
- func (e *ServiceSpecEditor) SetSessionAffinityConfig(cfg *corev1.SessionAffinityConfig)
- func (e *ServiceSpecEditor) SetType(t corev1.ServiceType)
- type StatefulSetSpecEditor
- func (e *StatefulSetSpecEditor) Raw() *appsv1.StatefulSetSpec
- func (e *StatefulSetSpecEditor) SetMinReadySeconds(seconds int32)
- func (e *StatefulSetSpecEditor) SetPersistentVolumeClaimRetentionPolicy(policy *appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy)
- func (e *StatefulSetSpecEditor) SetPodManagementPolicy(policy appsv1.PodManagementPolicyType)
- func (e *StatefulSetSpecEditor) SetReplicas(replicas int32)
- func (e *StatefulSetSpecEditor) SetRevisionHistoryLimit(limit int32)
- func (e *StatefulSetSpecEditor) SetServiceName(name string)
- func (e *StatefulSetSpecEditor) SetUpdateStrategy(strategy appsv1.StatefulSetUpdateStrategy)
- type UnstructuredContentEditor
- func (e *UnstructuredContentEditor) EnsureNestedStringMapEntry(key, value string, fields ...string) error
- func (e *UnstructuredContentEditor) Raw() map[string]interface{}
- func (e *UnstructuredContentEditor) RemoveNestedField(fields ...string)
- func (e *UnstructuredContentEditor) RemoveNestedStringMapEntry(key string, fields ...string) error
- func (e *UnstructuredContentEditor) SetNestedBool(value bool, fields ...string) error
- func (e *UnstructuredContentEditor) SetNestedField(value interface{}, fields ...string) error
- func (e *UnstructuredContentEditor) SetNestedFloat64(value float64, fields ...string) error
- func (e *UnstructuredContentEditor) SetNestedInt64(value int64, fields ...string) error
- func (e *UnstructuredContentEditor) SetNestedMap(value map[string]interface{}, fields ...string) error
- func (e *UnstructuredContentEditor) SetNestedSlice(value []interface{}, fields ...string) error
- func (e *UnstructuredContentEditor) SetNestedString(value string, fields ...string) error
- func (e *UnstructuredContentEditor) SetNestedStringMap(value map[string]string, fields ...string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BindingSubjectsEditor ¶
type BindingSubjectsEditor struct {
// contains filtered or unexported fields
}
BindingSubjectsEditor provides a typed API for mutating the subjects list of a Kubernetes RoleBinding or ClusterRoleBinding.
It exposes structured operations (EnsureSubject, RemoveSubject) as well as Raw() for free-form access when none of the structured methods are sufficient.
func NewBindingSubjectsEditor ¶
func NewBindingSubjectsEditor(subjects *[]rbacv1.Subject) *BindingSubjectsEditor
NewBindingSubjectsEditor creates a new BindingSubjectsEditor wrapping the given subjects slice pointer.
The pointer may refer to a nil slice; methods that add subjects initialise it automatically. If a nil pointer is provided, an empty slice is allocated and used internally.
func (*BindingSubjectsEditor) EnsureServiceAccount ¶
func (e *BindingSubjectsEditor) EnsureServiceAccount(name, namespace string)
EnsureServiceAccount ensures a ServiceAccount subject with the given name and namespace exists in the binding's subjects list. If an identical subject already exists, this is a no-op.
func (*BindingSubjectsEditor) EnsureSubject ¶
func (e *BindingSubjectsEditor) EnsureSubject(subject rbacv1.Subject)
EnsureSubject upserts a subject in the subjects list.
A subject is identified by the combination of Kind, Name, and Namespace. If a matching subject already exists it is replaced; otherwise the new subject is appended.
func (*BindingSubjectsEditor) Raw ¶
func (e *BindingSubjectsEditor) Raw() *[]rbacv1.Subject
Raw returns a pointer to the underlying subjects slice, allowing free-form modifications when the structured methods are insufficient.
func (*BindingSubjectsEditor) RemoveServiceAccount ¶
func (e *BindingSubjectsEditor) RemoveServiceAccount(name, namespace string)
RemoveServiceAccount removes a ServiceAccount subject with the given name and namespace from the binding's subjects list.
func (*BindingSubjectsEditor) RemoveSubject ¶
func (e *BindingSubjectsEditor) RemoveSubject(kind, name, namespace string)
RemoveSubject removes a subject identified by kind, name, and namespace from the subjects list. It is a no-op if no matching subject exists.
type ConfigMapDataEditor ¶
type ConfigMapDataEditor struct {
// contains filtered or unexported fields
}
ConfigMapDataEditor provides a typed API for mutating the .data and .binaryData fields of a Kubernetes ConfigMap.
It exposes structured operations (Set, Remove, MergeYAML, SetBinary, RemoveBinary) as well as Raw() and RawBinary() for free-form access when none of the structured methods are sufficient.
func NewConfigMapDataEditor ¶
func NewConfigMapDataEditor(data *map[string]string, binaryData *map[string][]byte) *ConfigMapDataEditor
NewConfigMapDataEditor creates a new ConfigMapDataEditor wrapping the given .data and .binaryData map pointers.
Either pointer may be nil, in which case the editor allocates a local zero-value map for that field. Operations on that field will succeed but writes will not propagate back to any external map. Pass non-nil pointers (e.g. &cm.Data, &cm.BinaryData) when the changes must be reflected on the object. The maps the pointers refer to may themselves be nil; methods that write to a map initialise it automatically.
func (*ConfigMapDataEditor) MergeYAML ¶
func (e *ConfigMapDataEditor) MergeYAML(key, yamlPatch string) error
MergeYAML deep-merges yamlPatch into the existing value stored at key in .data.
Merge semantics:
- If both the current value and the patch are YAML mappings, their keys are merged recursively: keys only in the current value are preserved, keys only in the patch are added, and keys present in both are resolved by applying MergeYAML recursively.
- For all other types (scalars, sequences, mixed) the patch value wins.
If the key does not yet exist the patch is written as-is. Returns an error if either the existing value or the patch is invalid YAML.
func (*ConfigMapDataEditor) Raw ¶
func (e *ConfigMapDataEditor) Raw() map[string]string
Raw returns the underlying .data map directly, initialising it if necessary.
This is an escape hatch for free-form editing when none of the structured methods are sufficient.
func (*ConfigMapDataEditor) RawBinary ¶
func (e *ConfigMapDataEditor) RawBinary() map[string][]byte
RawBinary returns the underlying .binaryData map directly, initialising it if necessary.
This is an escape hatch for free-form editing.
func (*ConfigMapDataEditor) Remove ¶
func (e *ConfigMapDataEditor) Remove(key string)
Remove deletes key from .data. It is a no-op if the key does not exist.
func (*ConfigMapDataEditor) RemoveBinary ¶
func (e *ConfigMapDataEditor) RemoveBinary(key string)
RemoveBinary deletes key from .binaryData. It is a no-op if the key does not exist.
func (*ConfigMapDataEditor) Set ¶
func (e *ConfigMapDataEditor) Set(key, value string)
Set sets key to value in .data, initialising the map if necessary.
func (*ConfigMapDataEditor) SetBinary ¶
func (e *ConfigMapDataEditor) SetBinary(key string, value []byte)
SetBinary sets key to value in .binaryData, initialising the map if necessary.
type ContainerEditor ¶
type ContainerEditor struct {
// contains filtered or unexported fields
}
ContainerEditor provides a typed API for mutating a Kubernetes Container.
func NewContainerEditor ¶
func NewContainerEditor(container *corev1.Container) *ContainerEditor
NewContainerEditor creates a new ContainerEditor for the given container.
func (*ContainerEditor) EnsureArg ¶
func (e *ContainerEditor) EnsureArg(arg string)
EnsureArg ensures the specified argument exists in the container's args list. If the argument is already present, it is not added again.
func (*ContainerEditor) EnsureArgs ¶
func (e *ContainerEditor) EnsureArgs(args []string)
EnsureArgs ensures multiple arguments exist in the container's args list.
func (*ContainerEditor) EnsureEnvVar ¶
func (e *ContainerEditor) EnsureEnvVar(ev corev1.EnvVar)
EnsureEnvVar ensures an environment variable exists in the container.
Behavior:
- If an environment variable with the same name exists, it is replaced with the provided EnvVar.
- If it does not exist, the new EnvVar is appended.
func (*ContainerEditor) EnsureEnvVars ¶
func (e *ContainerEditor) EnsureEnvVars(vars []corev1.EnvVar)
EnsureEnvVars ensures multiple environment variables exist in the container.
func (*ContainerEditor) Raw ¶
func (e *ContainerEditor) Raw() *corev1.Container
Raw returns the underlying *corev1.Container.
func (*ContainerEditor) RemoveArg ¶
func (e *ContainerEditor) RemoveArg(arg string)
RemoveArg removes all occurrences of the specified argument from the container's args list.
func (*ContainerEditor) RemoveArgs ¶
func (e *ContainerEditor) RemoveArgs(args []string)
RemoveArgs removes all occurrences of the specified arguments from the container's args list.
func (*ContainerEditor) RemoveEnvVar ¶
func (e *ContainerEditor) RemoveEnvVar(name string)
RemoveEnvVar removes all environment variables with the specified name.
func (*ContainerEditor) RemoveEnvVars ¶
func (e *ContainerEditor) RemoveEnvVars(names []string)
RemoveEnvVars removes all environment variables with any of the specified names.
func (*ContainerEditor) SetResourceLimit ¶
func (e *ContainerEditor) SetResourceLimit(name corev1.ResourceName, quantity resource.Quantity)
SetResourceLimit sets the resource limit for the container.
func (*ContainerEditor) SetResourceRequest ¶
func (e *ContainerEditor) SetResourceRequest(name corev1.ResourceName, quantity resource.Quantity)
SetResourceRequest sets the resource request for the container.
func (*ContainerEditor) SetResources ¶
func (e *ContainerEditor) SetResources(res corev1.ResourceRequirements)
SetResources sets the resource requirements for the container.
type CronJobSpecEditor ¶
type CronJobSpecEditor struct {
// contains filtered or unexported fields
}
CronJobSpecEditor provides a typed API for mutating a Kubernetes CronJobSpec.
Note: spec.suspend is NOT exposed here — it is managed by the framework's suspension system via DefaultSuspendMutationHandler.
func NewCronJobSpecEditor ¶
func NewCronJobSpecEditor(spec *batchv1.CronJobSpec) *CronJobSpecEditor
NewCronJobSpecEditor creates a new CronJobSpecEditor for the given CronJobSpec.
func (*CronJobSpecEditor) Raw ¶
func (e *CronJobSpecEditor) Raw() *batchv1.CronJobSpec
Raw returns the underlying *batchv1.CronJobSpec.
This is an escape hatch for cases where the typed API is insufficient.
func (*CronJobSpecEditor) SetConcurrencyPolicy ¶
func (e *CronJobSpecEditor) SetConcurrencyPolicy(policy batchv1.ConcurrencyPolicy)
SetConcurrencyPolicy sets the concurrency policy for the CronJob.
func (*CronJobSpecEditor) SetFailedJobsHistoryLimit ¶
func (e *CronJobSpecEditor) SetFailedJobsHistoryLimit(n int32)
SetFailedJobsHistoryLimit sets the number of failed finished jobs to retain.
func (*CronJobSpecEditor) SetSchedule ¶
func (e *CronJobSpecEditor) SetSchedule(cron string)
SetSchedule sets the cron schedule expression.
func (*CronJobSpecEditor) SetStartingDeadlineSeconds ¶
func (e *CronJobSpecEditor) SetStartingDeadlineSeconds(seconds int64)
SetStartingDeadlineSeconds sets the optional deadline in seconds for starting the job if it misses its scheduled time.
func (*CronJobSpecEditor) SetSuccessfulJobsHistoryLimit ¶
func (e *CronJobSpecEditor) SetSuccessfulJobsHistoryLimit(n int32)
SetSuccessfulJobsHistoryLimit sets the number of successful finished jobs to retain.
func (*CronJobSpecEditor) SetTimeZone ¶
func (e *CronJobSpecEditor) SetTimeZone(tz string)
SetTimeZone sets the time zone for the cron schedule.
type DaemonSetSpecEditor ¶
type DaemonSetSpecEditor struct {
// contains filtered or unexported fields
}
DaemonSetSpecEditor provides a typed API for mutating a Kubernetes DaemonSetSpec.
func NewDaemonSetSpecEditor ¶
func NewDaemonSetSpecEditor(spec *appsv1.DaemonSetSpec) *DaemonSetSpecEditor
NewDaemonSetSpecEditor creates a new DaemonSetSpecEditor for the given DaemonSetSpec.
func (*DaemonSetSpecEditor) Raw ¶
func (e *DaemonSetSpecEditor) Raw() *appsv1.DaemonSetSpec
Raw returns the underlying *appsv1.DaemonSetSpec.
This is an escape hatch for cases where the typed API is insufficient.
func (*DaemonSetSpecEditor) SetMinReadySeconds ¶
func (e *DaemonSetSpecEditor) SetMinReadySeconds(seconds int32)
SetMinReadySeconds sets the minimum number of seconds for which a newly created pod should be ready without any of its containers crashing, for it to be considered available.
func (*DaemonSetSpecEditor) SetRevisionHistoryLimit ¶
func (e *DaemonSetSpecEditor) SetRevisionHistoryLimit(limit int32)
SetRevisionHistoryLimit sets the number of old DaemonSet revisions to retain to allow rollback.
func (*DaemonSetSpecEditor) SetUpdateStrategy ¶
func (e *DaemonSetSpecEditor) SetUpdateStrategy(strategy appsv1.DaemonSetUpdateStrategy)
SetUpdateStrategy sets the update strategy for the DaemonSet.
type DeploymentSpecEditor ¶
type DeploymentSpecEditor struct {
// contains filtered or unexported fields
}
DeploymentSpecEditor provides a typed API for mutating a Kubernetes DeploymentSpec.
func NewDeploymentSpecEditor ¶
func NewDeploymentSpecEditor(spec *appsv1.DeploymentSpec) *DeploymentSpecEditor
NewDeploymentSpecEditor creates a new DeploymentSpecEditor for the given DeploymentSpec.
func (*DeploymentSpecEditor) Raw ¶
func (e *DeploymentSpecEditor) Raw() *appsv1.DeploymentSpec
Raw returns the underlying *appsv1.DeploymentSpec.
This is an escape hatch for cases where the typed API is insufficient.
func (*DeploymentSpecEditor) SetMinReadySeconds ¶
func (e *DeploymentSpecEditor) SetMinReadySeconds(seconds int32)
SetMinReadySeconds sets the minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available.
func (*DeploymentSpecEditor) SetPaused ¶
func (e *DeploymentSpecEditor) SetPaused(paused bool)
SetPaused sets the paused field of the deployment.
func (*DeploymentSpecEditor) SetProgressDeadlineSeconds ¶
func (e *DeploymentSpecEditor) SetProgressDeadlineSeconds(seconds int32)
SetProgressDeadlineSeconds sets the maximum time in seconds for a deployment to make progress before it is considered to be failed.
func (*DeploymentSpecEditor) SetReplicas ¶
func (e *DeploymentSpecEditor) SetReplicas(replicas int32)
SetReplicas sets the number of replicas for the deployment.
func (*DeploymentSpecEditor) SetRevisionHistoryLimit ¶
func (e *DeploymentSpecEditor) SetRevisionHistoryLimit(limit int32)
SetRevisionHistoryLimit sets the number of old ReplicaSets to retain to allow rollback.
type HPASpecEditor ¶
type HPASpecEditor struct {
// contains filtered or unexported fields
}
HPASpecEditor provides a typed API for mutating a Kubernetes HorizontalPodAutoscalerSpec.
func NewHPASpecEditor ¶
func NewHPASpecEditor(spec *autoscalingv2.HorizontalPodAutoscalerSpec) *HPASpecEditor
NewHPASpecEditor creates a new HPASpecEditor for the given HorizontalPodAutoscalerSpec.
func (*HPASpecEditor) EnsureMetric ¶
func (e *HPASpecEditor) EnsureMetric(metric autoscalingv2.MetricSpec)
EnsureMetric upserts a metric in the spec's Metrics slice.
Matching is performed by MetricSpec.Type. Within that type, matching is refined by the full identity of the metric source:
- Resource: matched by Resource.Name
- Pods: matched by Pods.Metric (Name + Selector)
- Object: matched by Object.DescribedObject + Object.Metric (Name + Selector)
- ContainerResource: matched by ContainerResource.Name + ContainerResource.Container
- External: matched by External.Metric (Name + Selector)
If a matching entry exists it is replaced; otherwise the metric is appended.
func (*HPASpecEditor) Raw ¶
func (e *HPASpecEditor) Raw() *autoscalingv2.HorizontalPodAutoscalerSpec
Raw returns the underlying *autoscalingv2.HorizontalPodAutoscalerSpec.
This is an escape hatch for cases where the typed API is insufficient.
func (*HPASpecEditor) RemoveMetric ¶
func (e *HPASpecEditor) RemoveMetric(metricType autoscalingv2.MetricSourceType, name string)
RemoveMetric removes all metrics matching the given type and name.
For Resource metrics, name corresponds to the resource name (e.g. "cpu"). For Pods, Object, and External metrics, name corresponds to the metric name. For ContainerResource metrics, name corresponds to the resource name; all container variants of that resource are removed.
This method removes every metric entry that matches the type and name, regardless of selector or described object. For fine-grained removal of a single metric identity, use HPASpecEditor.Raw and modify the Metrics slice directly.
If no matching metric is found, this is a no-op.
func (*HPASpecEditor) SetBehavior ¶
func (e *HPASpecEditor) SetBehavior(behavior *autoscalingv2.HorizontalPodAutoscalerBehavior)
SetBehavior sets the autoscaling behavior configuration. Passing nil removes custom behavior (Kubernetes uses defaults).
func (*HPASpecEditor) SetMaxReplicas ¶
func (e *HPASpecEditor) SetMaxReplicas(n int32)
SetMaxReplicas sets the upper bound for the number of replicas.
func (*HPASpecEditor) SetMinReplicas ¶
func (e *HPASpecEditor) SetMinReplicas(n *int32)
SetMinReplicas sets the lower bound for the number of replicas. Passing nil removes the lower bound (Kubernetes defaults to 1).
func (*HPASpecEditor) SetScaleTargetRef ¶
func (e *HPASpecEditor) SetScaleTargetRef(ref autoscalingv2.CrossVersionObjectReference)
SetScaleTargetRef sets the reference to the resource being scaled.
type IngressSpecEditor ¶
type IngressSpecEditor struct {
// contains filtered or unexported fields
}
IngressSpecEditor provides a typed API for mutating a Kubernetes IngressSpec.
func NewIngressSpecEditor ¶
func NewIngressSpecEditor(spec *networkingv1.IngressSpec) *IngressSpecEditor
NewIngressSpecEditor creates a new IngressSpecEditor for the given IngressSpec.
func (*IngressSpecEditor) EnsureRule ¶
func (e *IngressSpecEditor) EnsureRule(rule networkingv1.IngressRule)
EnsureRule upserts a rule by Host. If a rule with the same Host already exists, it is replaced. Otherwise the rule is appended.
func (*IngressSpecEditor) EnsureTLS ¶
func (e *IngressSpecEditor) EnsureTLS(tls networkingv1.IngressTLS)
EnsureTLS upserts a TLS entry by the first host in the Hosts slice. If a TLS entry with the same first host already exists, it is replaced. Otherwise the entry is appended.
func (*IngressSpecEditor) Raw ¶
func (e *IngressSpecEditor) Raw() *networkingv1.IngressSpec
Raw returns the underlying *networkingv1.IngressSpec.
This is an escape hatch for cases where the typed API is insufficient.
func (*IngressSpecEditor) RemoveRule ¶
func (e *IngressSpecEditor) RemoveRule(host string)
RemoveRule removes the rule with the given host. It is a no-op if no rule with that host exists.
func (*IngressSpecEditor) RemoveTLS ¶
func (e *IngressSpecEditor) RemoveTLS(hosts ...string)
RemoveTLS removes TLS entries whose first host matches any of the provided hosts. It is a no-op for hosts that do not match any existing TLS entry.
func (*IngressSpecEditor) SetDefaultBackend ¶
func (e *IngressSpecEditor) SetDefaultBackend(backend *networkingv1.IngressBackend)
SetDefaultBackend sets the default backend for the Ingress.
func (*IngressSpecEditor) SetIngressClassName ¶
func (e *IngressSpecEditor) SetIngressClassName(name string)
SetIngressClassName sets the IngressClassName field of the IngressSpec.
type JobSpecEditor ¶
type JobSpecEditor struct {
// contains filtered or unexported fields
}
JobSpecEditor provides a typed API for mutating a Kubernetes JobSpec.
func NewJobSpecEditor ¶
func NewJobSpecEditor(spec *batchv1.JobSpec) *JobSpecEditor
NewJobSpecEditor creates a new JobSpecEditor for the given JobSpec.
func (*JobSpecEditor) Raw ¶
func (e *JobSpecEditor) Raw() *batchv1.JobSpec
Raw returns the underlying *batchv1.JobSpec.
This is an escape hatch for cases where the typed API is insufficient.
func (*JobSpecEditor) SetActiveDeadlineSeconds ¶
func (e *JobSpecEditor) SetActiveDeadlineSeconds(seconds int64)
SetActiveDeadlineSeconds sets the duration in seconds relative to the start time that the job may be active before it is terminated.
func (*JobSpecEditor) SetBackoffLimit ¶
func (e *JobSpecEditor) SetBackoffLimit(n int32)
SetBackoffLimit sets the number of retries before marking the job as failed.
func (*JobSpecEditor) SetCompletionMode ¶
func (e *JobSpecEditor) SetCompletionMode(mode batchv1.CompletionMode)
SetCompletionMode sets the completion mode of the job.
func (*JobSpecEditor) SetCompletions ¶
func (e *JobSpecEditor) SetCompletions(n int32)
SetCompletions sets the desired number of successfully finished pods.
func (*JobSpecEditor) SetParallelism ¶
func (e *JobSpecEditor) SetParallelism(n int32)
SetParallelism sets the maximum desired number of pods running at any given time.
func (*JobSpecEditor) SetTTLSecondsAfterFinished ¶
func (e *JobSpecEditor) SetTTLSecondsAfterFinished(seconds int32)
SetTTLSecondsAfterFinished sets the TTL for cleaning up finished jobs.
type NetworkPolicySpecEditor ¶
type NetworkPolicySpecEditor struct {
// contains filtered or unexported fields
}
NetworkPolicySpecEditor provides a typed API for mutating a Kubernetes NetworkPolicySpec.
It exposes structured operations for managing the pod selector, ingress rules, egress rules, and policy types, as well as Raw() for free-form access when none of the structured methods are sufficient.
Note: ingress and egress rules have no unique key. AppendIngressRule and AppendEgressRule append unconditionally. Use RemoveIngressRules or RemoveEgressRules to replace the full set atomically, or use Raw() for fine-grained manipulation.
func NewNetworkPolicySpecEditor ¶
func NewNetworkPolicySpecEditor(spec *networkingv1.NetworkPolicySpec) *NetworkPolicySpecEditor
NewNetworkPolicySpecEditor creates a new NetworkPolicySpecEditor wrapping the given NetworkPolicySpec pointer.
func (*NetworkPolicySpecEditor) AppendEgressRule ¶
func (e *NetworkPolicySpecEditor) AppendEgressRule(rule networkingv1.NetworkPolicyEgressRule)
AppendEgressRule appends an egress rule to the NetworkPolicy.
Rules have no unique key, so this method always appends. To replace the full set of egress rules atomically, call RemoveEgressRules first and then add the desired rules, or use Raw() for fine-grained manipulation.
func (*NetworkPolicySpecEditor) AppendIngressRule ¶
func (e *NetworkPolicySpecEditor) AppendIngressRule(rule networkingv1.NetworkPolicyIngressRule)
AppendIngressRule appends an ingress rule to the NetworkPolicy.
Rules have no unique key, so this method always appends. To replace the full set of ingress rules atomically, call RemoveIngressRules first and then add the desired rules, or use Raw() for fine-grained manipulation.
func (*NetworkPolicySpecEditor) Raw ¶
func (e *NetworkPolicySpecEditor) Raw() *networkingv1.NetworkPolicySpec
Raw returns the underlying *networkingv1.NetworkPolicySpec.
func (*NetworkPolicySpecEditor) RemoveEgressRules ¶
func (e *NetworkPolicySpecEditor) RemoveEgressRules()
RemoveEgressRules clears all egress rules from the NetworkPolicy.
Use this before calling AppendEgressRule to replace the full set atomically.
func (*NetworkPolicySpecEditor) RemoveIngressRules ¶
func (e *NetworkPolicySpecEditor) RemoveIngressRules()
RemoveIngressRules clears all ingress rules from the NetworkPolicy.
Use this before calling AppendIngressRule to replace the full set atomically.
func (*NetworkPolicySpecEditor) SetPodSelector ¶
func (e *NetworkPolicySpecEditor) SetPodSelector(selector metav1.LabelSelector)
SetPodSelector sets the pod selector for the NetworkPolicy.
The selector determines which pods this policy applies to within the namespace. An empty LabelSelector matches all pods in the namespace.
func (*NetworkPolicySpecEditor) SetPolicyTypes ¶
func (e *NetworkPolicySpecEditor) SetPolicyTypes(types []networkingv1.PolicyType)
SetPolicyTypes sets the policy types for the NetworkPolicy.
Valid values are networkingv1.PolicyTypeIngress and networkingv1.PolicyTypeEgress. When networkingv1.PolicyTypeEgress is included in PolicyTypes, the .Egress field (egress rules) must be set explicitly to permit traffic; an empty list denies all egress.
type ObjectMetaEditor ¶
type ObjectMetaEditor struct {
// contains filtered or unexported fields
}
ObjectMetaEditor provides a typed API for mutating Kubernetes ObjectMeta.
func NewObjectMetaEditor ¶
func NewObjectMetaEditor(meta *metav1.ObjectMeta) *ObjectMetaEditor
NewObjectMetaEditor creates a new ObjectMetaEditor for the given ObjectMeta.
func (*ObjectMetaEditor) EnsureAnnotation ¶
func (e *ObjectMetaEditor) EnsureAnnotation(key, value string)
EnsureAnnotation ensures an annotation with the given key and value exists.
func (*ObjectMetaEditor) EnsureLabel ¶
func (e *ObjectMetaEditor) EnsureLabel(key, value string)
EnsureLabel ensures a label with the given key and value exists.
func (*ObjectMetaEditor) Raw ¶
func (e *ObjectMetaEditor) Raw() *metav1.ObjectMeta
Raw returns the underlying *metav1.ObjectMeta.
func (*ObjectMetaEditor) RemoveAnnotation ¶
func (e *ObjectMetaEditor) RemoveAnnotation(key string)
RemoveAnnotation removes an annotation with the given key.
func (*ObjectMetaEditor) RemoveLabel ¶
func (e *ObjectMetaEditor) RemoveLabel(key string)
RemoveLabel removes a label with the given key.
type ObjectMutator ¶
type ObjectMutator interface {
EditObjectMetadata(edit func(*ObjectMetaEditor) error)
}
ObjectMutator is implemented by all primitive mutators.
It guarantees that the Kubernetes object's own metadata is always mutable through a consistent API, regardless of which primitive type is being used.
type PVCSpecEditor ¶
type PVCSpecEditor struct {
// contains filtered or unexported fields
}
PVCSpecEditor provides a typed API for mutating a Kubernetes PersistentVolumeClaimSpec.
func NewPVCSpecEditor ¶
func NewPVCSpecEditor(spec *corev1.PersistentVolumeClaimSpec) *PVCSpecEditor
NewPVCSpecEditor creates a new PVCSpecEditor for the given PersistentVolumeClaimSpec.
func (*PVCSpecEditor) Raw ¶
func (e *PVCSpecEditor) Raw() *corev1.PersistentVolumeClaimSpec
Raw returns the underlying *corev1.PersistentVolumeClaimSpec.
This is an escape hatch for cases where the typed API is insufficient.
func (*PVCSpecEditor) SetAccessModes ¶
func (e *PVCSpecEditor) SetAccessModes(modes []corev1.PersistentVolumeAccessMode)
SetAccessModes sets the access modes for the PVC.
Access modes are immutable on existing PVCs. This method should be used for initial construction, or when reapplying the same value via Server-Side Apply. Attempting to change this field on an existing PVC will be rejected by the Kubernetes API server.
func (*PVCSpecEditor) SetStorageClassName ¶
func (e *PVCSpecEditor) SetStorageClassName(name string)
SetStorageClassName sets the storage class name for the PVC.
The storage class name is immutable on existing PVCs. This method should be used for initial construction, or when reapplying the same value via Server-Side Apply. Attempting to change this field on an existing PVC will be rejected by the Kubernetes API server.
func (*PVCSpecEditor) SetStorageRequest ¶
func (e *PVCSpecEditor) SetStorageRequest(quantity resource.Quantity)
SetStorageRequest sets the storage resource request for the PVC.
On existing PVCs, Kubernetes only allows storage expansion (not shrinking), provided the StorageClass supports volume expansion.
func (*PVCSpecEditor) SetVolumeMode ¶
func (e *PVCSpecEditor) SetVolumeMode(mode corev1.PersistentVolumeMode)
SetVolumeMode sets the volume mode (Filesystem or Block) for the PVC.
The volume mode is immutable on existing PVCs. This method should be used for initial construction, or when reapplying the same value via Server-Side Apply. Attempting to change this field on an existing PVC will be rejected by the Kubernetes API server.
func (*PVCSpecEditor) SetVolumeName ¶
func (e *PVCSpecEditor) SetVolumeName(name string)
SetVolumeName binds the PVC to a specific PersistentVolume by name.
The volume name is immutable on existing PVCs. This method should be used for initial construction, or when reapplying the same value via Server-Side Apply. Attempting to change this field on an existing PVC will be rejected by the Kubernetes API server.
type PVSpecEditor ¶
type PVSpecEditor struct {
// contains filtered or unexported fields
}
PVSpecEditor provides a typed API for mutating a Kubernetes PersistentVolumeSpec.
It exposes structured operations for the most common PV spec fields. Use Raw() for free-form access when none of the structured methods are sufficient.
func NewPVSpecEditor ¶
func NewPVSpecEditor(spec *corev1.PersistentVolumeSpec) *PVSpecEditor
NewPVSpecEditor creates a new PVSpecEditor for the given PersistentVolumeSpec.
func (*PVSpecEditor) Raw ¶
func (e *PVSpecEditor) Raw() *corev1.PersistentVolumeSpec
Raw returns the underlying *corev1.PersistentVolumeSpec.
This is an escape hatch for cases where the typed API is insufficient.
func (*PVSpecEditor) SetAccessModes ¶
func (e *PVSpecEditor) SetAccessModes(modes []corev1.PersistentVolumeAccessMode)
SetAccessModes replaces the access modes of the PersistentVolume.
func (*PVSpecEditor) SetCapacity ¶
func (e *PVSpecEditor) SetCapacity(storage resource.Quantity)
SetCapacity sets the storage capacity of the PersistentVolume.
func (*PVSpecEditor) SetMountOptions ¶
func (e *PVSpecEditor) SetMountOptions(options []string)
SetMountOptions replaces the mount options for the PersistentVolume.
func (*PVSpecEditor) SetNodeAffinity ¶
func (e *PVSpecEditor) SetNodeAffinity(affinity *corev1.VolumeNodeAffinity)
SetNodeAffinity sets the node affinity for the PersistentVolume.
func (*PVSpecEditor) SetPersistentVolumeReclaimPolicy ¶
func (e *PVSpecEditor) SetPersistentVolumeReclaimPolicy(policy corev1.PersistentVolumeReclaimPolicy)
SetPersistentVolumeReclaimPolicy sets the reclaim policy for the PersistentVolume.
func (*PVSpecEditor) SetStorageClassName ¶
func (e *PVSpecEditor) SetStorageClassName(name string)
SetStorageClassName sets the storage class name for the PersistentVolume.
func (*PVSpecEditor) SetVolumeMode ¶
func (e *PVSpecEditor) SetVolumeMode(mode corev1.PersistentVolumeMode)
SetVolumeMode sets the volume mode for the PersistentVolume.
type PodDisruptionBudgetSpecEditor ¶
type PodDisruptionBudgetSpecEditor struct {
// contains filtered or unexported fields
}
PodDisruptionBudgetSpecEditor provides a typed API for mutating a Kubernetes PodDisruptionBudgetSpec.
func NewPodDisruptionBudgetSpecEditor ¶
func NewPodDisruptionBudgetSpecEditor(spec *policyv1.PodDisruptionBudgetSpec) *PodDisruptionBudgetSpecEditor
NewPodDisruptionBudgetSpecEditor creates a new PodDisruptionBudgetSpecEditor for the given PodDisruptionBudgetSpec.
func (*PodDisruptionBudgetSpecEditor) ClearMaxUnavailable ¶
func (e *PodDisruptionBudgetSpecEditor) ClearMaxUnavailable()
ClearMaxUnavailable removes the MaxUnavailable constraint.
func (*PodDisruptionBudgetSpecEditor) ClearMinAvailable ¶
func (e *PodDisruptionBudgetSpecEditor) ClearMinAvailable()
ClearMinAvailable removes the MinAvailable constraint.
func (*PodDisruptionBudgetSpecEditor) ClearUnhealthyPodEvictionPolicy ¶
func (e *PodDisruptionBudgetSpecEditor) ClearUnhealthyPodEvictionPolicy()
ClearUnhealthyPodEvictionPolicy removes the unhealthy pod eviction policy, reverting to the cluster default.
func (*PodDisruptionBudgetSpecEditor) Raw ¶
func (e *PodDisruptionBudgetSpecEditor) Raw() *policyv1.PodDisruptionBudgetSpec
Raw returns the underlying *policyv1.PodDisruptionBudgetSpec.
This is an escape hatch for cases where the typed API is insufficient.
func (*PodDisruptionBudgetSpecEditor) SetMaxUnavailable ¶
func (e *PodDisruptionBudgetSpecEditor) SetMaxUnavailable(val intstr.IntOrString)
SetMaxUnavailable sets the maximum number of pods that can be unavailable after an eviction. Accepts either an integer or a percentage string (e.g. "25%").
func (*PodDisruptionBudgetSpecEditor) SetMinAvailable ¶
func (e *PodDisruptionBudgetSpecEditor) SetMinAvailable(val intstr.IntOrString)
SetMinAvailable sets the minimum number of pods that must be available after an eviction. Accepts either an integer or a percentage string (e.g. "50%").
func (*PodDisruptionBudgetSpecEditor) SetSelector ¶
func (e *PodDisruptionBudgetSpecEditor) SetSelector(selector *metav1.LabelSelector)
SetSelector replaces the pod selector used by the PodDisruptionBudget.
func (*PodDisruptionBudgetSpecEditor) SetUnhealthyPodEvictionPolicy ¶
func (e *PodDisruptionBudgetSpecEditor) SetUnhealthyPodEvictionPolicy( policy policyv1.UnhealthyPodEvictionPolicyType, )
SetUnhealthyPodEvictionPolicy sets the unhealthy pod eviction policy.
Valid values are policyv1.IfHealthyBudget and policyv1.AlwaysAllow.
type PodSpecEditor ¶
type PodSpecEditor struct {
// contains filtered or unexported fields
}
PodSpecEditor provides a typed API for mutating a Kubernetes PodSpec. It remains a scoped editor, and Raw() can be used for less common changes.
func NewPodSpecEditor ¶
func NewPodSpecEditor(spec *corev1.PodSpec) *PodSpecEditor
NewPodSpecEditor creates a new PodSpecEditor for the given PodSpec.
func (*PodSpecEditor) EnsureImagePullSecret ¶
func (e *PodSpecEditor) EnsureImagePullSecret(name string)
EnsureImagePullSecret appends the given secret name to spec.ImagePullSecrets if it's not already present. It identifies existing secrets by name.
func (*PodSpecEditor) EnsureNodeSelector ¶
func (e *PodSpecEditor) EnsureNodeSelector(key, value string)
EnsureNodeSelector initializes spec.NodeSelector if nil and upserts the given key/value pair.
func (*PodSpecEditor) EnsureToleration ¶
func (e *PodSpecEditor) EnsureToleration(t corev1.Toleration)
EnsureToleration appends the given toleration to spec.Tolerations if an equal toleration is not already present. It uses exact struct equality for comparison.
func (*PodSpecEditor) EnsureVolume ¶
func (e *PodSpecEditor) EnsureVolume(v corev1.Volume)
EnsureVolume replaces an existing volume with the same name in spec.Volumes or appends it if missing. It identifies volumes by their Name field.
func (*PodSpecEditor) Raw ¶
func (e *PodSpecEditor) Raw() *corev1.PodSpec
Raw returns the underlying *corev1.PodSpec.
func (*PodSpecEditor) RemoveImagePullSecret ¶
func (e *PodSpecEditor) RemoveImagePullSecret(name string)
RemoveImagePullSecret removes all entries from spec.ImagePullSecrets that match the given name. It's a no-op if no matching entries are present.
func (*PodSpecEditor) RemoveNodeSelector ¶
func (e *PodSpecEditor) RemoveNodeSelector(key string)
RemoveNodeSelector removes the key from spec.NodeSelector. It's a no-op if NodeSelector is nil or the key is not present.
func (*PodSpecEditor) RemoveTolerations ¶
func (e *PodSpecEditor) RemoveTolerations(match func(corev1.Toleration) bool)
RemoveTolerations removes all tolerations for which the match function returns true. It ignores the call if the match function is nil.
func (*PodSpecEditor) RemoveVolume ¶
func (e *PodSpecEditor) RemoveVolume(name string)
RemoveVolume removes all volumes with the given name from spec.Volumes. It's a no-op if no volume with the given name is present.
func (*PodSpecEditor) SetHostIPC ¶
func (e *PodSpecEditor) SetHostIPC(enabled bool)
SetHostIPC sets the spec.HostIPC field.
func (*PodSpecEditor) SetHostNetwork ¶
func (e *PodSpecEditor) SetHostNetwork(enabled bool)
SetHostNetwork sets the spec.HostNetwork field.
func (*PodSpecEditor) SetHostPID ¶
func (e *PodSpecEditor) SetHostPID(enabled bool)
SetHostPID sets the spec.HostPID field.
func (*PodSpecEditor) SetPriorityClassName ¶
func (e *PodSpecEditor) SetPriorityClassName(name string)
SetPriorityClassName sets the spec.PriorityClassName field.
func (*PodSpecEditor) SetSecurityContext ¶
func (e *PodSpecEditor) SetSecurityContext(ctx *corev1.PodSecurityContext)
SetSecurityContext sets the spec.SecurityContext field.
func (*PodSpecEditor) SetServiceAccountName ¶
func (e *PodSpecEditor) SetServiceAccountName(name string)
SetServiceAccountName sets the spec.ServiceAccountName field.
type PolicyRulesEditor ¶
type PolicyRulesEditor struct {
// contains filtered or unexported fields
}
PolicyRulesEditor provides a typed API for mutating the .rules field of a Kubernetes Role or ClusterRole.
It exposes structured operations (SetRules, AddRule, RemoveRuleByIndex, Clear) as well as Raw() for free-form access when none of the structured methods are sufficient.
func NewPolicyRulesEditor ¶
func NewPolicyRulesEditor(rules *[]rbacv1.PolicyRule) *PolicyRulesEditor
NewPolicyRulesEditor creates a new PolicyRulesEditor wrapping the given rules slice pointer.
The pointer itself must be non-nil — passing a nil pointer is a programmer error and will cause a panic. It may refer to a nil slice; methods that append rules initialise it automatically. Pass a non-nil pointer (e.g. &cr.Rules) so that writes are reflected on the object.
func (*PolicyRulesEditor) AddRule ¶
func (e *PolicyRulesEditor) AddRule(rule rbacv1.PolicyRule)
AddRule appends a PolicyRule to the rules slice.
func (*PolicyRulesEditor) Raw ¶
func (e *PolicyRulesEditor) Raw() *[]rbacv1.PolicyRule
Raw returns a pointer to the underlying []rbacv1.PolicyRule, initialising the slice if necessary.
This is an escape hatch for free-form editing when none of the structured methods are sufficient.
func (*PolicyRulesEditor) RemoveRuleByIndex ¶
func (e *PolicyRulesEditor) RemoveRuleByIndex(index int)
RemoveRuleByIndex removes the rule at the given index.
It is a no-op if the index is out of bounds.
func (*PolicyRulesEditor) SetRules ¶
func (e *PolicyRulesEditor) SetRules(rules []rbacv1.PolicyRule)
SetRules replaces the full rules slice with the provided rules.
type RawEditor ¶
type RawEditor[T any] interface { // Raw returns a pointer to the raw Kubernetes object. Raw() *T }
RawEditor provides access to the raw underlying Kubernetes object.
This interface allows users to perform unconstrained modifications to the object when the provided typed helpers are insufficient.
type ReplicaSetSpecEditor ¶
type ReplicaSetSpecEditor struct {
// contains filtered or unexported fields
}
ReplicaSetSpecEditor provides a typed API for mutating a Kubernetes ReplicaSetSpec.
Note: spec.selector is immutable after creation and is not exposed here. Set it via the desired object passed to the ReplicaSet builder.
func NewReplicaSetSpecEditor ¶
func NewReplicaSetSpecEditor(spec *appsv1.ReplicaSetSpec) *ReplicaSetSpecEditor
NewReplicaSetSpecEditor creates a new ReplicaSetSpecEditor for the given ReplicaSetSpec.
func (*ReplicaSetSpecEditor) Raw ¶
func (e *ReplicaSetSpecEditor) Raw() *appsv1.ReplicaSetSpec
Raw returns the underlying *appsv1.ReplicaSetSpec.
This is an escape hatch for cases where the typed API is insufficient.
func (*ReplicaSetSpecEditor) SetMinReadySeconds ¶
func (e *ReplicaSetSpecEditor) SetMinReadySeconds(seconds int32)
SetMinReadySeconds sets the minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available.
func (*ReplicaSetSpecEditor) SetReplicas ¶
func (e *ReplicaSetSpecEditor) SetReplicas(replicas int32)
SetReplicas sets the number of desired replicas for the ReplicaSet.
type SecretDataEditor ¶
type SecretDataEditor struct {
// contains filtered or unexported fields
}
SecretDataEditor provides a typed API for mutating the .data and .stringData fields of a Kubernetes Secret.
It exposes structured operations (Set, Remove, SetString, RemoveString) as well as Raw() and RawStringData() for free-form access when none of the structured methods are sufficient.
Note on Kubernetes semantics: the API server merges .stringData into .data on write and returns only .data on read. During reconciliation it is safe to use either field; the two coexist on the desired object until it is applied.
func NewSecretDataEditor ¶
func NewSecretDataEditor(data *map[string][]byte, stringData *map[string]string) *SecretDataEditor
NewSecretDataEditor creates a new SecretDataEditor wrapping the given .data and .stringData map pointers.
Either pointer may be nil, in which case the editor allocates a local zero-value map for that field. Operations on that field will succeed but writes will not propagate back to any external map. Pass non-nil pointers (e.g. &secret.Data, &secret.StringData) when the changes must be reflected on the object. The maps the pointers refer to may themselves be nil; methods that write to a map initialise it automatically.
func (*SecretDataEditor) Raw ¶
func (e *SecretDataEditor) Raw() map[string][]byte
Raw returns the underlying .data map directly, initialising it if necessary.
This is an escape hatch for free-form editing when none of the structured methods are sufficient.
func (*SecretDataEditor) RawStringData ¶
func (e *SecretDataEditor) RawStringData() map[string]string
RawStringData returns the underlying .stringData map directly, initialising it if necessary.
This is an escape hatch for free-form editing.
func (*SecretDataEditor) Remove ¶
func (e *SecretDataEditor) Remove(key string)
Remove deletes key from .data. It is a no-op if the key does not exist or the underlying map is nil.
func (*SecretDataEditor) RemoveString ¶
func (e *SecretDataEditor) RemoveString(key string)
RemoveString deletes key from .stringData. It is a no-op if the key does not exist or the underlying map is nil.
func (*SecretDataEditor) Set ¶
func (e *SecretDataEditor) Set(key string, value []byte)
Set sets key to value in .data, initialising the map if necessary.
func (*SecretDataEditor) SetString ¶
func (e *SecretDataEditor) SetString(key, value string)
SetString sets key to value in .stringData, initialising the map if necessary.
The API server will merge .stringData into .data on write; use this when working with plaintext values that should not be pre-encoded.
type ServiceSpecEditor ¶
type ServiceSpecEditor struct {
// contains filtered or unexported fields
}
ServiceSpecEditor provides a typed API for mutating a Kubernetes ServiceSpec.
func NewServiceSpecEditor ¶
func NewServiceSpecEditor(spec *corev1.ServiceSpec) *ServiceSpecEditor
NewServiceSpecEditor creates a new ServiceSpecEditor for the given ServiceSpec.
func (*ServiceSpecEditor) EnsurePort ¶
func (e *ServiceSpecEditor) EnsurePort(port corev1.ServicePort)
EnsurePort upserts a service port. If a port with the same Name exists (or the same Port number and Protocol when both ports are unnamed), it is replaced; otherwise the port is appended. When matching unnamed ports, only existing unnamed ports are considered, and an empty Protocol is treated as TCP (the Kubernetes default).
func (*ServiceSpecEditor) EnsureSelector ¶
func (e *ServiceSpecEditor) EnsureSelector(key, value string)
EnsureSelector adds or updates a single selector key-value pair.
func (*ServiceSpecEditor) Raw ¶
func (e *ServiceSpecEditor) Raw() *corev1.ServiceSpec
Raw returns the underlying *corev1.ServiceSpec.
This is an escape hatch for cases where the typed API is insufficient.
func (*ServiceSpecEditor) RemovePort ¶
func (e *ServiceSpecEditor) RemovePort(name string)
RemovePort removes a service port by name. It is a no-op if the port does not exist.
func (*ServiceSpecEditor) RemoveSelector ¶
func (e *ServiceSpecEditor) RemoveSelector(key string)
RemoveSelector removes a single selector key. It is a no-op if the key does not exist.
func (*ServiceSpecEditor) SetExternalName ¶
func (e *ServiceSpecEditor) SetExternalName(name string)
SetExternalName sets the external name for an ExternalName service type.
func (*ServiceSpecEditor) SetExternalTrafficPolicy ¶
func (e *ServiceSpecEditor) SetExternalTrafficPolicy(policy corev1.ServiceExternalTrafficPolicy)
SetExternalTrafficPolicy sets the external traffic policy for the service.
func (*ServiceSpecEditor) SetInternalTrafficPolicy ¶
func (e *ServiceSpecEditor) SetInternalTrafficPolicy(policy *corev1.ServiceInternalTrafficPolicy)
SetInternalTrafficPolicy sets the internal traffic policy for the service.
func (*ServiceSpecEditor) SetLoadBalancerSourceRanges ¶
func (e *ServiceSpecEditor) SetLoadBalancerSourceRanges(ranges []string)
SetLoadBalancerSourceRanges sets the allowed source ranges for a LoadBalancer service.
func (*ServiceSpecEditor) SetPublishNotReadyAddresses ¶
func (e *ServiceSpecEditor) SetPublishNotReadyAddresses(v bool)
SetPublishNotReadyAddresses controls whether endpoints for not-ready pods are published.
func (*ServiceSpecEditor) SetSelector ¶
func (e *ServiceSpecEditor) SetSelector(selector map[string]string)
SetSelector replaces the entire service selector map.
func (*ServiceSpecEditor) SetSessionAffinity ¶
func (e *ServiceSpecEditor) SetSessionAffinity(affinity corev1.ServiceAffinity)
SetSessionAffinity sets the session affinity type (None or ClientIP).
func (*ServiceSpecEditor) SetSessionAffinityConfig ¶
func (e *ServiceSpecEditor) SetSessionAffinityConfig(cfg *corev1.SessionAffinityConfig)
SetSessionAffinityConfig sets the session affinity configuration.
func (*ServiceSpecEditor) SetType ¶
func (e *ServiceSpecEditor) SetType(t corev1.ServiceType)
SetType sets the service type (ClusterIP, NodePort, LoadBalancer, ExternalName).
type StatefulSetSpecEditor ¶
type StatefulSetSpecEditor struct {
// contains filtered or unexported fields
}
StatefulSetSpecEditor provides a typed API for mutating a Kubernetes StatefulSetSpec.
func NewStatefulSetSpecEditor ¶
func NewStatefulSetSpecEditor(spec *appsv1.StatefulSetSpec) *StatefulSetSpecEditor
NewStatefulSetSpecEditor creates a new StatefulSetSpecEditor for the given StatefulSetSpec.
func (*StatefulSetSpecEditor) Raw ¶
func (e *StatefulSetSpecEditor) Raw() *appsv1.StatefulSetSpec
Raw returns the underlying *appsv1.StatefulSetSpec.
This is an escape hatch for cases where the typed API is insufficient.
func (*StatefulSetSpecEditor) SetMinReadySeconds ¶
func (e *StatefulSetSpecEditor) SetMinReadySeconds(seconds int32)
SetMinReadySeconds sets the minimum number of seconds for which a newly created pod should be ready before it is considered available.
func (*StatefulSetSpecEditor) SetPersistentVolumeClaimRetentionPolicy ¶
func (e *StatefulSetSpecEditor) SetPersistentVolumeClaimRetentionPolicy( policy *appsv1.StatefulSetPersistentVolumeClaimRetentionPolicy, )
SetPersistentVolumeClaimRetentionPolicy sets the policy for retaining PVCs when pods are scaled down or the StatefulSet is deleted.
func (*StatefulSetSpecEditor) SetPodManagementPolicy ¶
func (e *StatefulSetSpecEditor) SetPodManagementPolicy(policy appsv1.PodManagementPolicyType)
SetPodManagementPolicy sets the policy for creating pods under the StatefulSet.
func (*StatefulSetSpecEditor) SetReplicas ¶
func (e *StatefulSetSpecEditor) SetReplicas(replicas int32)
SetReplicas sets the number of desired replicas for the StatefulSet.
func (*StatefulSetSpecEditor) SetRevisionHistoryLimit ¶
func (e *StatefulSetSpecEditor) SetRevisionHistoryLimit(limit int32)
SetRevisionHistoryLimit sets the number of revisions to retain in the StatefulSet's revision history.
func (*StatefulSetSpecEditor) SetServiceName ¶
func (e *StatefulSetSpecEditor) SetServiceName(name string)
SetServiceName sets the name of the governing Service for the StatefulSet.
func (*StatefulSetSpecEditor) SetUpdateStrategy ¶
func (e *StatefulSetSpecEditor) SetUpdateStrategy(strategy appsv1.StatefulSetUpdateStrategy)
SetUpdateStrategy sets the update strategy for the StatefulSet.
type UnstructuredContentEditor ¶
type UnstructuredContentEditor struct {
// contains filtered or unexported fields
}
UnstructuredContentEditor provides a typed API for mutating the content of a Kubernetes unstructured object.
It wraps the object's underlying map[string]interface{} and exposes structured operations for setting and removing values at nested paths. The editor delegates to the k8s.io/apimachinery/pkg/apis/meta/v1/unstructured helper functions for path traversal and creation.
For reads during mutation, use Raw() to access the underlying map directly.
func NewUnstructuredContentEditor ¶
func NewUnstructuredContentEditor(content map[string]interface{}) *UnstructuredContentEditor
NewUnstructuredContentEditor creates a new UnstructuredContentEditor wrapping the given content map.
The content map is typically obtained from unstructured.Unstructured.Object. Mutations are applied directly to the provided map.
func (*UnstructuredContentEditor) EnsureNestedStringMapEntry ¶
func (e *UnstructuredContentEditor) EnsureNestedStringMapEntry(key, value string, fields ...string) error
EnsureNestedStringMapEntry adds or updates a single entry in a nested string map. If the map does not exist at the given path it is created.
func (*UnstructuredContentEditor) Raw ¶
func (e *UnstructuredContentEditor) Raw() map[string]interface{}
Raw returns the underlying content map directly.
This is an escape hatch for free-form editing when none of the structured methods are sufficient.
func (*UnstructuredContentEditor) RemoveNestedField ¶
func (e *UnstructuredContentEditor) RemoveNestedField(fields ...string)
RemoveNestedField removes the field at the specified nested path. It is a no-op if the path does not exist.
func (*UnstructuredContentEditor) RemoveNestedStringMapEntry ¶
func (e *UnstructuredContentEditor) RemoveNestedStringMapEntry(key string, fields ...string) error
RemoveNestedStringMapEntry removes a single entry from a nested string map. It is a no-op if the map or the key does not exist.
func (*UnstructuredContentEditor) SetNestedBool ¶
func (e *UnstructuredContentEditor) SetNestedBool(value bool, fields ...string) error
SetNestedBool sets a boolean value at the specified nested path.
func (*UnstructuredContentEditor) SetNestedField ¶
func (e *UnstructuredContentEditor) SetNestedField(value interface{}, fields ...string) error
SetNestedField sets a value at the specified nested path, creating intermediate maps as needed.
func (*UnstructuredContentEditor) SetNestedFloat64 ¶
func (e *UnstructuredContentEditor) SetNestedFloat64(value float64, fields ...string) error
SetNestedFloat64 sets a float64 value at the specified nested path.
func (*UnstructuredContentEditor) SetNestedInt64 ¶
func (e *UnstructuredContentEditor) SetNestedInt64(value int64, fields ...string) error
SetNestedInt64 sets an int64 value at the specified nested path.
func (*UnstructuredContentEditor) SetNestedMap ¶
func (e *UnstructuredContentEditor) SetNestedMap(value map[string]interface{}, fields ...string) error
SetNestedMap sets a map[string]interface{} value at the specified nested path, replacing any existing value at that path.
func (*UnstructuredContentEditor) SetNestedSlice ¶
func (e *UnstructuredContentEditor) SetNestedSlice(value []interface{}, fields ...string) error
SetNestedSlice sets a []interface{} value at the specified nested path, replacing any existing value at that path.
func (*UnstructuredContentEditor) SetNestedString ¶
func (e *UnstructuredContentEditor) SetNestedString(value string, fields ...string) error
SetNestedString sets a string value at the specified nested path.
func (*UnstructuredContentEditor) SetNestedStringMap ¶
func (e *UnstructuredContentEditor) SetNestedStringMap(value map[string]string, fields ...string) error
SetNestedStringMap sets a map[string]string value at the specified nested path, replacing any existing value at that path.
Source Files
¶
- bindingsubjects.go
- configmapdata.go
- container.go
- cronjobspec.go
- daemonsetspec.go
- deploymentspec.go
- editor.go
- hpaspec.go
- ingressspec.go
- jobspec.go
- mutators.go
- networkpolicyspec.go
- objectmeta.go
- pdbspec.go
- podspec.go
- policyrules.go
- pvcspec.go
- pvspec.go
- replicasetspec.go
- secretdata.go
- servicespec.go
- statefulsetspec.go
- unstructuredcontent.go