Skip to content

Commit

Permalink
Fix some names in common Autoscaler types
Browse files Browse the repository at this point in the history
  • Loading branch information
vboulineau committed Feb 18, 2025
1 parent 14fc1bb commit 6465ee6
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 83 deletions.
26 changes: 13 additions & 13 deletions api/datadoghq/common/datadogpodautoscaler_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,36 +115,36 @@ type DatadogPodAutoscalerScalingRule struct {
PeriodSeconds int32 `json:"periodSeconds"`
}

// DatadogPodAutoscalerTargetType defines the type of the target.
// DatadogPodAutoscalerObjectiveType defines the type of the target.
// +kubebuilder:validation:Enum:=PodResource;ContainerResource
type DatadogPodAutoscalerTargetType string
type DatadogPodAutoscalerObjectiveType string

const (
// DatadogPodAutoscalerPodResourceTargetType allows to set pod-level resource targets.
DatadogPodAutoscalerPodResourceTargetType DatadogPodAutoscalerTargetType = "PodResource"
// DatadogPodAutoscalerPodResourceObjectiveType allows to set pod-level resource targets.
DatadogPodAutoscalerPodResourceObjectiveType DatadogPodAutoscalerObjectiveType = "PodResource"

// DatadogPodAutoscalerContainerResourceTargetType allows to set container-level resource targets.
DatadogPodAutoscalerContainerResourceTargetType DatadogPodAutoscalerTargetType = "ContainerResource"
// DatadogPodAutoscalerContainerResourceObjectiveType allows to set container-level resource targets.
DatadogPodAutoscalerContainerResourceObjectiveType DatadogPodAutoscalerObjectiveType = "ContainerResource"
)

// DatadogPodAutoscalerObjective defines the objectives to reach and maintain for the target resource.
// +kubebuilder:object:generate=true
type DatadogPodAutoscalerObjective struct {
// Type sets the type of the target.
Type DatadogPodAutoscalerTargetType `json:"type"`
Type DatadogPodAutoscalerObjectiveType `json:"type"`

// PodResource allows to set a pod-level resource target.
PodResource *DatadogPodAutoscalerResourceTarget `json:"podResource,omitempty"`
PodResource *DatadogPodAutoscalerPodResourceObjective `json:"podResource,omitempty"`

// ContainerResource allows to set a container-level resource target.
ContainerResource *DatadogPodAutoscalerContainerResourceTarget `json:"containerResource,omitempty"`
ContainerResource *DatadogPodAutoscalerContainerResourceObjective `json:"containerResource,omitempty"`
}

// DatadogPodAutoscalerResourceTarget defines a pod-level resource target (for instance, CPU Utilization at 80%)
// DatadogPodAutoscalerPodResourceObjective defines a pod-level resource target (for instance, CPU Utilization at 80%)
// For pod-level targets, resources are the sum of all containers resources.
// Utilization is computed from sum(usage) / sum(requests).
// +kubebuilder:object:generate=true
type DatadogPodAutoscalerResourceTarget struct {
type DatadogPodAutoscalerPodResourceObjective struct {
// Name is the name of the resource.
// +kubebuilder:validation:Enum:=cpu
Name corev1.ResourceName `json:"name"`
Expand All @@ -153,9 +153,9 @@ type DatadogPodAutoscalerResourceTarget struct {
Value DatadogPodAutoscalerTargetValue `json:"value"`
}

// DatadogPodAutoscalerContainerResourceTarget defines a container-level resource target (for instance, CPU Utilization for container named "foo" at 80%)
// DatadogPodAutoscalerContainerResourceObjective defines a container-level resource target (for instance, CPU Utilization for container named "foo" at 80%)
// +kubebuilder:object:generate=true
type DatadogPodAutoscalerContainerResourceTarget struct {
type DatadogPodAutoscalerContainerResourceObjective struct {
// Name is the name of the resource.
// +kubebuilder:validation:Enum:=cpu
Name corev1.ResourceName `json:"name"`
Expand Down
20 changes: 10 additions & 10 deletions api/datadoghq/common/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions api/datadoghq/v1alpha2/datadogpodautoscaler_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
package v1alpha2

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/DataDog/datadog-operator/api/datadoghq/v1alpha1"
)

Expand All @@ -17,7 +19,10 @@ func NewDatadogPodAutoscalerFromV1Alpha1(in *v1alpha1.DatadogPodAutoscaler) *Dat
// As many types are shared, we'll assign the deep copied value to the new object
in = in.DeepCopy()
out := &DatadogPodAutoscaler{
TypeMeta: in.TypeMeta,
TypeMeta: metav1.TypeMeta{
Kind: "DatadogPodAutoscaler",
APIVersion: "datadoghq.com/v1alpha2",
},
ObjectMeta: in.ObjectMeta,
Spec: ConvertDatadogPodAutoscalerSpecFromV1Alpha1(in.Spec),
Status: in.Status,
Expand Down Expand Up @@ -61,7 +66,10 @@ func NewDatadogPodAutoscalerToV1Alpha1(in *DatadogPodAutoscaler) *v1alpha1.Datad
// As many types are shared, we'll assign the deep copied value to the new object
in = in.DeepCopy()
out := &v1alpha1.DatadogPodAutoscaler{
TypeMeta: in.TypeMeta,
TypeMeta: metav1.TypeMeta{
Kind: "DatadogPodAutoscaler",
APIVersion: "datadoghq.com/v1alpha1",
},
ObjectMeta: in.ObjectMeta,
Spec: ConvertDatadogPodAutoscalerSpecToV1Alpha1(in.Spec),
Status: in.Status,
Expand Down
Loading

0 comments on commit 6465ee6

Please sign in to comment.