From dbd5de27ca15b88f10a5fdf81891c2438ab6c2b9 Mon Sep 17 00:00:00 2001 From: ichekrygin Date: Mon, 7 Oct 2024 11:47:18 -0700 Subject: [PATCH 1/3] Enhance unit-test for packages/k8s.contrib.crd/tests/fixtures/crds.yaml adding support for colliding nested sub-objects. --- .../tests/ModuleGenerator.pkl-expected.pcf | 162 ++++++++++++++++++ .../k8s.contrib.crd/tests/fixtures/crds.yaml | 54 ++++++ 2 files changed, 216 insertions(+) diff --git a/packages/k8s.contrib.crd/tests/ModuleGenerator.pkl-expected.pcf b/packages/k8s.contrib.crd/tests/ModuleGenerator.pkl-expected.pcf index 2161933..e363251 100644 --- a/packages/k8s.contrib.crd/tests/ModuleGenerator.pkl-expected.pcf +++ b/packages/k8s.contrib.crd/tests/ModuleGenerator.pkl-expected.pcf @@ -58,6 +58,60 @@ examples { /// Compute Resources for the Restate container. More info: /// https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ resources: ResourceRequirements? + + /// Test nested objects field collision. + redObject: RedObject? + + /// Test nested objects field collision. + blueObject: BlueObject? + } + + /// Test nested objects field collision. + class RedObject { + /// Nested field. + nestedField: String + + /// Nested child object. + nestedObject: NestedObject? + + /// Nested list object red. + nestedList: Listing? + } + + /// Nested child object. + class NestedObject { + /// Nested field. + nestedRed: String? + } + + /// Red nested object test items. + class NestedList { + /// Red nested list field. + nestedListItemField: String? + } + + /// Test nested objects field collision. + class BlueObject { + /// Nested field. + nestedField: String + + /// Nested child object. + nestedObject: NestedObject? + + /// Nested list object blue. + nestedList: Listing? + } + + /// Nested child object. + class NestedObject { + /// Nested field. + nestedBlue: String? + } + + /// Blue nested object test items. + class NestedList { + /// Blue nested list field. + nestedListItemField: String? } /// Security configuration @@ -157,6 +211,60 @@ examples { /// Compute Resources for the Restate container. More info: /// https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ resources: ResourceRequirements? + + /// Test nested objects field collision. + redObject: RedObject? + + /// Test nested objects field collision. + blueObject: BlueObject? + } + + /// Test nested objects field collision. + class RedObject { + /// Nested field. + nestedField: String + + /// Nested child object. + nestedObject: NestedObject? + + /// Nested list object red. + nestedList: Listing? + } + + /// Nested child object. + class NestedObject { + /// Nested field. + nestedRed: String? + } + + /// Red nested object test items. + class NestedList { + /// Red nested list field. + nestedListItemField: String? + } + + /// Test nested objects field collision. + class BlueObject { + /// Nested field. + nestedField: String + + /// Nested child object. + nestedObject: NestedObject? + + /// Nested list object blue. + nestedList: Listing? + } + + /// Nested child object. + class NestedObject { + /// Nested field. + nestedBlue: String? + } + + /// Blue nested object test items. + class NestedList { + /// Blue nested list field. + nestedListItemField: String? } /// Security configuration @@ -256,6 +364,60 @@ examples { /// Compute Resources for the Restate container. More info: /// https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ resources: ResourceRequirements? + + /// Test nested objects field collision. + redObject: RedObject? + + /// Test nested objects field collision. + blueObject: BlueObject? + } + + /// Test nested objects field collision. + class RedObject { + /// Nested field. + nestedField: String + + /// Nested child object. + nestedObject: NestedObject? + + /// Nested list object red. + nestedList: Listing? + } + + /// Nested child object. + class NestedObject { + /// Nested field. + nestedRed: String? + } + + /// Red nested object test items. + class NestedList { + /// Red nested list field. + nestedListItemField: String? + } + + /// Test nested objects field collision. + class BlueObject { + /// Nested field. + nestedField: String + + /// Nested child object. + nestedObject: NestedObject? + + /// Nested list object blue. + nestedList: Listing? + } + + /// Nested child object. + class NestedObject { + /// Nested field. + nestedBlue: String? + } + + /// Blue nested object test items. + class NestedList { + /// Blue nested list field. + nestedListItemField: String? } /// Security configuration diff --git a/packages/k8s.contrib.crd/tests/fixtures/crds.yaml b/packages/k8s.contrib.crd/tests/fixtures/crds.yaml index 0bbb43c..bd29c43 100644 --- a/packages/k8s.contrib.crd/tests/fixtures/crds.yaml +++ b/packages/k8s.contrib.crd/tests/fixtures/crds.yaml @@ -151,6 +151,60 @@ spec: description: 'Requests describes the minimum amount of compute resources required. If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, otherwise to an implementation-defined value. Requests cannot exceed Limits. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object + redObject: + description: Test nested objects field collision. + properties: + nestedField: + description: Nested field. + type: string + nestedObject: + description: Nested child object. + properties: + nestedRed: + description: Nested field. + type: string + type: object + nestedList: + description: Nested list object red. + items: + description: Red nested object test items. + properties: + nestedListItemField: + description: Red nested list field. + type: string + type: object + nullable: true + type: array + required: + - nestedField + type: object + blueObject: + description: Test nested objects field collision. + properties: + nestedField: + description: Nested field. + type: string + nestedObject: + description: Nested child object. + properties: + nestedBlue: + description: Nested field. + type: string + type: object + nestedList: + description: Nested list object blue. + items: + description: Blue nested object test items. + properties: + nestedListItemField: + description: Blue nested list field. + type: string + type: object + nullable: true + type: array + required: + - nestedField + type: object required: - image type: object From ab5758e8ae70b031c302778121cd8b3e1c955378 Mon Sep 17 00:00:00 2001 From: ichekrygin Date: Mon, 7 Oct 2024 13:09:40 -0700 Subject: [PATCH 2/3] Change class naming convention to avoid classes collisions on colliding properties (objects, list). This change will result in: "spec.foo.bar": - current: classes ["Spec", "Foo", "Bar"] - change: classes ["Spec", "SpecFoo", "SpecFooBar" This change is suggested by https://github.com/Avarei in https://github.com/apple/pkl-pantry/issues/40#issuecomment-2205366945 --- .../internal/ModuleGenerator.pkl | 2 +- .../tests/ModuleGenerator.pkl-expected.pcf | 818 +++++++++--------- 2 files changed, 410 insertions(+), 410 deletions(-) diff --git a/packages/k8s.contrib.crd/internal/ModuleGenerator.pkl b/packages/k8s.contrib.crd/internal/ModuleGenerator.pkl index 4662bfb..06d307e 100644 --- a/packages/k8s.contrib.crd/internal/ModuleGenerator.pkl +++ b/packages/k8s.contrib.crd/internal/ModuleGenerator.pkl @@ -304,7 +304,7 @@ local classSchemas: Type.TypeNames = .fold(Map(), (accumulator: Type.TypeNames, pair) -> let (path = pair.first) let (schema = pair.second) - let (typeName = determineTypeName(path, path.lastOrNull?.capitalize() ?? "Item", accumulator.values.toSet(), 0)) + let (typeName = determineTypeName(path, path.fold(List(), (res: List, el: String) -> res.add(el.capitalize())).join(""), accumulator.values.toSet(), 0)) accumulator.put(schema, typeName) ) diff --git a/packages/k8s.contrib.crd/tests/ModuleGenerator.pkl-expected.pcf b/packages/k8s.contrib.crd/tests/ModuleGenerator.pkl-expected.pcf index e363251..2a6b98c 100644 --- a/packages/k8s.contrib.crd/tests/ModuleGenerator.pkl-expected.pcf +++ b/packages/k8s.contrib.crd/tests/ModuleGenerator.pkl-expected.pcf @@ -1,461 +1,461 @@ examples { ["RestateCluster.pkl"] { - """ - /// Auto-generated derived type for RestateClusterSpec via `CustomResource` - /// - /// This module was generated from the CustomResourceDefinition at . - module dev.restate.v1.RestateCluster - - extends "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/K8sResource.pkl" - - import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/apimachinery/pkg/apis/meta/v1/ObjectMeta.pkl" - import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/core/v1/EnvVar.pkl" - import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/core/v1/ResourceRequirements.pkl" - import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/networking/v1/NetworkPolicy.pkl" - - fixed apiVersion: "restate.dev/v1" - - fixed kind: "RestateCluster" - - /// Standard object's metadata. - /// - /// More info: . - metadata: ObjectMeta? - - /// Represents the configuration of a Restate Cluster - spec: Spec - - status: Dynamic? - - /// Represents the configuration of a Restate Cluster - class Spec { + """ + /// Auto-generated derived type for RestateClusterSpec via `CustomResource` + /// + /// This module was generated from the CustomResourceDefinition at . + module dev.restate.v1.RestateCluster + + extends "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/K8sResource.pkl" + + import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/apimachinery/pkg/apis/meta/v1/ObjectMeta.pkl" + import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/core/v1/EnvVar.pkl" + import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/core/v1/ResourceRequirements.pkl" + import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/networking/v1/NetworkPolicy.pkl" + + fixed apiVersion: "restate.dev/v1" + + fixed kind: "RestateCluster" + + /// Standard object's metadata. + /// + /// More info: . + metadata: ObjectMeta? + + /// Represents the configuration of a Restate Cluster + spec: Spec + + status: Dynamic? + + /// Represents the configuration of a Restate Cluster + class Spec { + /// Compute configuration + compute: SpecCompute + + /// Security configuration + security: SpecSecurity? + + /// Storage configuration + storage: SpecStorage + } + /// Compute configuration - compute: Compute - - /// Security configuration - security: Security? - - /// Storage configuration - storage: Storage - } - - /// Compute configuration - class Compute { - /// List of environment variables to set in the container; these may override defaults - env: Listing? - - /// Container image name. More info: https://kubernetes.io/docs/concepts/containers/images. - image: String - - /// Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is - /// specified, or IfNotPresent otherwise. More info: - /// https://kubernetes.io/docs/concepts/containers/images#updating-images - imagePullPolicy: String? - - /// replicas is the desired number of Restate nodes. If unspecified, defaults to 1. - replicas: Int? - - /// Compute Resources for the Restate container. More info: - /// https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - resources: ResourceRequirements? - - /// Test nested objects field collision. - redObject: RedObject? + class SpecCompute { + /// List of environment variables to set in the container; these may override defaults + env: Listing? + + /// Container image name. More info: https://kubernetes.io/docs/concepts/containers/images. + image: String + + /// Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is + /// specified, or IfNotPresent otherwise. More info: + /// https://kubernetes.io/docs/concepts/containers/images#updating-images + imagePullPolicy: String? + + /// replicas is the desired number of Restate nodes. If unspecified, defaults to 1. + replicas: Int? + + /// Compute Resources for the Restate container. More info: + /// https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + resources: ResourceRequirements? + + /// Test nested objects field collision. + redObject: SpecComputeRedObject? + + /// Test nested objects field collision. + blueObject: SpecComputeBlueObject? + } /// Test nested objects field collision. - blueObject: BlueObject? - } + class SpecComputeRedObject { + /// Nested field. + nestedField: String - /// Test nested objects field collision. - class RedObject { - /// Nested field. - nestedField: String + /// Nested child object. + nestedObject: SpecComputeRedObjectNestedObject? + + /// Nested list object red. + nestedList: Listing? + } /// Nested child object. - nestedObject: NestedObject? + class SpecComputeRedObjectNestedObject { + /// Nested field. + nestedRed: String? + } - /// Nested list object red. - nestedList: Listing? - } + /// Red nested object test items. + class SpecComputeRedObjectNestedListNestedList { + /// Red nested list field. + nestedListItemField: String? + } - /// Nested child object. - class NestedObject { - /// Nested field. - nestedRed: String? - } + /// Test nested objects field collision. + class SpecComputeBlueObject { + /// Nested field. + nestedField: String - /// Red nested object test items. - class NestedList { - /// Red nested list field. - nestedListItemField: String? - } + /// Nested child object. + nestedObject: SpecComputeBlueObjectNestedObject? - /// Test nested objects field collision. - class BlueObject { - /// Nested field. - nestedField: String + /// Nested list object blue. + nestedList: Listing? + } /// Nested child object. - nestedObject: NestedObject? - - /// Nested list object blue. - nestedList: Listing? - } - - /// Nested child object. - class NestedObject { - /// Nested field. - nestedBlue: String? - } - - /// Blue nested object test items. - class NestedList { - /// Blue nested list field. - nestedListItemField: String? - } - - /// Security configuration - class Security { - /// if set, create a AWS PodIdentityAssociation using the ACK CRD in order to give the Restate pod - /// access to this role - awsPodIdentityAssociationRoleArn: String? - + class SpecComputeBlueObjectNestedObject { + /// Nested field. + nestedBlue: String? + } + + /// Blue nested object test items. + class SpecComputeBlueObjectNestedListNestedList { + /// Blue nested list field. + nestedListItemField: String? + } + + /// Security configuration + class SpecSecurity { + /// if set, create a AWS PodIdentityAssociation using the ACK CRD in order to give the Restate pod + /// access to this role + awsPodIdentityAssociationRoleArn: String? + + /// Network peers to allow access to restate ports If unset, will not allow any new traffic. Set any of + /// these to [] to allow all traffic - not recommended. + networkPeers: SpecSecurityNetworkPeers? + + serviceAccountAnnotations: Mapping? + + serviceAnnotations: Mapping? + } + /// Network peers to allow access to restate ports If unset, will not allow any new traffic. Set any of /// these to [] to allow all traffic - not recommended. - networkPeers: NetworkPeers? - - serviceAccountAnnotations: Mapping? - - serviceAnnotations: Mapping? - } - - /// Network peers to allow access to restate ports If unset, will not allow any new traffic. Set any of - /// these to [] to allow all traffic - not recommended. - class NetworkPeers { - admin: Listing? - - ingress: Listing? - - metrics: Listing? - } - - /// Storage configuration - class Storage { - /// storageClassName is the name of the StorageClass required by the claim. More info: - /// https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1 this field is immutable - storageClassName: String? - - /// storageRequestBytes is the amount of storage to request in volume claims. It is allowed to increase - /// but not decrease. - storageRequestBytes: Int(this >= 1.0) - } - - """ + class SpecSecurityNetworkPeers { + admin: Listing? + + ingress: Listing? + + metrics: Listing? + } + + /// Storage configuration + class SpecStorage { + /// storageClassName is the name of the StorageClass required by the claim. More info: + /// https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1 this field is immutable + storageClassName: String? + + /// storageRequestBytes is the amount of storage to request in volume claims. It is allowed to increase + /// but not decrease. + storageRequestBytes: Int(this >= 1.0) + } + + """ } ["RestateCluster.pkl -- dependency notation for k8s"] { - """ - /// Auto-generated derived type for RestateClusterSpec via `CustomResource` - /// - /// This module was generated from the CustomResourceDefinition at . - module dev.restate.v1.RestateCluster - - extends "@k8s/K8sResource.pkl" - - import "@k8s/apimachinery/pkg/apis/meta/v1/ObjectMeta.pkl" - import "@k8s/api/core/v1/EnvVar.pkl" - import "@k8s/api/core/v1/ResourceRequirements.pkl" - import "@k8s/api/networking/v1/NetworkPolicy.pkl" - - fixed apiVersion: "restate.dev/v1" - - fixed kind: "RestateCluster" - - /// Standard object's metadata. - /// - /// More info: . - metadata: ObjectMeta? - - /// Represents the configuration of a Restate Cluster - spec: Spec - - status: Dynamic? - - /// Represents the configuration of a Restate Cluster - class Spec { + """ + /// Auto-generated derived type for RestateClusterSpec via `CustomResource` + /// + /// This module was generated from the CustomResourceDefinition at . + module dev.restate.v1.RestateCluster + + extends "@k8s/K8sResource.pkl" + + import "@k8s/apimachinery/pkg/apis/meta/v1/ObjectMeta.pkl" + import "@k8s/api/core/v1/EnvVar.pkl" + import "@k8s/api/core/v1/ResourceRequirements.pkl" + import "@k8s/api/networking/v1/NetworkPolicy.pkl" + + fixed apiVersion: "restate.dev/v1" + + fixed kind: "RestateCluster" + + /// Standard object's metadata. + /// + /// More info: . + metadata: ObjectMeta? + + /// Represents the configuration of a Restate Cluster + spec: Spec + + status: Dynamic? + + /// Represents the configuration of a Restate Cluster + class Spec { + /// Compute configuration + compute: SpecCompute + + /// Security configuration + security: SpecSecurity? + + /// Storage configuration + storage: SpecStorage + } + /// Compute configuration - compute: Compute - - /// Security configuration - security: Security? - - /// Storage configuration - storage: Storage - } - - /// Compute configuration - class Compute { - /// List of environment variables to set in the container; these may override defaults - env: Listing? - - /// Container image name. More info: https://kubernetes.io/docs/concepts/containers/images. - image: String - - /// Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is - /// specified, or IfNotPresent otherwise. More info: - /// https://kubernetes.io/docs/concepts/containers/images#updating-images - imagePullPolicy: String? - - /// replicas is the desired number of Restate nodes. If unspecified, defaults to 1. - replicas: Int? - - /// Compute Resources for the Restate container. More info: - /// https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - resources: ResourceRequirements? + class SpecCompute { + /// List of environment variables to set in the container; these may override defaults + env: Listing? - /// Test nested objects field collision. - redObject: RedObject? + /// Container image name. More info: https://kubernetes.io/docs/concepts/containers/images. + image: String + + /// Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is + /// specified, or IfNotPresent otherwise. More info: + /// https://kubernetes.io/docs/concepts/containers/images#updating-images + imagePullPolicy: String? + + /// replicas is the desired number of Restate nodes. If unspecified, defaults to 1. + replicas: Int? + + /// Compute Resources for the Restate container. More info: + /// https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + resources: ResourceRequirements? + + /// Test nested objects field collision. + redObject: SpecComputeRedObject? + + /// Test nested objects field collision. + blueObject: SpecComputeBlueObject? + } /// Test nested objects field collision. - blueObject: BlueObject? - } + class SpecComputeRedObject { + /// Nested field. + nestedField: String - /// Test nested objects field collision. - class RedObject { - /// Nested field. - nestedField: String + /// Nested child object. + nestedObject: SpecComputeRedObjectNestedObject? + + /// Nested list object red. + nestedList: Listing? + } /// Nested child object. - nestedObject: NestedObject? + class SpecComputeRedObjectNestedObject { + /// Nested field. + nestedRed: String? + } - /// Nested list object red. - nestedList: Listing? - } + /// Red nested object test items. + class SpecComputeRedObjectNestedListNestedList { + /// Red nested list field. + nestedListItemField: String? + } - /// Nested child object. - class NestedObject { - /// Nested field. - nestedRed: String? - } + /// Test nested objects field collision. + class SpecComputeBlueObject { + /// Nested field. + nestedField: String - /// Red nested object test items. - class NestedList { - /// Red nested list field. - nestedListItemField: String? - } + /// Nested child object. + nestedObject: SpecComputeBlueObjectNestedObject? - /// Test nested objects field collision. - class BlueObject { - /// Nested field. - nestedField: String + /// Nested list object blue. + nestedList: Listing? + } /// Nested child object. - nestedObject: NestedObject? - - /// Nested list object blue. - nestedList: Listing? - } - - /// Nested child object. - class NestedObject { - /// Nested field. - nestedBlue: String? - } - - /// Blue nested object test items. - class NestedList { - /// Blue nested list field. - nestedListItemField: String? - } - - /// Security configuration - class Security { - /// if set, create a AWS PodIdentityAssociation using the ACK CRD in order to give the Restate pod - /// access to this role - awsPodIdentityAssociationRoleArn: String? - + class SpecComputeBlueObjectNestedObject { + /// Nested field. + nestedBlue: String? + } + + /// Blue nested object test items. + class SpecComputeBlueObjectNestedListNestedList { + /// Blue nested list field. + nestedListItemField: String? + } + + /// Security configuration + class SpecSecurity { + /// if set, create a AWS PodIdentityAssociation using the ACK CRD in order to give the Restate pod + /// access to this role + awsPodIdentityAssociationRoleArn: String? + + /// Network peers to allow access to restate ports If unset, will not allow any new traffic. Set any of + /// these to [] to allow all traffic - not recommended. + networkPeers: SpecSecurityNetworkPeers? + + serviceAccountAnnotations: Mapping? + + serviceAnnotations: Mapping? + } + /// Network peers to allow access to restate ports If unset, will not allow any new traffic. Set any of /// these to [] to allow all traffic - not recommended. - networkPeers: NetworkPeers? - - serviceAccountAnnotations: Mapping? - - serviceAnnotations: Mapping? - } - - /// Network peers to allow access to restate ports If unset, will not allow any new traffic. Set any of - /// these to [] to allow all traffic - not recommended. - class NetworkPeers { - admin: Listing? - - ingress: Listing? - - metrics: Listing? - } - - /// Storage configuration - class Storage { - /// storageClassName is the name of the StorageClass required by the claim. More info: - /// https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1 this field is immutable - storageClassName: String? - - /// storageRequestBytes is the amount of storage to request in volume claims. It is allowed to increase - /// but not decrease. - storageRequestBytes: Int(this >= 1.0) - } - - """ + class SpecSecurityNetworkPeers { + admin: Listing? + + ingress: Listing? + + metrics: Listing? + } + + /// Storage configuration + class SpecStorage { + /// storageClassName is the name of the StorageClass required by the claim. More info: + /// https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1 this field is immutable + storageClassName: String? + + /// storageRequestBytes is the amount of storage to request in volume claims. It is allowed to increase + /// but not decrease. + storageRequestBytes: Int(this >= 1.0) + } + + """ } ["RestateCluster.pkl.pkl -- different version of k8s"] { - """ - /// Auto-generated derived type for RestateClusterSpec via `CustomResource` - /// - /// This module was generated from the CustomResourceDefinition at . - module dev.restate.v1.RestateCluster - - extends "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.1.0/K8sResource.pkl" - - import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.1.0/apimachinery/pkg/apis/meta/v1/ObjectMeta.pkl" - import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.1.0/api/core/v1/EnvVar.pkl" - import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.1.0/api/core/v1/ResourceRequirements.pkl" - import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.1.0/api/networking/v1/NetworkPolicy.pkl" - - fixed apiVersion: "restate.dev/v1" - - fixed kind: "RestateCluster" - - /// Standard object's metadata. - /// - /// More info: . - metadata: ObjectMeta? - - /// Represents the configuration of a Restate Cluster - spec: Spec - - status: Dynamic? - - /// Represents the configuration of a Restate Cluster - class Spec { + """ + /// Auto-generated derived type for RestateClusterSpec via `CustomResource` + /// + /// This module was generated from the CustomResourceDefinition at . + module dev.restate.v1.RestateCluster + + extends "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.1.0/K8sResource.pkl" + + import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.1.0/apimachinery/pkg/apis/meta/v1/ObjectMeta.pkl" + import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.1.0/api/core/v1/EnvVar.pkl" + import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.1.0/api/core/v1/ResourceRequirements.pkl" + import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.1.0/api/networking/v1/NetworkPolicy.pkl" + + fixed apiVersion: "restate.dev/v1" + + fixed kind: "RestateCluster" + + /// Standard object's metadata. + /// + /// More info: . + metadata: ObjectMeta? + + /// Represents the configuration of a Restate Cluster + spec: Spec + + status: Dynamic? + + /// Represents the configuration of a Restate Cluster + class Spec { + /// Compute configuration + compute: SpecCompute + + /// Security configuration + security: SpecSecurity? + + /// Storage configuration + storage: SpecStorage + } + /// Compute configuration - compute: Compute - - /// Security configuration - security: Security? - - /// Storage configuration - storage: Storage - } - - /// Compute configuration - class Compute { - /// List of environment variables to set in the container; these may override defaults - env: Listing? - - /// Container image name. More info: https://kubernetes.io/docs/concepts/containers/images. - image: String - - /// Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is - /// specified, or IfNotPresent otherwise. More info: - /// https://kubernetes.io/docs/concepts/containers/images#updating-images - imagePullPolicy: String? - - /// replicas is the desired number of Restate nodes. If unspecified, defaults to 1. - replicas: Int? - - /// Compute Resources for the Restate container. More info: - /// https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - resources: ResourceRequirements? + class SpecCompute { + /// List of environment variables to set in the container; these may override defaults + env: Listing? - /// Test nested objects field collision. - redObject: RedObject? + /// Container image name. More info: https://kubernetes.io/docs/concepts/containers/images. + image: String + + /// Image pull policy. One of Always, Never, IfNotPresent. Defaults to Always if :latest tag is + /// specified, or IfNotPresent otherwise. More info: + /// https://kubernetes.io/docs/concepts/containers/images#updating-images + imagePullPolicy: String? + + /// replicas is the desired number of Restate nodes. If unspecified, defaults to 1. + replicas: Int? + + /// Compute Resources for the Restate container. More info: + /// https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + resources: ResourceRequirements? + + /// Test nested objects field collision. + redObject: SpecComputeRedObject? + + /// Test nested objects field collision. + blueObject: SpecComputeBlueObject? + } /// Test nested objects field collision. - blueObject: BlueObject? - } + class SpecComputeRedObject { + /// Nested field. + nestedField: String - /// Test nested objects field collision. - class RedObject { - /// Nested field. - nestedField: String + /// Nested child object. + nestedObject: SpecComputeRedObjectNestedObject? + + /// Nested list object red. + nestedList: Listing? + } /// Nested child object. - nestedObject: NestedObject? + class SpecComputeRedObjectNestedObject { + /// Nested field. + nestedRed: String? + } - /// Nested list object red. - nestedList: Listing? - } + /// Red nested object test items. + class SpecComputeRedObjectNestedListNestedList { + /// Red nested list field. + nestedListItemField: String? + } - /// Nested child object. - class NestedObject { - /// Nested field. - nestedRed: String? - } + /// Test nested objects field collision. + class SpecComputeBlueObject { + /// Nested field. + nestedField: String - /// Red nested object test items. - class NestedList { - /// Red nested list field. - nestedListItemField: String? - } + /// Nested child object. + nestedObject: SpecComputeBlueObjectNestedObject? - /// Test nested objects field collision. - class BlueObject { - /// Nested field. - nestedField: String + /// Nested list object blue. + nestedList: Listing? + } /// Nested child object. - nestedObject: NestedObject? - - /// Nested list object blue. - nestedList: Listing? - } - - /// Nested child object. - class NestedObject { - /// Nested field. - nestedBlue: String? - } - - /// Blue nested object test items. - class NestedList { - /// Blue nested list field. - nestedListItemField: String? - } - - /// Security configuration - class Security { - /// if set, create a AWS PodIdentityAssociation using the ACK CRD in order to give the Restate pod - /// access to this role - awsPodIdentityAssociationRoleArn: String? - + class SpecComputeBlueObjectNestedObject { + /// Nested field. + nestedBlue: String? + } + + /// Blue nested object test items. + class SpecComputeBlueObjectNestedListNestedList { + /// Blue nested list field. + nestedListItemField: String? + } + + /// Security configuration + class SpecSecurity { + /// if set, create a AWS PodIdentityAssociation using the ACK CRD in order to give the Restate pod + /// access to this role + awsPodIdentityAssociationRoleArn: String? + + /// Network peers to allow access to restate ports If unset, will not allow any new traffic. Set any of + /// these to [] to allow all traffic - not recommended. + networkPeers: SpecSecurityNetworkPeers? + + serviceAccountAnnotations: Mapping? + + serviceAnnotations: Mapping? + } + /// Network peers to allow access to restate ports If unset, will not allow any new traffic. Set any of /// these to [] to allow all traffic - not recommended. - networkPeers: NetworkPeers? - - serviceAccountAnnotations: Mapping? - - serviceAnnotations: Mapping? - } - - /// Network peers to allow access to restate ports If unset, will not allow any new traffic. Set any of - /// these to [] to allow all traffic - not recommended. - class NetworkPeers { - admin: Listing? - - ingress: Listing? - - metrics: Listing? - } - - /// Storage configuration - class Storage { - /// storageClassName is the name of the StorageClass required by the claim. More info: - /// https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1 this field is immutable - storageClassName: String? - - /// storageRequestBytes is the amount of storage to request in volume claims. It is allowed to increase - /// but not decrease. - storageRequestBytes: Int(this >= 1.0) - } - - """ + class SpecSecurityNetworkPeers { + admin: Listing? + + ingress: Listing? + + metrics: Listing? + } + + /// Storage configuration + class SpecStorage { + /// storageClassName is the name of the StorageClass required by the claim. More info: + /// https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1 this field is immutable + storageClassName: String? + + /// storageRequestBytes is the amount of storage to request in volume claims. It is allowed to increase + /// but not decrease. + storageRequestBytes: Int(this >= 1.0) + } + + """ } } From 9916a716659a42f9d9de5f813eecfdb28ee41ae9 Mon Sep 17 00:00:00 2001 From: ichekrygin Date: Mon, 7 Oct 2024 16:52:57 -0700 Subject: [PATCH 3/3] Bump major version for k8s.contrib.crd package. --- packages/k8s.contrib.crd/PklProject | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/k8s.contrib.crd/PklProject b/packages/k8s.contrib.crd/PklProject index e460406..11c497c 100644 --- a/packages/k8s.contrib.crd/PklProject +++ b/packages/k8s.contrib.crd/PklProject @@ -29,5 +29,5 @@ dependencies { } package { - version = "1.0.12" + version = "2.0.0" }