You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
XRDs can define [validation rules](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation-rules) expressed in the Common Expression Language, CEL for short.
855
+
The `crossplane beta validate` command can validate an XR and one or more
message: "replicas should be in between minReplicas and maxReplicas."
867
-
```
868
-
{{< /expand >}}
858
+
{{<hint "important" >}}
859
+
When validating against a provider the `crossplane beta validate` command
860
+
downloads the provider package to the `--cache-dir` directory. By default
861
+
Crossplane uses `.crossplane` as the `--cache-dir` location.
869
862
870
-
`crossplane beta validate xrd.yaml rong-xr.yaml`
871
-
{{< expand "CEL rule violation" >}}
872
-
```console
873
-
[x] CEL validation error example.crossplane.io/v1beta1, Kind=XR, example : spec: Invalid value: "object": replicas should be in between minReplicas and maxReplicas.
[x] schema validation error example.crossplane.io/v1beta1, Kind=XR, example : status.conditions[0].lastTransitionTime: Invalid value: "null": status.conditions[0].lastTransitionTime in body must be of type string: "null"
925
935
[x] schema validation error example.crossplane.io/v1beta1, Kind=XR, example : spec: Required value
XRDs can define [validation rules](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#validation-rules) expressed in the Common Expression Language
[x] schema validation error example.crossplane.io/v1beta1, Kind=XR, example : status.conditions[0].lastTransitionTime: Invalid value: "null": status.conditions[0].lastTransitionTime in body must be of type string: "null"
Pass a directory containing YAML files as an argument to the validate command.
994
+
Running `crossplane beta validate` with the example XRD and XR produces an
995
+
error.
952
996
953
-
{{< hint "tip" >}}
954
-
The command processes only the Crossplane YAML files while ignoring files with
955
-
other extensions.
956
-
{{< /hint >}}
997
+
```shell
998
+
`crossplane beta validate xrd.yaml xr.yaml
999
+
[x] CEL validation error example.crossplane.io/v1beta1, Kind=XR, example : spec: Invalid value: "object": replicas should be in between minReplicas and maxReplicas.
{{< expand "Downloading packages and validating directory content" >}}
979
-
```console
980
-
package schemas does not exist, downloading: xpkg.upbound.io/upbound/configuration-observability-oss:v0.2.0
981
-
package schemas does not exist, downloading: xpkg.upbound.io/upbound/configuration-gitops-flux:v0.2.0
982
-
package schemas does not exist, downloading: xpkg.upbound.io/upbound/provider-aws-iam:v0.45.0
983
-
package schemas does not exist, downloading: xpkg.upbound.io/upbound/platform-ref-aws:v0.9.0
984
-
package schemas does not exist, downloading: xpkg.upbound.io/upbound/configuration-aws-network:v0.7.0
985
-
package schemas does not exist, downloading: xpkg.upbound.io/upbound/configuration-aws-database:v0.5.0
986
-
package schemas does not exist, downloading: xpkg.upbound.io/upbound/configuration-aws-eks:v0.5.0
987
-
package schemas does not exist, downloading: xpkg.upbound.io/upbound/configuration-app:v0.2.0
1028
+
Provide the directory name and a resource YAML file to the
1029
+
`crossplane beta validate` command.
1030
+
1031
+
```shell
1032
+
crossplane beta validate schema resources.yaml
988
1033
[x] schema validation error example.crossplane.io/v1beta1, Kind=XR, example : status.conditions[0].lastTransitionTime: Invalid value: "null": status.conditions[0].lastTransitionTime in body must be of type string: "null"
989
1034
[x] CEL validation error example.crossplane.io/v1beta1, Kind=XR, example : spec: Invalid value: "object": no such key: minReplicas evaluating rule: replicas should be greater than or equal to minReplicas.
0 commit comments