Skip to content

Commit

Permalink
use json.Number instead of float64
Browse files Browse the repository at this point in the history
  • Loading branch information
sbueringer committed Oct 13, 2021
1 parent a851a7f commit e27c834
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -355,15 +355,14 @@ generate-manifests: $(addprefix generate-manifests-,$(ALL_GENERATE_MODULES)) ##

.PHONY: generate-manifests-core
generate-manifests-core: $(CONTROLLER_GEN) $(KUSTOMIZE)
## crd:allowDangerousTypes is required to allow using float64 in JSONSchemaProps
$(CONTROLLER_GEN) \
paths=./api/... \
paths=./controllers/... \
paths=./$(EXP_DIR)/api/... \
paths=./$(EXP_DIR)/controllers/... \
paths=./$(EXP_DIR)/addons/api/... \
paths=./$(EXP_DIR)/addons/controllers/... \
crd:allowDangerousTypes=true,crdVersions=v1 \
crd:crdVersions=v1 \
rbac:roleName=manager-role \
output:crd:dir=./config/crd/bases \
output:webhook:dir=./config/webhook \
Expand Down
8 changes: 5 additions & 3 deletions api/v1beta1/clusterclass_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package v1beta1

import (
"encoding/json"

corev1 "k8s.io/api/core/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -195,7 +197,7 @@ type JSONSchemaProps struct {
// If ExclusiveMaximum is false, the variable is valid if it is lower than, or equal to, the value of Maximum.
// If ExclusiveMaximum is true, the variable is valid if it is strictly lower than the value of Maximum.
// +optional
Maximum *float64 `json:"maximum,omitempty"`
Maximum *json.Number `json:"maximum,omitempty"`

// ExclusiveMaximum specifies if the Maximum is exclusive.
// +optional
Expand All @@ -205,15 +207,15 @@ type JSONSchemaProps struct {
// If ExclusiveMinimum is false, the variable is valid if it is greater than, or equal to, the value of Minimum.
// If ExclusiveMinimum is true, the variable is valid if it is strictly greater than the value of Minimum.
// +optional
Minimum *float64 `json:"minimum,omitempty"`
Minimum *json.Number `json:"minimum,omitempty"`

// ExclusiveMinimum specifies if the Minimum is exclusive.
// +optional
ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty"`

// MultipleOf specifies the number of which the variable must be a multiple of.
// +optional
MultipleOf *float64 `json:"multipleOf,omitempty"`
MultipleOf *json.Number `json:"multipleOf,omitempty"`

// Enum is the list of valid values of the variable.
// +optional
Expand Down
7 changes: 4 additions & 3 deletions api/v1beta1/zz_generated.deepcopy.go

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

6 changes: 3 additions & 3 deletions config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ spec:
equal to, the value of Maximum. If ExclusiveMaximum
is true, the variable is valid if it is strictly
lower than the value of Maximum.
type: number
type: string
minLength:
description: MinLength is the min length of a string
variable.
Expand All @@ -774,11 +774,11 @@ spec:
equal to, the value of Minimum. If ExclusiveMinimum
is true, the variable is valid if it is strictly
greater than the value of Minimum.
type: number
type: string
multipleOf:
description: MultipleOf specifies the number of
which the variable must be a multiple of.
type: number
type: string
nullable:
description: Nullable specifies if the variable
can be set to null.
Expand Down

0 comments on commit e27c834

Please sign in to comment.