Skip to content

Commit

Permalink
Fix DatadogMetric generation with operator-sdk 0.17
Browse files Browse the repository at this point in the history
the CRD generator doesn't support `float64` as a type of a CRD field.
The sugested workaround is to used instead `resource.Quantity`.
Related issue: kubernetes-sigs/controller-tools#245

Signed-off-by: cedric lamoriniere <cedric.lamoriniere@datadoghq.com>
  • Loading branch information
clamoriniere committed May 26, 2020
1 parent 4cb9aaf commit 67fcfe0
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 21 deletions.
6 changes: 6 additions & 0 deletions deploy/crds/datadoghq.com_datadogmetrics_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,14 @@ spec:
- type
type: object
type: array
x-kubernetes-list-type: set
currentValue:
anyOf:
- type: integer
- type: string
description: Value is the latest value of the metric
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
required:
- currentValue
type: object
Expand Down
3 changes: 2 additions & 1 deletion pkg/apis/datadoghq/v1alpha1/datadogmetric_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -24,7 +25,7 @@ type DatadogMetricStatus struct {
// +listType=set
Conditions []DatadogMetricCondition `json:"conditions,omitempty"`
// Value is the latest value of the metric
Value float64 `json:"currentValue"`
Value resource.Quantity `json:"currentValue"`
}

// DatadogMetricCondition describes the state of a DatadogMetric at a certain point.
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/datadoghq/v1alpha1/zz_generated.deepcopy.go

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

60 changes: 40 additions & 20 deletions pkg/apis/datadoghq/v1alpha1/zz_generated.openapi.go

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

0 comments on commit 67fcfe0

Please sign in to comment.