diff --git a/go.mod b/go.mod index 6664ff0..239acef 100644 --- a/go.mod +++ b/go.mod @@ -13,6 +13,7 @@ require ( github.com/go-openapi/validate v0.21.0 github.com/jessevdk/go-flags v1.5.0 github.com/kr/pretty v0.3.0 + github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.7.1 gopkg.in/yaml.v2 v2.4.0 k8s.io/apiextensions-apiserver v0.24.1 diff --git a/go.sum b/go.sum index a94e735..1423296 100644 --- a/go.sum +++ b/go.sum @@ -425,6 +425,7 @@ github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/pkg/kube_resource/generator/testdata/array_branch/models/operator_victoriametrics_com_v1beta1_vm_agent.k b/pkg/kube_resource/generator/testdata/array_branch/models/operator_victoriametrics_com_v1beta1_vm_agent.k index 1f233e1..211eeb4 100644 --- a/pkg/kube_resource/generator/testdata/array_branch/models/operator_victoriametrics_com_v1beta1_vm_agent.k +++ b/pkg/kube_resource/generator/testdata/array_branch/models/operator_victoriametrics_com_v1beta1_vm_agent.k @@ -878,8 +878,8 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecClaimTemplatesItems0SpecResou check: - all _, n in limits { regex.match(str(n), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") } if limits - all _, n in requests { regex.match(str(n), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") } if requests + all _, limits in limits {regex.match(str(limits), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if limits } if limits + all _, requests in requests {regex.match(str(requests), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if requests } if requests schema OperatorVictoriametricsComV1beta1VMAgentSpecClaimTemplatesItems0SpecSelector: @@ -957,8 +957,8 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecClaimTemplatesItems0Status: check: - all _, n in allocatedResources { regex.match(str(n), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") } if allocatedResources - all _, n in capacity { regex.match(str(n), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") } if capacity + all _, allocatedResources in allocatedResources {regex.match(str(allocatedResources), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if allocatedResources } if allocatedResources + all _, capacity in capacity {regex.match(str(capacity), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if capacity } if capacity schema OperatorVictoriametricsComV1beta1VMAgentSpecClaimTemplatesItems0StatusConditionsItems0: @@ -2475,8 +2475,8 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecResources: check: - all _, n in limits { regex.match(str(n), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") } if limits - all _, n in requests { regex.match(str(n), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") } if requests + all _, limits in limits {regex.match(str(limits), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if limits } if limits + all _, requests in requests {regex.match(str(requests), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if requests } if requests schema OperatorVictoriametricsComV1beta1VMAgentSpecRollingUpdate: @@ -2876,8 +2876,8 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecStatefulStorageVolumeClaimTem check: - all _, n in limits { regex.match(str(n), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") } if limits - all _, n in requests { regex.match(str(n), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") } if requests + all _, limits in limits {regex.match(str(limits), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if limits } if limits + all _, requests in requests {regex.match(str(requests), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if requests } if requests schema OperatorVictoriametricsComV1beta1VMAgentSpecStatefulStorageVolumeClaimTemplateSpecSelector: @@ -2955,8 +2955,8 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecStatefulStorageVolumeClaimTem check: - all _, n in allocatedResources { regex.match(str(n), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") } if allocatedResources - all _, n in capacity { regex.match(str(n), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") } if capacity + all _, allocatedResources in allocatedResources {regex.match(str(allocatedResources), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if allocatedResources } if allocatedResources + all _, capacity in capacity {regex.match(str(capacity), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if capacity } if capacity schema OperatorVictoriametricsComV1beta1VMAgentSpecStatefulStorageVolumeClaimTemplateStatusConditionsItems0: diff --git a/pkg/kube_resource/generator/testdata/default_value/crossplane_io_compositions.yaml b/pkg/kube_resource/generator/testdata/default_value/crossplane_io_compositions.yaml new file mode 100644 index 0000000..800b5f4 --- /dev/null +++ b/pkg/kube_resource/generator/testdata/default_value/crossplane_io_compositions.yaml @@ -0,0 +1,1540 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.14.0 + name: compositions.apiextensions.crossplane.io +spec: + group: apiextensions.crossplane.io + names: + categories: + - crossplane + kind: Composition + listKind: CompositionList + plural: compositions + shortNames: + - comp + singular: composition + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .spec.compositeTypeRef.kind + name: XR-KIND + type: string + - jsonPath: .spec.compositeTypeRef.apiVersion + name: XR-APIVERSION + type: string + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1 + schema: + openAPIV3Schema: + description: A Composition specifies how a composite resource should be composed. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: CompositionSpec specifies desired state of a composition. + properties: + compositeTypeRef: + description: |- + CompositeTypeRef specifies the type of composite resource that this + composition is compatible with. + properties: + apiVersion: + description: APIVersion of the type. + type: string + kind: + description: Kind of the type. + type: string + required: + - apiVersion + - kind + type: object + environment: + description: |- + Environment configures the environment in which resources are rendered. + + + THIS IS AN ALPHA FIELD. Do not use it in production. It is not honored + unless the relevant Crossplane feature flag is enabled, and may be + changed or removed without notice. + properties: + defaultData: + additionalProperties: + x-kubernetes-preserve-unknown-fields: true + description: |- + DefaultData statically defines the initial state of the environment. + It has the same schema-less structure as the data field in + environment configs. + It is overwritten by the selected environment configs. + type: object + environmentConfigs: + description: |- + EnvironmentConfigs selects a list of `EnvironmentConfig`s. The resolved + resources are stored in the composite resource at + `spec.environmentConfigRefs` and is only updated if it is null. + + + The list of references is used to compute an in-memory environment at + compose time. The data of all object is merged in the order they are + listed, meaning the values of EnvironmentConfigs with a larger index take + priority over ones with smaller indices. + + + The computed environment can be accessed in a composition using + `FromEnvironmentFieldPath` and `CombineFromEnvironment` patches. + items: + description: EnvironmentSource selects a EnvironmentConfig resource. + properties: + ref: + description: |- + Ref is a named reference to a single EnvironmentConfig. + Either Ref or Selector is required. + properties: + name: + description: The name of the object. + type: string + required: + - name + type: object + selector: + description: Selector selects EnvironmentConfig(s) via labels. + properties: + matchLabels: + description: MatchLabels ensures an object with matching + labels is selected. + items: + description: |- + An EnvironmentSourceSelectorLabelMatcher acts like a k8s label selector but + can draw the label value from a different path. + properties: + fromFieldPathPolicy: + default: Required + description: |- + FromFieldPathPolicy specifies the policy for the valueFromFieldPath. + The default is Required, meaning that an error will be returned if the + field is not found in the composite resource. + Optional means that if the field is not found in the composite resource, + that label pair will just be skipped. N.B. other specified label + matchers will still be used to retrieve the desired + environment config, if any. + enum: + - Optional + - Required + type: string + key: + description: Key of the label to match. + type: string + type: + default: FromCompositeFieldPath + description: Type specifies where the value for + a label comes from. + enum: + - FromCompositeFieldPath + - Value + type: string + value: + description: Value specifies a literal label value. + type: string + valueFromFieldPath: + description: ValueFromFieldPath specifies the + field path to look for the label value. + type: string + required: + - key + type: object + type: array + maxMatch: + description: MaxMatch specifies the number of extracted + EnvironmentConfigs in Multiple mode, extracts all + if nil. + format: int64 + type: integer + minMatch: + description: MinMatch specifies the required minimum + of extracted EnvironmentConfigs in Multiple mode. + format: int64 + type: integer + mode: + default: Single + description: 'Mode specifies retrieval strategy: "Single" + or "Multiple".' + enum: + - Single + - Multiple + type: string + sortByFieldPath: + default: metadata.name + description: SortByFieldPath is the path to the field + based on which list of EnvironmentConfigs is alphabetically + sorted. + type: string + type: object + type: + default: Reference + description: |- + Type specifies the way the EnvironmentConfig is selected. + Default is `Reference` + enum: + - Reference + - Selector + type: string + type: object + type: array + patches: + description: |- + Patches is a list of environment patches that are executed before a + composition's resources are composed. + items: + description: EnvironmentPatch is a patch for a Composition environment. + properties: + combine: + description: |- + Combine is the patch configuration for a CombineFromComposite or + CombineToComposite patch. + properties: + strategy: + description: |- + Strategy defines the strategy to use to combine the input variable values. + Currently only string is supported. + enum: + - string + type: string + string: + description: |- + String declares that input variables should be combined into a single + string, using the relevant settings for formatting purposes. + properties: + fmt: + description: |- + Format the input using a Go format string. See + https://golang.org/pkg/fmt/ for details. + type: string + required: + - fmt + type: object + variables: + description: |- + Variables are the list of variables whose values will be retrieved and + combined. + items: + description: |- + A CombineVariable defines the source of a value that is combined with + others to form and patch an output value. Currently, this only supports + retrieving values from a field path. + properties: + fromFieldPath: + description: |- + FromFieldPath is the path of the field on the source whose value is + to be used as input. + type: string + required: + - fromFieldPath + type: object + minItems: 1 + type: array + required: + - strategy + - variables + type: object + fromFieldPath: + description: |- + FromFieldPath is the path of the field on the resource whose value is + to be used as input. Required when type is FromCompositeFieldPath or + ToCompositeFieldPath. + type: string + policy: + description: Policy configures the specifics of patching + behaviour. + properties: + fromFieldPath: + description: |- + FromFieldPath specifies how to patch from a field path. The default is + 'Optional', which means the patch will be a no-op if the specified + fromFieldPath does not exist. Use 'Required' if the patch should fail if + the specified path does not exist. + enum: + - Optional + - Required + type: string + mergeOptions: + description: MergeOptions Specifies merge options on + a field path + properties: + appendSlice: + description: Specifies that already existing elements + in a merged slice should be preserved + type: boolean + keepMapValues: + description: Specifies that already existing values + in a merged map should be preserved + type: boolean + type: object + type: object + toFieldPath: + description: |- + ToFieldPath is the path of the field on the resource whose value will + be changed with the result of transforms. Leave empty if you'd like to + propagate to the same path as fromFieldPath. + type: string + transforms: + description: |- + Transforms are the list of functions that are used as a FIFO pipe for the + input to be transformed. + items: + description: |- + Transform is a unit of process whose input is transformed into an output with + the supplied configuration. + properties: + convert: + description: Convert is used to cast the input into + the given output type. + properties: + format: + description: |- + The expected input format. + + + * `quantity` - parses the input as a K8s [`resource.Quantity`](https://pkg.go.dev/k8s.io/apimachinery/pkg/api/resource#Quantity). + Only used during `string -> float64` conversions. + * `json` - parses the input as a JSON string. + Only used during `string -> object` or `string -> list` conversions. + + + If this property is null, the default conversion is applied. + enum: + - none + - quantity + - json + type: string + toType: + description: ToType is the type of the output + of this transform. + enum: + - string + - int + - int64 + - bool + - float64 + - object + - array + type: string + required: + - toType + type: object + map: + additionalProperties: + x-kubernetes-preserve-unknown-fields: true + description: Map uses the input as a key in the given + map and returns the value. + type: object + match: + description: Match is a more complex version of Map + that matches a list of patterns. + properties: + fallbackTo: + default: Value + description: Determines to what value the transform + should fallback if no pattern matches. + enum: + - Value + - Input + type: string + fallbackValue: + description: |- + The fallback value that should be returned by the transform if now pattern + matches. + x-kubernetes-preserve-unknown-fields: true + patterns: + description: |- + The patterns that should be tested against the input string. + Patterns are tested in order. The value of the first match is used as + result of this transform. + items: + description: |- + MatchTransformPattern is a transform that returns the value that matches a + pattern. + properties: + literal: + description: |- + Literal exactly matches the input string (case sensitive). + Is required if `type` is `literal`. + type: string + regexp: + description: |- + Regexp to match against the input string. + Is required if `type` is `regexp`. + type: string + result: + description: The value that is used as result + of the transform if the pattern matches. + x-kubernetes-preserve-unknown-fields: true + type: + default: literal + description: |- + Type specifies how the pattern matches the input. + + + * `literal` - the pattern value has to exactly match (case sensitive) the + input string. This is the default. + + + * `regexp` - the pattern treated as a regular expression against + which the input string is tested. Crossplane will throw an error if the + key is not a valid regexp. + enum: + - literal + - regexp + type: string + required: + - result + - type + type: object + type: array + type: object + math: + description: |- + Math is used to transform the input via mathematical operations such as + multiplication. + properties: + clampMax: + description: ClampMax makes sure that the value + is not bigger than the given value. + format: int64 + type: integer + clampMin: + description: ClampMin makes sure that the value + is not smaller than the given value. + format: int64 + type: integer + multiply: + description: Multiply the value. + format: int64 + type: integer + type: + default: Multiply + description: Type of the math transform to be + run. + enum: + - Multiply + - ClampMin + - ClampMax + type: string + type: object + string: + description: |- + String is used to transform the input into a string or a different kind + of string. Note that the input does not necessarily need to be a string. + properties: + convert: + description: |- + Optional conversion method to be specified. + `ToUpper` and `ToLower` change the letter case of the input string. + `ToBase64` and `FromBase64` perform a base64 conversion based on the input string. + `ToJson` converts any input value into its raw JSON representation. + `ToSha1`, `ToSha256` and `ToSha512` generate a hash value based on the input + converted to JSON. + enum: + - ToUpper + - ToLower + - ToBase64 + - FromBase64 + - ToJson + - ToSha1 + - ToSha256 + - ToSha512 + type: string + fmt: + description: |- + Format the input using a Go format string. See + https://golang.org/pkg/fmt/ for details. + type: string + join: + description: Join defines parameters to join a + slice of values to a string. + properties: + separator: + description: |- + Separator defines the character that should separate the values from each + other in the joined string. + type: string + required: + - separator + type: object + regexp: + description: Extract a match from the input using + a regular expression. + properties: + group: + description: Group number to match. 0 (the + default) matches the entire expression. + type: integer + match: + description: |- + Match string. May optionally include submatches, aka capture groups. + See https://pkg.go.dev/regexp/ for details. + type: string + required: + - match + type: object + trim: + description: Trim the prefix or suffix from the + input + type: string + type: + default: Format + description: Type of the string transform to be + run. + enum: + - Format + - Convert + - TrimPrefix + - TrimSuffix + - Regexp + - Join + type: string + type: object + type: + description: Type of the transform to be run. + enum: + - map + - match + - math + - string + - convert + type: string + required: + - type + type: object + type: array + type: + default: FromCompositeFieldPath + description: |- + Type sets the patching behaviour to be used. Each patch type may require + its own fields to be set on the Patch object. + enum: + - FromCompositeFieldPath + - ToCompositeFieldPath + - CombineFromComposite + - CombineToComposite + type: string + type: object + type: array + policy: + description: |- + Policy represents the Resolve and Resolution policies which apply to + all EnvironmentSourceReferences in EnvironmentConfigs list. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object + mode: + default: Resources + description: |- + Mode controls what type or "mode" of Composition will be used. + + + "Resources" (the default) indicates that a Composition uses what is + commonly referred to as "Patch & Transform" or P&T composition. This mode + of Composition uses an array of resources, each a template for a composed + resource. + + + "Pipeline" indicates that a Composition specifies a pipeline + of Composition Functions, each of which is responsible for producing + composed resources that Crossplane should create or update. THE PIPELINE + MODE IS A BETA FEATURE. It is not honored if the relevant Crossplane + feature flag is disabled. + enum: + - Resources + - Pipeline + type: string + patchSets: + description: |- + PatchSets define a named set of patches that may be included by any + resource in this Composition. PatchSets cannot themselves refer to other + PatchSets. + + + PatchSets are only used by the "Resources" mode of Composition. They + are ignored by other modes. + items: + description: |- + A PatchSet is a set of patches that can be reused from all resources within + a Composition. + properties: + name: + description: Name of this PatchSet. + type: string + patches: + description: Patches will be applied as an overlay to the base + resource. + items: + description: |- + Patch objects are applied between composite and composed resources. Their + behaviour depends on the Type selected. The default Type, + FromCompositeFieldPath, copies a value from the composite resource to + the composed resource, applying any defined transformers. + properties: + combine: + description: |- + Combine is the patch configuration for a CombineFromComposite, + CombineFromEnvironment, CombineToComposite or CombineToEnvironment patch. + properties: + strategy: + description: |- + Strategy defines the strategy to use to combine the input variable values. + Currently only string is supported. + enum: + - string + type: string + string: + description: |- + String declares that input variables should be combined into a single + string, using the relevant settings for formatting purposes. + properties: + fmt: + description: |- + Format the input using a Go format string. See + https://golang.org/pkg/fmt/ for details. + type: string + required: + - fmt + type: object + variables: + description: |- + Variables are the list of variables whose values will be retrieved and + combined. + items: + description: |- + A CombineVariable defines the source of a value that is combined with + others to form and patch an output value. Currently, this only supports + retrieving values from a field path. + properties: + fromFieldPath: + description: |- + FromFieldPath is the path of the field on the source whose value is + to be used as input. + type: string + required: + - fromFieldPath + type: object + minItems: 1 + type: array + required: + - strategy + - variables + type: object + fromFieldPath: + description: |- + FromFieldPath is the path of the field on the resource whose value is + to be used as input. Required when type is FromCompositeFieldPath, + FromEnvironmentFieldPath, ToCompositeFieldPath, ToEnvironmentFieldPath. + type: string + patchSetName: + description: PatchSetName to include patches from. Required + when type is PatchSet. + type: string + policy: + description: Policy configures the specifics of patching + behaviour. + properties: + fromFieldPath: + description: |- + FromFieldPath specifies how to patch from a field path. The default is + 'Optional', which means the patch will be a no-op if the specified + fromFieldPath does not exist. Use 'Required' if the patch should fail if + the specified path does not exist. + enum: + - Optional + - Required + type: string + mergeOptions: + description: MergeOptions Specifies merge options + on a field path + properties: + appendSlice: + description: Specifies that already existing elements + in a merged slice should be preserved + type: boolean + keepMapValues: + description: Specifies that already existing values + in a merged map should be preserved + type: boolean + type: object + type: object + toFieldPath: + description: |- + ToFieldPath is the path of the field on the resource whose value will + be changed with the result of transforms. Leave empty if you'd like to + propagate to the same path as fromFieldPath. + type: string + transforms: + description: |- + Transforms are the list of functions that are used as a FIFO pipe for the + input to be transformed. + items: + description: |- + Transform is a unit of process whose input is transformed into an output with + the supplied configuration. + properties: + convert: + description: Convert is used to cast the input into + the given output type. + properties: + format: + description: |- + The expected input format. + + + * `quantity` - parses the input as a K8s [`resource.Quantity`](https://pkg.go.dev/k8s.io/apimachinery/pkg/api/resource#Quantity). + Only used during `string -> float64` conversions. + * `json` - parses the input as a JSON string. + Only used during `string -> object` or `string -> list` conversions. + + + If this property is null, the default conversion is applied. + enum: + - none + - quantity + - json + type: string + toType: + description: ToType is the type of the output + of this transform. + enum: + - string + - int + - int64 + - bool + - float64 + - object + - array + type: string + required: + - toType + type: object + map: + additionalProperties: + x-kubernetes-preserve-unknown-fields: true + description: Map uses the input as a key in the + given map and returns the value. + type: object + match: + description: Match is a more complex version of + Map that matches a list of patterns. + properties: + fallbackTo: + default: Value + description: Determines to what value the transform + should fallback if no pattern matches. + enum: + - Value + - Input + type: string + fallbackValue: + description: |- + The fallback value that should be returned by the transform if now pattern + matches. + x-kubernetes-preserve-unknown-fields: true + patterns: + description: |- + The patterns that should be tested against the input string. + Patterns are tested in order. The value of the first match is used as + result of this transform. + items: + description: |- + MatchTransformPattern is a transform that returns the value that matches a + pattern. + properties: + literal: + description: |- + Literal exactly matches the input string (case sensitive). + Is required if `type` is `literal`. + type: string + regexp: + description: |- + Regexp to match against the input string. + Is required if `type` is `regexp`. + type: string + result: + description: The value that is used as + result of the transform if the pattern + matches. + x-kubernetes-preserve-unknown-fields: true + type: + default: literal + description: |- + Type specifies how the pattern matches the input. + + + * `literal` - the pattern value has to exactly match (case sensitive) the + input string. This is the default. + + + * `regexp` - the pattern treated as a regular expression against + which the input string is tested. Crossplane will throw an error if the + key is not a valid regexp. + enum: + - literal + - regexp + type: string + required: + - result + - type + type: object + type: array + type: object + math: + description: |- + Math is used to transform the input via mathematical operations such as + multiplication. + properties: + clampMax: + description: ClampMax makes sure that the value + is not bigger than the given value. + format: int64 + type: integer + clampMin: + description: ClampMin makes sure that the value + is not smaller than the given value. + format: int64 + type: integer + multiply: + description: Multiply the value. + format: int64 + type: integer + type: + default: Multiply + description: Type of the math transform to be + run. + enum: + - Multiply + - ClampMin + - ClampMax + type: string + type: object + string: + description: |- + String is used to transform the input into a string or a different kind + of string. Note that the input does not necessarily need to be a string. + properties: + convert: + description: |- + Optional conversion method to be specified. + `ToUpper` and `ToLower` change the letter case of the input string. + `ToBase64` and `FromBase64` perform a base64 conversion based on the input string. + `ToJson` converts any input value into its raw JSON representation. + `ToSha1`, `ToSha256` and `ToSha512` generate a hash value based on the input + converted to JSON. + enum: + - ToUpper + - ToLower + - ToBase64 + - FromBase64 + - ToJson + - ToSha1 + - ToSha256 + - ToSha512 + type: string + fmt: + description: |- + Format the input using a Go format string. See + https://golang.org/pkg/fmt/ for details. + type: string + join: + description: Join defines parameters to join + a slice of values to a string. + properties: + separator: + description: |- + Separator defines the character that should separate the values from each + other in the joined string. + type: string + required: + - separator + type: object + regexp: + description: Extract a match from the input + using a regular expression. + properties: + group: + description: Group number to match. 0 (the + default) matches the entire expression. + type: integer + match: + description: |- + Match string. May optionally include submatches, aka capture groups. + See https://pkg.go.dev/regexp/ for details. + type: string + required: + - match + type: object + trim: + description: Trim the prefix or suffix from + the input + type: string + type: + default: Format + description: Type of the string transform to + be run. + enum: + - Format + - Convert + - TrimPrefix + - TrimSuffix + - Regexp + - Join + type: string + type: object + type: + description: Type of the transform to be run. + enum: + - map + - match + - math + - string + - convert + type: string + required: + - type + type: object + type: array + type: + default: FromCompositeFieldPath + description: |- + Type sets the patching behaviour to be used. Each patch type may require + its own fields to be set on the Patch object. + enum: + - FromCompositeFieldPath + - FromEnvironmentFieldPath + - PatchSet + - ToCompositeFieldPath + - ToEnvironmentFieldPath + - CombineFromEnvironment + - CombineFromComposite + - CombineToComposite + - CombineToEnvironment + type: string + type: object + type: array + required: + - name + - patches + type: object + type: array + pipeline: + description: |- + Pipeline is a list of composition function steps that will be used when a + composite resource referring to this composition is created. One of + resources and pipeline must be specified - you cannot specify both. + + + The Pipeline is only used by the "Pipeline" mode of Composition. It is + ignored by other modes. + + + THIS IS A BETA FIELD. It is not honored if the relevant Crossplane + feature flag is disabled. + items: + description: A PipelineStep in a Composition Function pipeline. + properties: + functionRef: + description: |- + FunctionRef is a reference to the Composition Function this step should + execute. + properties: + name: + description: Name of the referenced Function. + type: string + required: + - name + type: object + input: + description: |- + Input is an optional, arbitrary Kubernetes resource (i.e. a resource + with an apiVersion and kind) that will be passed to the Composition + Function as the 'input' of its RunFunctionRequest. + type: object + x-kubernetes-embedded-resource: true + x-kubernetes-preserve-unknown-fields: true + step: + description: Step name. Must be unique within its Pipeline. + type: string + required: + - functionRef + - step + type: object + type: array + publishConnectionDetailsWithStoreConfigRef: + default: + name: default + description: |- + PublishConnectionDetailsWithStoreConfig specifies the secret store config + with which the connection details of composite resources dynamically + provisioned using this composition will be published. + + + THIS IS AN ALPHA FIELD. Do not use it in production. It is not honored + unless the relevant Crossplane feature flag is enabled, and may be + changed or removed without notice. + properties: + name: + description: Name of the referenced StoreConfig. + type: string + required: + - name + type: object + resources: + description: |- + Resources is a list of resource templates that will be used when a + composite resource referring to this composition is created. + + + Resources are only used by the "Resources" mode of Composition. They are + ignored by other modes. + items: + description: |- + ComposedTemplate is used to provide information about how the composed resource + should be processed. + properties: + base: + description: Base is the target resource that the patches will + be applied on. + type: object + x-kubernetes-embedded-resource: true + x-kubernetes-preserve-unknown-fields: true + connectionDetails: + description: |- + ConnectionDetails lists the propagation secret keys from this target + resource to the composition instance connection secret. + items: + description: |- + ConnectionDetail includes the information about the propagation of the connection + information from one secret to another. + properties: + fromConnectionSecretKey: + description: |- + FromConnectionSecretKey is the key that will be used to fetch the value + from the composed resource's connection secret. + type: string + fromFieldPath: + description: |- + FromFieldPath is the path of the field on the composed resource whose + value to be used as input. Name must be specified if the type is + FromFieldPath. + type: string + name: + description: |- + Name of the connection secret key that will be propagated to the + connection secret of the composition instance. Leave empty if you'd like + to use the same key name. + type: string + type: + description: |- + Type sets the connection detail fetching behaviour to be used. Each + connection detail type may require its own fields to be set on the + ConnectionDetail object. If the type is omitted Crossplane will attempt + to infer it based on which other fields were specified. If multiple + fields are specified the order of precedence is: + 1. FromValue + 2. FromConnectionSecretKey + 3. FromFieldPath + enum: + - FromConnectionSecretKey + - FromFieldPath + - FromValue + type: string + value: + description: |- + Value that will be propagated to the connection secret of the composite + resource. May be set to inject a fixed, non-sensitive connection secret + value, for example a well-known port. + type: string + type: object + type: array + name: + description: |- + A Name uniquely identifies this entry within its Composition's resources + array. Names are optional but *strongly* recommended. When all entries in + the resources array are named entries may added, deleted, and reordered + as long as their names do not change. When entries are not named the + length and order of the resources array should be treated as immutable. + Either all or no entries must be named. + type: string + patches: + description: Patches will be applied as overlay to the base + resource. + items: + description: |- + Patch objects are applied between composite and composed resources. Their + behaviour depends on the Type selected. The default Type, + FromCompositeFieldPath, copies a value from the composite resource to + the composed resource, applying any defined transformers. + properties: + combine: + description: |- + Combine is the patch configuration for a CombineFromComposite, + CombineFromEnvironment, CombineToComposite or CombineToEnvironment patch. + properties: + strategy: + description: |- + Strategy defines the strategy to use to combine the input variable values. + Currently only string is supported. + enum: + - string + type: string + string: + description: |- + String declares that input variables should be combined into a single + string, using the relevant settings for formatting purposes. + properties: + fmt: + description: |- + Format the input using a Go format string. See + https://golang.org/pkg/fmt/ for details. + type: string + required: + - fmt + type: object + variables: + description: |- + Variables are the list of variables whose values will be retrieved and + combined. + items: + description: |- + A CombineVariable defines the source of a value that is combined with + others to form and patch an output value. Currently, this only supports + retrieving values from a field path. + properties: + fromFieldPath: + description: |- + FromFieldPath is the path of the field on the source whose value is + to be used as input. + type: string + required: + - fromFieldPath + type: object + minItems: 1 + type: array + required: + - strategy + - variables + type: object + fromFieldPath: + description: |- + FromFieldPath is the path of the field on the resource whose value is + to be used as input. Required when type is FromCompositeFieldPath, + FromEnvironmentFieldPath, ToCompositeFieldPath, ToEnvironmentFieldPath. + type: string + patchSetName: + description: PatchSetName to include patches from. Required + when type is PatchSet. + type: string + policy: + description: Policy configures the specifics of patching + behaviour. + properties: + fromFieldPath: + description: |- + FromFieldPath specifies how to patch from a field path. The default is + 'Optional', which means the patch will be a no-op if the specified + fromFieldPath does not exist. Use 'Required' if the patch should fail if + the specified path does not exist. + enum: + - Optional + - Required + type: string + mergeOptions: + description: MergeOptions Specifies merge options + on a field path + properties: + appendSlice: + description: Specifies that already existing elements + in a merged slice should be preserved + type: boolean + keepMapValues: + description: Specifies that already existing values + in a merged map should be preserved + type: boolean + type: object + type: object + toFieldPath: + description: |- + ToFieldPath is the path of the field on the resource whose value will + be changed with the result of transforms. Leave empty if you'd like to + propagate to the same path as fromFieldPath. + type: string + transforms: + description: |- + Transforms are the list of functions that are used as a FIFO pipe for the + input to be transformed. + items: + description: |- + Transform is a unit of process whose input is transformed into an output with + the supplied configuration. + properties: + convert: + description: Convert is used to cast the input into + the given output type. + properties: + format: + description: |- + The expected input format. + + + * `quantity` - parses the input as a K8s [`resource.Quantity`](https://pkg.go.dev/k8s.io/apimachinery/pkg/api/resource#Quantity). + Only used during `string -> float64` conversions. + * `json` - parses the input as a JSON string. + Only used during `string -> object` or `string -> list` conversions. + + + If this property is null, the default conversion is applied. + enum: + - none + - quantity + - json + type: string + toType: + description: ToType is the type of the output + of this transform. + enum: + - string + - int + - int64 + - bool + - float64 + - object + - array + type: string + required: + - toType + type: object + map: + additionalProperties: + x-kubernetes-preserve-unknown-fields: true + description: Map uses the input as a key in the + given map and returns the value. + type: object + match: + description: Match is a more complex version of + Map that matches a list of patterns. + properties: + fallbackTo: + default: Value + description: Determines to what value the transform + should fallback if no pattern matches. + enum: + - Value + - Input + type: string + fallbackValue: + description: |- + The fallback value that should be returned by the transform if now pattern + matches. + x-kubernetes-preserve-unknown-fields: true + patterns: + description: |- + The patterns that should be tested against the input string. + Patterns are tested in order. The value of the first match is used as + result of this transform. + items: + description: |- + MatchTransformPattern is a transform that returns the value that matches a + pattern. + properties: + literal: + description: |- + Literal exactly matches the input string (case sensitive). + Is required if `type` is `literal`. + type: string + regexp: + description: |- + Regexp to match against the input string. + Is required if `type` is `regexp`. + type: string + result: + description: The value that is used as + result of the transform if the pattern + matches. + x-kubernetes-preserve-unknown-fields: true + type: + default: literal + description: |- + Type specifies how the pattern matches the input. + + + * `literal` - the pattern value has to exactly match (case sensitive) the + input string. This is the default. + + + * `regexp` - the pattern treated as a regular expression against + which the input string is tested. Crossplane will throw an error if the + key is not a valid regexp. + enum: + - literal + - regexp + type: string + required: + - result + - type + type: object + type: array + type: object + math: + description: |- + Math is used to transform the input via mathematical operations such as + multiplication. + properties: + clampMax: + description: ClampMax makes sure that the value + is not bigger than the given value. + format: int64 + type: integer + clampMin: + description: ClampMin makes sure that the value + is not smaller than the given value. + format: int64 + type: integer + multiply: + description: Multiply the value. + format: int64 + type: integer + type: + default: Multiply + description: Type of the math transform to be + run. + enum: + - Multiply + - ClampMin + - ClampMax + type: string + type: object + string: + description: |- + String is used to transform the input into a string or a different kind + of string. Note that the input does not necessarily need to be a string. + properties: + convert: + description: |- + Optional conversion method to be specified. + `ToUpper` and `ToLower` change the letter case of the input string. + `ToBase64` and `FromBase64` perform a base64 conversion based on the input string. + `ToJson` converts any input value into its raw JSON representation. + `ToSha1`, `ToSha256` and `ToSha512` generate a hash value based on the input + converted to JSON. + enum: + - ToUpper + - ToLower + - ToBase64 + - FromBase64 + - ToJson + - ToSha1 + - ToSha256 + - ToSha512 + type: string + fmt: + description: |- + Format the input using a Go format string. See + https://golang.org/pkg/fmt/ for details. + type: string + join: + description: Join defines parameters to join + a slice of values to a string. + properties: + separator: + description: |- + Separator defines the character that should separate the values from each + other in the joined string. + type: string + required: + - separator + type: object + regexp: + description: Extract a match from the input + using a regular expression. + properties: + group: + description: Group number to match. 0 (the + default) matches the entire expression. + type: integer + match: + description: |- + Match string. May optionally include submatches, aka capture groups. + See https://pkg.go.dev/regexp/ for details. + type: string + required: + - match + type: object + trim: + description: Trim the prefix or suffix from + the input + type: string + type: + default: Format + description: Type of the string transform to + be run. + enum: + - Format + - Convert + - TrimPrefix + - TrimSuffix + - Regexp + - Join + type: string + type: object + type: + description: Type of the transform to be run. + enum: + - map + - match + - math + - string + - convert + type: string + required: + - type + type: object + type: array + type: + default: FromCompositeFieldPath + description: |- + Type sets the patching behaviour to be used. Each patch type may require + its own fields to be set on the Patch object. + enum: + - FromCompositeFieldPath + - FromEnvironmentFieldPath + - PatchSet + - ToCompositeFieldPath + - ToEnvironmentFieldPath + - CombineFromEnvironment + - CombineFromComposite + - CombineToComposite + - CombineToEnvironment + type: string + type: object + type: array + readinessChecks: + default: + - matchCondition: + status: "True" + type: Ready + type: MatchCondition + - matchCondition: + status: "False" + type: MatchCondition + description: |- + ReadinessChecks allows users to define custom readiness checks. All checks + have to return true in order for resource to be considered ready. The + default readiness check is to have the "Ready" condition to be "True". + items: + description: |- + ReadinessCheck is used to indicate how to tell whether a resource is ready + for consumption. + properties: + fieldPath: + description: FieldPath shows the path of the field whose + value will be used. + type: string + matchCondition: + description: MatchCondition specifies the condition you'd + like to match if you're using "MatchCondition" type. + properties: + status: + default: "True" + description: Status is the status of the condition + you'd like to match. + type: string + type: + default: Ready + description: Type indicates the type of condition + you'd like to use. + type: string + required: + - status + - type + type: object + matchInteger: + description: MatchInt is the value you'd like to match + if you're using "MatchInt" type. + format: int64 + type: integer + matchString: + description: MatchString is the value you'd like to match + if you're using "MatchString" type. + type: string + type: + description: Type indicates the type of probe you'd like + to use. + enum: + - MatchString + - MatchInteger + - NonEmpty + - MatchCondition + - MatchTrue + - MatchFalse + - None + type: string + required: + - type + type: object + type: array + required: + - base + type: object + type: array + writeConnectionSecretsToNamespace: + description: |- + WriteConnectionSecretsToNamespace specifies the namespace in which the + connection secrets of composite resource dynamically provisioned using + this composition will be created. + This field is planned to be replaced in a future release in favor of + PublishConnectionDetailsWithStoreConfigRef. Currently, both could be + set independently and connection details would be published to both + without affecting each other as long as related fields at MR level + specified. + type: string + required: + - compositeTypeRef + type: object + type: object + served: true + storage: true + subresources: {} diff --git a/pkg/kube_resource/generator/testdata/default_value/models/apiextensions_crossplane_io_v1_composition.k b/pkg/kube_resource/generator/testdata/default_value/models/apiextensions_crossplane_io_v1_composition.k new file mode 100644 index 0000000..bab759f --- /dev/null +++ b/pkg/kube_resource/generator/testdata/default_value/models/apiextensions_crossplane_io_v1_composition.k @@ -0,0 +1,1642 @@ +""" +This file was generated by the KCL auto-gen tool. DO NOT EDIT. +Editing this file might prove futile when you re-run the KCL auto-gen generate command. +""" +import k8s.apimachinery.pkg.apis.meta.v1 + + +schema Composition: + """ + A Composition specifies how a composite resource should be composed. + + Attributes + ---------- + apiVersion : str, default is "apiextensions.crossplane.io/v1", required + APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + kind : str, default is "Composition", required + Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + metadata : v1.ObjectMeta, default is Undefined, optional + metadata + spec : ApiextensionsCrossplaneIoV1CompositionSpec, default is Undefined, optional + spec + """ + + + apiVersion: "apiextensions.crossplane.io/v1" = "apiextensions.crossplane.io/v1" + + kind: "Composition" = "Composition" + + metadata?: v1.ObjectMeta + + spec?: ApiextensionsCrossplaneIoV1CompositionSpec + + +schema ApiextensionsCrossplaneIoV1CompositionSpec: + """ + CompositionSpec specifies desired state of a composition. + + Attributes + ---------- + mode : str, default is "Resources", optional + Mode controls what type or "mode" of Composition will be used. + + + "Resources" (the default) indicates that a Composition uses what is + commonly referred to as "Patch & Transform" or P&T composition. This mode + of Composition uses an array of resources, each a template for a composed + resource. + + + "Pipeline" indicates that a Composition specifies a pipeline + of Composition Functions, each of which is responsible for producing + composed resources that Crossplane should create or update. THE PIPELINE + MODE IS A BETA FEATURE. It is not honored if the relevant Crossplane + feature flag is disabled. + patchSets : [ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0], default is Undefined, optional + PatchSets define a named set of patches that may be included by any + resource in this Composition. PatchSets cannot themselves refer to other + PatchSets. + + + PatchSets are only used by the "Resources" mode of Composition. They + are ignored by other modes. + pipeline : [ApiextensionsCrossplaneIoV1CompositionSpecPipelineItems0], default is Undefined, optional + Pipeline is a list of composition function steps that will be used when a + composite resource referring to this composition is created. One of + resources and pipeline must be specified - you cannot specify both. + + + The Pipeline is only used by the "Pipeline" mode of Composition. It is + ignored by other modes. + + + THIS IS A BETA FIELD. It is not honored if the relevant Crossplane + feature flag is disabled. + resources : [ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0], default is Undefined, optional + Resources is a list of resource templates that will be used when a + composite resource referring to this composition is created. + + + Resources are only used by the "Resources" mode of Composition. They are + ignored by other modes. + writeConnectionSecretsToNamespace : str, default is Undefined, optional + WriteConnectionSecretsToNamespace specifies the namespace in which the + connection secrets of composite resource dynamically provisioned using + this composition will be created. + This field is planned to be replaced in a future release in favor of + PublishConnectionDetailsWithStoreConfigRef. Currently, both could be + set independently and connection details would be published to both + without affecting each other as long as related fields at MR level + specified. + compositeTypeRef : ApiextensionsCrossplaneIoV1CompositionSpecCompositeTypeRef, default is Undefined, required + composite type ref + environment : ApiextensionsCrossplaneIoV1CompositionSpecEnvironment, default is Undefined, optional + environment + publishConnectionDetailsWithStoreConfigRef : ApiextensionsCrossplaneIoV1CompositionSpecPublishConnectionDetailsWithStoreConfigRef, default is Undefined, optional + publish connection details with store config ref + """ + + + mode?: "Resources" | "Pipeline" = "Resources" + + patchSets?: [ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0] + + pipeline?: [ApiextensionsCrossplaneIoV1CompositionSpecPipelineItems0] + + resources?: [ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0] + + writeConnectionSecretsToNamespace?: str + + compositeTypeRef: ApiextensionsCrossplaneIoV1CompositionSpecCompositeTypeRef + + environment?: ApiextensionsCrossplaneIoV1CompositionSpecEnvironment + + publishConnectionDetailsWithStoreConfigRef?: ApiextensionsCrossplaneIoV1CompositionSpecPublishConnectionDetailsWithStoreConfigRef + + +schema ApiextensionsCrossplaneIoV1CompositionSpecCompositeTypeRef: + """ + CompositeTypeRef specifies the type of composite resource that this + composition is compatible with. + + Attributes + ---------- + apiVersion : str, default is Undefined, required + APIVersion of the type. + kind : str, default is Undefined, required + Kind of the type. + """ + + + apiVersion: str + + kind: str + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironment: + """ + Environment configures the environment in which resources are rendered. + + + THIS IS AN ALPHA FIELD. Do not use it in production. It is not honored + unless the relevant Crossplane feature flag is enabled, and may be + changed or removed without notice. + + Attributes + ---------- + defaultData : {str:any}, default is Undefined, optional + DefaultData statically defines the initial state of the environment. + It has the same schema-less structure as the data field in + environment configs. + It is overwritten by the selected environment configs. + environmentConfigs : [ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentEnvironmentConfigsItems0], default is Undefined, optional + EnvironmentConfigs selects a list of `EnvironmentConfig`s. The resolved + resources are stored in the composite resource at + `spec.environmentConfigRefs` and is only updated if it is null. + + + The list of references is used to compute an in-memory environment at + compose time. The data of all object is merged in the order they are + listed, meaning the values of EnvironmentConfigs with a larger index take + priority over ones with smaller indices. + + + The computed environment can be accessed in a composition using + `FromEnvironmentFieldPath` and `CombineFromEnvironment` patches. + patches : [ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0], default is Undefined, optional + Patches is a list of environment patches that are executed before a + composition's resources are composed. + policy : ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPolicy, default is Undefined, optional + policy + """ + + + defaultData?: {str:any} + + environmentConfigs?: [ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentEnvironmentConfigsItems0] + + patches?: [ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0] + + policy?: ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPolicy + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentEnvironmentConfigsItems0: + """ + EnvironmentSource selects a EnvironmentConfig resource. + + Attributes + ---------- + ref : ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentEnvironmentConfigsItems0Ref, default is Undefined, optional + ref + selector : ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentEnvironmentConfigsItems0Selector, default is Undefined, optional + selector + $type : str, default is "Reference", optional + Type specifies the way the EnvironmentConfig is selected. + Default is `Reference` + """ + + + ref?: ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentEnvironmentConfigsItems0Ref + + selector?: ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentEnvironmentConfigsItems0Selector + + $type?: "Reference" | "Selector" = "Reference" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentEnvironmentConfigsItems0Ref: + """ + Ref is a named reference to a single EnvironmentConfig. + Either Ref or Selector is required. + + Attributes + ---------- + name : str, default is Undefined, required + The name of the object. + """ + + + name: str + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentEnvironmentConfigsItems0Selector: + """ + Selector selects EnvironmentConfig(s) via labels. + + Attributes + ---------- + matchLabels : [ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentEnvironmentConfigsItems0SelectorMatchLabelsItems0], default is Undefined, optional + MatchLabels ensures an object with matching labels is selected. + maxMatch : int, default is Undefined, optional + MaxMatch specifies the number of extracted EnvironmentConfigs in Multiple mode, extracts all if nil. + minMatch : int, default is Undefined, optional + MinMatch specifies the required minimum of extracted EnvironmentConfigs in Multiple mode. + mode : str, default is "Single", optional + Mode specifies retrieval strategy: "Single" or "Multiple". + sortByFieldPath : str, default is "metadata.name", optional + SortByFieldPath is the path to the field based on which list of EnvironmentConfigs is alphabetically sorted. + """ + + + matchLabels?: [ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentEnvironmentConfigsItems0SelectorMatchLabelsItems0] + + maxMatch?: int + + minMatch?: int + + mode?: "Single" | "Multiple" = "Single" + + sortByFieldPath?: str = "metadata.name" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentEnvironmentConfigsItems0SelectorMatchLabelsItems0: + """ + An EnvironmentSourceSelectorLabelMatcher acts like a k8s label selector but + can draw the label value from a different path. + + Attributes + ---------- + fromFieldPathPolicy : str, default is "Required", optional + FromFieldPathPolicy specifies the policy for the valueFromFieldPath. + The default is Required, meaning that an error will be returned if the + field is not found in the composite resource. + Optional means that if the field is not found in the composite resource, + that label pair will just be skipped. N.B. other specified label + matchers will still be used to retrieve the desired + environment config, if any. + key : str, default is Undefined, required + Key of the label to match. + $type : str, default is "FromCompositeFieldPath", optional + Type specifies where the value for a label comes from. + value : str, default is Undefined, optional + Value specifies a literal label value. + valueFromFieldPath : str, default is Undefined, optional + ValueFromFieldPath specifies the field path to look for the label value. + """ + + + fromFieldPathPolicy?: "Optional" | "Required" = "Required" + + key: str + + $type?: "FromCompositeFieldPath" | "Value" = "FromCompositeFieldPath" + + value?: str + + valueFromFieldPath?: str + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0: + """ + EnvironmentPatch is a patch for a Composition environment. + + Attributes + ---------- + combine : ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0Combine, default is Undefined, optional + combine + fromFieldPath : str, default is Undefined, optional + FromFieldPath is the path of the field on the resource whose value is + to be used as input. Required when type is FromCompositeFieldPath or + ToCompositeFieldPath. + policy : ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0Policy, default is Undefined, optional + policy + toFieldPath : str, default is Undefined, optional + ToFieldPath is the path of the field on the resource whose value will + be changed with the result of transforms. Leave empty if you'd like to + propagate to the same path as fromFieldPath. + transforms : [ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0], default is Undefined, optional + Transforms are the list of functions that are used as a FIFO pipe for the + input to be transformed. + $type : str, default is "FromCompositeFieldPath", optional + Type sets the patching behaviour to be used. Each patch type may require + its own fields to be set on the Patch object. + """ + + + combine?: ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0Combine + + fromFieldPath?: str + + policy?: ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0Policy + + toFieldPath?: str + + transforms?: [ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0] + + $type?: "FromCompositeFieldPath" | "ToCompositeFieldPath" | "CombineFromComposite" | "CombineToComposite" = "FromCompositeFieldPath" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0Combine: + """ + Combine is the patch configuration for a CombineFromComposite or + CombineToComposite patch. + + Attributes + ---------- + strategy : str, default is Undefined, required + Strategy defines the strategy to use to combine the input variable values. + Currently only string is supported. + string : ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0CombineString, default is Undefined, optional + string + variables : [ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0CombineVariablesItems0], default is Undefined, required + Variables are the list of variables whose values will be retrieved and + combined. + """ + + + strategy: "string" + + string?: ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0CombineString + + variables: [ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0CombineVariablesItems0] + + + check: + len(variables) >= 1 + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0CombineString: + """ + String declares that input variables should be combined into a single + string, using the relevant settings for formatting purposes. + + Attributes + ---------- + fmt : str, default is Undefined, required + Format the input using a Go format string. See + https://golang.org/pkg/fmt/ for details. + """ + + + fmt: str + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0CombineVariablesItems0: + """ + A CombineVariable defines the source of a value that is combined with + others to form and patch an output value. Currently, this only supports + retrieving values from a field path. + + Attributes + ---------- + fromFieldPath : str, default is Undefined, required + FromFieldPath is the path of the field on the source whose value is + to be used as input. + """ + + + fromFieldPath: str + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0Policy: + """ + Policy configures the specifics of patching behaviour. + + Attributes + ---------- + fromFieldPath : str, default is Undefined, optional + FromFieldPath specifies how to patch from a field path. The default is + 'Optional', which means the patch will be a no-op if the specified + fromFieldPath does not exist. Use 'Required' if the patch should fail if + the specified path does not exist. + mergeOptions : ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0PolicyMergeOptions, default is Undefined, optional + merge options + """ + + + fromFieldPath?: "Optional" | "Required" + + mergeOptions?: ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0PolicyMergeOptions + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0PolicyMergeOptions: + """ + MergeOptions Specifies merge options on a field path + + Attributes + ---------- + appendSlice : bool, default is Undefined, optional + Specifies that already existing elements in a merged slice should be preserved + keepMapValues : bool, default is Undefined, optional + Specifies that already existing values in a merged map should be preserved + """ + + + appendSlice?: bool + + keepMapValues?: bool + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0: + """ + Transform is a unit of process whose input is transformed into an output with + the supplied configuration. + + Attributes + ---------- + convert : ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0Convert, default is Undefined, optional + convert + $map : {str:any}, default is Undefined, optional + Map uses the input as a key in the given map and returns the value. + match : ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0Match, default is Undefined, optional + match + math : ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0Math, default is Undefined, optional + math + string : ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0String, default is Undefined, optional + string + $type : str, default is Undefined, required + Type of the transform to be run. + """ + + + convert?: ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0Convert + + $map?: {str:any} + + match?: ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0Match + + math?: ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0Math + + string?: ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0String + + $type: "map" | "match" | "math" | "string" | "convert" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0Convert: + """ + Convert is used to cast the input into the given output type. + + Attributes + ---------- + format : str, default is Undefined, optional + The expected input format. + + + * `quantity` - parses the input as a K8s [`resource.Quantity`](https://pkg.go.dev/k8s.io/apimachinery/pkg/api/resource#Quantity). + Only used during `string -> float64` conversions. + * `json` - parses the input as a JSON string. + Only used during `string -> object` or `string -> list` conversions. + + + If this property is null, the default conversion is applied. + toType : str, default is Undefined, required + ToType is the type of the output of this transform. + """ + + + format?: "none" | "quantity" | "json" + + toType: "string" | "int" | "int64" | "bool" | "float64" | "object" | "array" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0Match: + """ + Match is a more complex version of Map that matches a list of patterns. + + Attributes + ---------- + fallbackTo : str, default is "Value", optional + Determines to what value the transform should fallback if no pattern matches. + fallbackValue : any, default is Undefined, optional + The fallback value that should be returned by the transform if now pattern + matches. + patterns : [ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0MatchPatternsItems0], default is Undefined, optional + The patterns that should be tested against the input string. + Patterns are tested in order. The value of the first match is used as + result of this transform. + """ + + + fallbackTo?: "Value" | "Input" = "Value" + + fallbackValue?: any + + patterns?: [ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0MatchPatternsItems0] + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0MatchPatternsItems0: + """ + MatchTransformPattern is a transform that returns the value that matches a + pattern. + + Attributes + ---------- + literal : str, default is Undefined, optional + Literal exactly matches the input string (case sensitive). + Is required if `type` is `literal`. + regexp : str, default is Undefined, optional + Regexp to match against the input string. + Is required if `type` is `regexp`. + result : any, default is Undefined, required + The value that is used as result of the transform if the pattern matches. + $type : str, default is "literal", required + Type specifies how the pattern matches the input. + + + * `literal` - the pattern value has to exactly match (case sensitive) the + input string. This is the default. + + + * `regexp` - the pattern treated as a regular expression against + which the input string is tested. Crossplane will throw an error if the + key is not a valid regexp. + """ + + + literal?: str + + regexp?: str + + result: any + + $type: "literal" | "regexp" = "literal" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0Math: + """ + Math is used to transform the input via mathematical operations such as + multiplication. + + Attributes + ---------- + clampMax : int, default is Undefined, optional + ClampMax makes sure that the value is not bigger than the given value. + clampMin : int, default is Undefined, optional + ClampMin makes sure that the value is not smaller than the given value. + multiply : int, default is Undefined, optional + Multiply the value. + $type : str, default is "Multiply", optional + Type of the math transform to be run. + """ + + + clampMax?: int + + clampMin?: int + + multiply?: int + + $type?: "Multiply" | "ClampMin" | "ClampMax" = "Multiply" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0String: + """ + String is used to transform the input into a string or a different kind + of string. Note that the input does not necessarily need to be a string. + + Attributes + ---------- + convert : str, default is Undefined, optional + Optional conversion method to be specified. + `ToUpper` and `ToLower` change the letter case of the input string. + `ToBase64` and `FromBase64` perform a base64 conversion based on the input string. + `ToJson` converts any input value into its raw JSON representation. + `ToSha1`, `ToSha256` and `ToSha512` generate a hash value based on the input + converted to JSON. + fmt : str, default is Undefined, optional + Format the input using a Go format string. See + https://golang.org/pkg/fmt/ for details. + join : ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0StringJoin, default is Undefined, optional + join + regexp : ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0StringRegexp, default is Undefined, optional + regexp + trim : str, default is Undefined, optional + Trim the prefix or suffix from the input + $type : str, default is "Format", optional + Type of the string transform to be run. + """ + + + convert?: "ToUpper" | "ToLower" | "ToBase64" | "FromBase64" | "ToJson" | "ToSha1" | "ToSha256" | "ToSha512" + + fmt?: str + + join?: ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0StringJoin + + regexp?: ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0StringRegexp + + trim?: str + + $type?: "Format" | "Convert" | "TrimPrefix" | "TrimSuffix" | "Regexp" | "Join" = "Format" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0StringJoin: + """ + Join defines parameters to join a slice of values to a string. + + Attributes + ---------- + separator : str, default is Undefined, required + Separator defines the character that should separate the values from each + other in the joined string. + """ + + + separator: str + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPatchesItems0TransformsItems0StringRegexp: + """ + Extract a match from the input using a regular expression. + + Attributes + ---------- + group : int, default is Undefined, optional + Group number to match. 0 (the default) matches the entire expression. + match : str, default is Undefined, required + Match string. May optionally include submatches, aka capture groups. + See https://pkg.go.dev/regexp/ for details. + """ + + + group?: int + + match: str + + +schema ApiextensionsCrossplaneIoV1CompositionSpecEnvironmentPolicy: + """ + Policy represents the Resolve and Resolution policies which apply to + all EnvironmentSourceReferences in EnvironmentConfigs list. + + Attributes + ---------- + resolution : str, default is "Required", optional + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + resolve : str, default is Undefined, optional + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + """ + + + resolution?: "Required" | "Optional" = "Required" + + resolve?: "Always" | "IfNotPresent" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0: + """ + A PatchSet is a set of patches that can be reused from all resources within + a Composition. + + Attributes + ---------- + name : str, default is Undefined, required + Name of this PatchSet. + patches : [ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0], default is Undefined, required + Patches will be applied as an overlay to the base resource. + """ + + + name: str + + patches: [ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0] + + +schema ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0: + """ + Patch objects are applied between composite and composed resources. Their + behaviour depends on the Type selected. The default Type, + FromCompositeFieldPath, copies a value from the composite resource to + the composed resource, applying any defined transformers. + + Attributes + ---------- + combine : ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0Combine, default is Undefined, optional + combine + fromFieldPath : str, default is Undefined, optional + FromFieldPath is the path of the field on the resource whose value is + to be used as input. Required when type is FromCompositeFieldPath, + FromEnvironmentFieldPath, ToCompositeFieldPath, ToEnvironmentFieldPath. + patchSetName : str, default is Undefined, optional + PatchSetName to include patches from. Required when type is PatchSet. + policy : ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0Policy, default is Undefined, optional + policy + toFieldPath : str, default is Undefined, optional + ToFieldPath is the path of the field on the resource whose value will + be changed with the result of transforms. Leave empty if you'd like to + propagate to the same path as fromFieldPath. + transforms : [ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0], default is Undefined, optional + Transforms are the list of functions that are used as a FIFO pipe for the + input to be transformed. + $type : str, default is "FromCompositeFieldPath", optional + Type sets the patching behaviour to be used. Each patch type may require + its own fields to be set on the Patch object. + """ + + + combine?: ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0Combine + + fromFieldPath?: str + + patchSetName?: str + + policy?: ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0Policy + + toFieldPath?: str + + transforms?: [ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0] + + $type?: "FromCompositeFieldPath" | "FromEnvironmentFieldPath" | "PatchSet" | "ToCompositeFieldPath" | "ToEnvironmentFieldPath" | "CombineFromEnvironment" | "CombineFromComposite" | "CombineToComposite" | "CombineToEnvironment" = "FromCompositeFieldPath" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0Combine: + """ + Combine is the patch configuration for a CombineFromComposite, + CombineFromEnvironment, CombineToComposite or CombineToEnvironment patch. + + Attributes + ---------- + strategy : str, default is Undefined, required + Strategy defines the strategy to use to combine the input variable values. + Currently only string is supported. + string : ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0CombineString, default is Undefined, optional + string + variables : [ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0CombineVariablesItems0], default is Undefined, required + Variables are the list of variables whose values will be retrieved and + combined. + """ + + + strategy: "string" + + string?: ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0CombineString + + variables: [ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0CombineVariablesItems0] + + + check: + len(variables) >= 1 + + +schema ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0CombineString: + """ + String declares that input variables should be combined into a single + string, using the relevant settings for formatting purposes. + + Attributes + ---------- + fmt : str, default is Undefined, required + Format the input using a Go format string. See + https://golang.org/pkg/fmt/ for details. + """ + + + fmt: str + + +schema ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0CombineVariablesItems0: + """ + A CombineVariable defines the source of a value that is combined with + others to form and patch an output value. Currently, this only supports + retrieving values from a field path. + + Attributes + ---------- + fromFieldPath : str, default is Undefined, required + FromFieldPath is the path of the field on the source whose value is + to be used as input. + """ + + + fromFieldPath: str + + +schema ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0Policy: + """ + Policy configures the specifics of patching behaviour. + + Attributes + ---------- + fromFieldPath : str, default is Undefined, optional + FromFieldPath specifies how to patch from a field path. The default is + 'Optional', which means the patch will be a no-op if the specified + fromFieldPath does not exist. Use 'Required' if the patch should fail if + the specified path does not exist. + mergeOptions : ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0PolicyMergeOptions, default is Undefined, optional + merge options + """ + + + fromFieldPath?: "Optional" | "Required" + + mergeOptions?: ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0PolicyMergeOptions + + +schema ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0PolicyMergeOptions: + """ + MergeOptions Specifies merge options on a field path + + Attributes + ---------- + appendSlice : bool, default is Undefined, optional + Specifies that already existing elements in a merged slice should be preserved + keepMapValues : bool, default is Undefined, optional + Specifies that already existing values in a merged map should be preserved + """ + + + appendSlice?: bool + + keepMapValues?: bool + + +schema ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0: + """ + Transform is a unit of process whose input is transformed into an output with + the supplied configuration. + + Attributes + ---------- + convert : ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0Convert, default is Undefined, optional + convert + $map : {str:any}, default is Undefined, optional + Map uses the input as a key in the given map and returns the value. + match : ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0Match, default is Undefined, optional + match + math : ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0Math, default is Undefined, optional + math + string : ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0String, default is Undefined, optional + string + $type : str, default is Undefined, required + Type of the transform to be run. + """ + + + convert?: ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0Convert + + $map?: {str:any} + + match?: ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0Match + + math?: ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0Math + + string?: ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0String + + $type: "map" | "match" | "math" | "string" | "convert" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0Convert: + """ + Convert is used to cast the input into the given output type. + + Attributes + ---------- + format : str, default is Undefined, optional + The expected input format. + + + * `quantity` - parses the input as a K8s [`resource.Quantity`](https://pkg.go.dev/k8s.io/apimachinery/pkg/api/resource#Quantity). + Only used during `string -> float64` conversions. + * `json` - parses the input as a JSON string. + Only used during `string -> object` or `string -> list` conversions. + + + If this property is null, the default conversion is applied. + toType : str, default is Undefined, required + ToType is the type of the output of this transform. + """ + + + format?: "none" | "quantity" | "json" + + toType: "string" | "int" | "int64" | "bool" | "float64" | "object" | "array" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0Match: + """ + Match is a more complex version of Map that matches a list of patterns. + + Attributes + ---------- + fallbackTo : str, default is "Value", optional + Determines to what value the transform should fallback if no pattern matches. + fallbackValue : any, default is Undefined, optional + The fallback value that should be returned by the transform if now pattern + matches. + patterns : [ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0MatchPatternsItems0], default is Undefined, optional + The patterns that should be tested against the input string. + Patterns are tested in order. The value of the first match is used as + result of this transform. + """ + + + fallbackTo?: "Value" | "Input" = "Value" + + fallbackValue?: any + + patterns?: [ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0MatchPatternsItems0] + + +schema ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0MatchPatternsItems0: + """ + MatchTransformPattern is a transform that returns the value that matches a + pattern. + + Attributes + ---------- + literal : str, default is Undefined, optional + Literal exactly matches the input string (case sensitive). + Is required if `type` is `literal`. + regexp : str, default is Undefined, optional + Regexp to match against the input string. + Is required if `type` is `regexp`. + result : any, default is Undefined, required + The value that is used as result of the transform if the pattern matches. + $type : str, default is "literal", required + Type specifies how the pattern matches the input. + + + * `literal` - the pattern value has to exactly match (case sensitive) the + input string. This is the default. + + + * `regexp` - the pattern treated as a regular expression against + which the input string is tested. Crossplane will throw an error if the + key is not a valid regexp. + """ + + + literal?: str + + regexp?: str + + result: any + + $type: "literal" | "regexp" = "literal" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0Math: + """ + Math is used to transform the input via mathematical operations such as + multiplication. + + Attributes + ---------- + clampMax : int, default is Undefined, optional + ClampMax makes sure that the value is not bigger than the given value. + clampMin : int, default is Undefined, optional + ClampMin makes sure that the value is not smaller than the given value. + multiply : int, default is Undefined, optional + Multiply the value. + $type : str, default is "Multiply", optional + Type of the math transform to be run. + """ + + + clampMax?: int + + clampMin?: int + + multiply?: int + + $type?: "Multiply" | "ClampMin" | "ClampMax" = "Multiply" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0String: + """ + String is used to transform the input into a string or a different kind + of string. Note that the input does not necessarily need to be a string. + + Attributes + ---------- + convert : str, default is Undefined, optional + Optional conversion method to be specified. + `ToUpper` and `ToLower` change the letter case of the input string. + `ToBase64` and `FromBase64` perform a base64 conversion based on the input string. + `ToJson` converts any input value into its raw JSON representation. + `ToSha1`, `ToSha256` and `ToSha512` generate a hash value based on the input + converted to JSON. + fmt : str, default is Undefined, optional + Format the input using a Go format string. See + https://golang.org/pkg/fmt/ for details. + join : ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0StringJoin, default is Undefined, optional + join + regexp : ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0StringRegexp, default is Undefined, optional + regexp + trim : str, default is Undefined, optional + Trim the prefix or suffix from the input + $type : str, default is "Format", optional + Type of the string transform to be run. + """ + + + convert?: "ToUpper" | "ToLower" | "ToBase64" | "FromBase64" | "ToJson" | "ToSha1" | "ToSha256" | "ToSha512" + + fmt?: str + + join?: ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0StringJoin + + regexp?: ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0StringRegexp + + trim?: str + + $type?: "Format" | "Convert" | "TrimPrefix" | "TrimSuffix" | "Regexp" | "Join" = "Format" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0StringJoin: + """ + Join defines parameters to join a slice of values to a string. + + Attributes + ---------- + separator : str, default is Undefined, required + Separator defines the character that should separate the values from each + other in the joined string. + """ + + + separator: str + + +schema ApiextensionsCrossplaneIoV1CompositionSpecPatchSetsItems0PatchesItems0TransformsItems0StringRegexp: + """ + Extract a match from the input using a regular expression. + + Attributes + ---------- + group : int, default is Undefined, optional + Group number to match. 0 (the default) matches the entire expression. + match : str, default is Undefined, required + Match string. May optionally include submatches, aka capture groups. + See https://pkg.go.dev/regexp/ for details. + """ + + + group?: int + + match: str + + +schema ApiextensionsCrossplaneIoV1CompositionSpecPipelineItems0: + """ + A PipelineStep in a Composition Function pipeline. + + Attributes + ---------- + functionRef : ApiextensionsCrossplaneIoV1CompositionSpecPipelineItems0FunctionRef, default is Undefined, required + function ref + input : any, default is Undefined, optional + Input is an optional, arbitrary Kubernetes resource (i.e. a resource + with an apiVersion and kind) that will be passed to the Composition + Function as the 'input' of its RunFunctionRequest. + step : str, default is Undefined, required + Step name. Must be unique within its Pipeline. + """ + + + functionRef: ApiextensionsCrossplaneIoV1CompositionSpecPipelineItems0FunctionRef + + input?: any + + step: str + + +schema ApiextensionsCrossplaneIoV1CompositionSpecPipelineItems0FunctionRef: + """ + FunctionRef is a reference to the Composition Function this step should + execute. + + Attributes + ---------- + name : str, default is Undefined, required + Name of the referenced Function. + """ + + + name: str + + +schema ApiextensionsCrossplaneIoV1CompositionSpecPublishConnectionDetailsWithStoreConfigRef: + """ + PublishConnectionDetailsWithStoreConfig specifies the secret store config + with which the connection details of composite resources dynamically + provisioned using this composition will be published. + + + THIS IS AN ALPHA FIELD. Do not use it in production. It is not honored + unless the relevant Crossplane feature flag is enabled, and may be + changed or removed without notice. + + Attributes + ---------- + name : str, default is Undefined, required + Name of the referenced StoreConfig. + """ + + + name: str + + +schema ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0: + """ + ComposedTemplate is used to provide information about how the composed resource + should be processed. + + Attributes + ---------- + base : any, default is Undefined, required + Base is the target resource that the patches will be applied on. + connectionDetails : [ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0ConnectionDetailsItems0], default is Undefined, optional + ConnectionDetails lists the propagation secret keys from this target + resource to the composition instance connection secret. + name : str, default is Undefined, optional + A Name uniquely identifies this entry within its Composition's resources + array. Names are optional but *strongly* recommended. When all entries in + the resources array are named entries may added, deleted, and reordered + as long as their names do not change. When entries are not named the + length and order of the resources array should be treated as immutable. + Either all or no entries must be named. + patches : [ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0], default is Undefined, optional + Patches will be applied as overlay to the base resource. + readinessChecks : [ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0ReadinessChecksItems0], default is [{"matchCondition": {"status": "True", "type": "Ready"}, "type": "MatchCondition"}, {"matchCondition": {"status": "False"}, "type": "MatchCondition"}], optional + ReadinessChecks allows users to define custom readiness checks. All checks + have to return true in order for resource to be considered ready. The + default readiness check is to have the "Ready" condition to be "True". + """ + + + base: any + + connectionDetails?: [ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0ConnectionDetailsItems0] + + name?: str + + patches?: [ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0] + + readinessChecks?: [ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0ReadinessChecksItems0] = [{"matchCondition": {"status": "True", "type": "Ready"}, "type": "MatchCondition"}, {"matchCondition": {"status": "False"}, "type": "MatchCondition"}] + + +schema ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0ConnectionDetailsItems0: + """ + ConnectionDetail includes the information about the propagation of the connection + information from one secret to another. + + Attributes + ---------- + fromConnectionSecretKey : str, default is Undefined, optional + FromConnectionSecretKey is the key that will be used to fetch the value + from the composed resource's connection secret. + fromFieldPath : str, default is Undefined, optional + FromFieldPath is the path of the field on the composed resource whose + value to be used as input. Name must be specified if the type is + FromFieldPath. + name : str, default is Undefined, optional + Name of the connection secret key that will be propagated to the + connection secret of the composition instance. Leave empty if you'd like + to use the same key name. + $type : str, default is Undefined, optional + Type sets the connection detail fetching behaviour to be used. Each + connection detail type may require its own fields to be set on the + ConnectionDetail object. If the type is omitted Crossplane will attempt + to infer it based on which other fields were specified. If multiple + fields are specified the order of precedence is: + 1. FromValue + 2. FromConnectionSecretKey + 3. FromFieldPath + value : str, default is Undefined, optional + Value that will be propagated to the connection secret of the composite + resource. May be set to inject a fixed, non-sensitive connection secret + value, for example a well-known port. + """ + + + fromConnectionSecretKey?: str + + fromFieldPath?: str + + name?: str + + $type?: "FromConnectionSecretKey" | "FromFieldPath" | "FromValue" + + value?: str + + +schema ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0: + """ + Patch objects are applied between composite and composed resources. Their + behaviour depends on the Type selected. The default Type, + FromCompositeFieldPath, copies a value from the composite resource to + the composed resource, applying any defined transformers. + + Attributes + ---------- + combine : ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0Combine, default is Undefined, optional + combine + fromFieldPath : str, default is Undefined, optional + FromFieldPath is the path of the field on the resource whose value is + to be used as input. Required when type is FromCompositeFieldPath, + FromEnvironmentFieldPath, ToCompositeFieldPath, ToEnvironmentFieldPath. + patchSetName : str, default is Undefined, optional + PatchSetName to include patches from. Required when type is PatchSet. + policy : ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0Policy, default is Undefined, optional + policy + toFieldPath : str, default is Undefined, optional + ToFieldPath is the path of the field on the resource whose value will + be changed with the result of transforms. Leave empty if you'd like to + propagate to the same path as fromFieldPath. + transforms : [ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0], default is Undefined, optional + Transforms are the list of functions that are used as a FIFO pipe for the + input to be transformed. + $type : str, default is "FromCompositeFieldPath", optional + Type sets the patching behaviour to be used. Each patch type may require + its own fields to be set on the Patch object. + """ + + + combine?: ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0Combine + + fromFieldPath?: str + + patchSetName?: str + + policy?: ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0Policy + + toFieldPath?: str + + transforms?: [ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0] + + $type?: "FromCompositeFieldPath" | "FromEnvironmentFieldPath" | "PatchSet" | "ToCompositeFieldPath" | "ToEnvironmentFieldPath" | "CombineFromEnvironment" | "CombineFromComposite" | "CombineToComposite" | "CombineToEnvironment" = "FromCompositeFieldPath" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0Combine: + """ + Combine is the patch configuration for a CombineFromComposite, + CombineFromEnvironment, CombineToComposite or CombineToEnvironment patch. + + Attributes + ---------- + strategy : str, default is Undefined, required + Strategy defines the strategy to use to combine the input variable values. + Currently only string is supported. + string : ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0CombineString, default is Undefined, optional + string + variables : [ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0CombineVariablesItems0], default is Undefined, required + Variables are the list of variables whose values will be retrieved and + combined. + """ + + + strategy: "string" + + string?: ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0CombineString + + variables: [ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0CombineVariablesItems0] + + + check: + len(variables) >= 1 + + +schema ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0CombineString: + """ + String declares that input variables should be combined into a single + string, using the relevant settings for formatting purposes. + + Attributes + ---------- + fmt : str, default is Undefined, required + Format the input using a Go format string. See + https://golang.org/pkg/fmt/ for details. + """ + + + fmt: str + + +schema ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0CombineVariablesItems0: + """ + A CombineVariable defines the source of a value that is combined with + others to form and patch an output value. Currently, this only supports + retrieving values from a field path. + + Attributes + ---------- + fromFieldPath : str, default is Undefined, required + FromFieldPath is the path of the field on the source whose value is + to be used as input. + """ + + + fromFieldPath: str + + +schema ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0Policy: + """ + Policy configures the specifics of patching behaviour. + + Attributes + ---------- + fromFieldPath : str, default is Undefined, optional + FromFieldPath specifies how to patch from a field path. The default is + 'Optional', which means the patch will be a no-op if the specified + fromFieldPath does not exist. Use 'Required' if the patch should fail if + the specified path does not exist. + mergeOptions : ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0PolicyMergeOptions, default is Undefined, optional + merge options + """ + + + fromFieldPath?: "Optional" | "Required" + + mergeOptions?: ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0PolicyMergeOptions + + +schema ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0PolicyMergeOptions: + """ + MergeOptions Specifies merge options on a field path + + Attributes + ---------- + appendSlice : bool, default is Undefined, optional + Specifies that already existing elements in a merged slice should be preserved + keepMapValues : bool, default is Undefined, optional + Specifies that already existing values in a merged map should be preserved + """ + + + appendSlice?: bool + + keepMapValues?: bool + + +schema ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0: + """ + Transform is a unit of process whose input is transformed into an output with + the supplied configuration. + + Attributes + ---------- + convert : ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0Convert, default is Undefined, optional + convert + $map : {str:any}, default is Undefined, optional + Map uses the input as a key in the given map and returns the value. + match : ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0Match, default is Undefined, optional + match + math : ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0Math, default is Undefined, optional + math + string : ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0String, default is Undefined, optional + string + $type : str, default is Undefined, required + Type of the transform to be run. + """ + + + convert?: ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0Convert + + $map?: {str:any} + + match?: ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0Match + + math?: ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0Math + + string?: ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0String + + $type: "map" | "match" | "math" | "string" | "convert" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0Convert: + """ + Convert is used to cast the input into the given output type. + + Attributes + ---------- + format : str, default is Undefined, optional + The expected input format. + + + * `quantity` - parses the input as a K8s [`resource.Quantity`](https://pkg.go.dev/k8s.io/apimachinery/pkg/api/resource#Quantity). + Only used during `string -> float64` conversions. + * `json` - parses the input as a JSON string. + Only used during `string -> object` or `string -> list` conversions. + + + If this property is null, the default conversion is applied. + toType : str, default is Undefined, required + ToType is the type of the output of this transform. + """ + + + format?: "none" | "quantity" | "json" + + toType: "string" | "int" | "int64" | "bool" | "float64" | "object" | "array" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0Match: + """ + Match is a more complex version of Map that matches a list of patterns. + + Attributes + ---------- + fallbackTo : str, default is "Value", optional + Determines to what value the transform should fallback if no pattern matches. + fallbackValue : any, default is Undefined, optional + The fallback value that should be returned by the transform if now pattern + matches. + patterns : [ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0MatchPatternsItems0], default is Undefined, optional + The patterns that should be tested against the input string. + Patterns are tested in order. The value of the first match is used as + result of this transform. + """ + + + fallbackTo?: "Value" | "Input" = "Value" + + fallbackValue?: any + + patterns?: [ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0MatchPatternsItems0] + + +schema ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0MatchPatternsItems0: + """ + MatchTransformPattern is a transform that returns the value that matches a + pattern. + + Attributes + ---------- + literal : str, default is Undefined, optional + Literal exactly matches the input string (case sensitive). + Is required if `type` is `literal`. + regexp : str, default is Undefined, optional + Regexp to match against the input string. + Is required if `type` is `regexp`. + result : any, default is Undefined, required + The value that is used as result of the transform if the pattern matches. + $type : str, default is "literal", required + Type specifies how the pattern matches the input. + + + * `literal` - the pattern value has to exactly match (case sensitive) the + input string. This is the default. + + + * `regexp` - the pattern treated as a regular expression against + which the input string is tested. Crossplane will throw an error if the + key is not a valid regexp. + """ + + + literal?: str + + regexp?: str + + result: any + + $type: "literal" | "regexp" = "literal" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0Math: + """ + Math is used to transform the input via mathematical operations such as + multiplication. + + Attributes + ---------- + clampMax : int, default is Undefined, optional + ClampMax makes sure that the value is not bigger than the given value. + clampMin : int, default is Undefined, optional + ClampMin makes sure that the value is not smaller than the given value. + multiply : int, default is Undefined, optional + Multiply the value. + $type : str, default is "Multiply", optional + Type of the math transform to be run. + """ + + + clampMax?: int + + clampMin?: int + + multiply?: int + + $type?: "Multiply" | "ClampMin" | "ClampMax" = "Multiply" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0String: + """ + String is used to transform the input into a string or a different kind + of string. Note that the input does not necessarily need to be a string. + + Attributes + ---------- + convert : str, default is Undefined, optional + Optional conversion method to be specified. + `ToUpper` and `ToLower` change the letter case of the input string. + `ToBase64` and `FromBase64` perform a base64 conversion based on the input string. + `ToJson` converts any input value into its raw JSON representation. + `ToSha1`, `ToSha256` and `ToSha512` generate a hash value based on the input + converted to JSON. + fmt : str, default is Undefined, optional + Format the input using a Go format string. See + https://golang.org/pkg/fmt/ for details. + join : ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0StringJoin, default is Undefined, optional + join + regexp : ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0StringRegexp, default is Undefined, optional + regexp + trim : str, default is Undefined, optional + Trim the prefix or suffix from the input + $type : str, default is "Format", optional + Type of the string transform to be run. + """ + + + convert?: "ToUpper" | "ToLower" | "ToBase64" | "FromBase64" | "ToJson" | "ToSha1" | "ToSha256" | "ToSha512" + + fmt?: str + + join?: ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0StringJoin + + regexp?: ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0StringRegexp + + trim?: str + + $type?: "Format" | "Convert" | "TrimPrefix" | "TrimSuffix" | "Regexp" | "Join" = "Format" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0StringJoin: + """ + Join defines parameters to join a slice of values to a string. + + Attributes + ---------- + separator : str, default is Undefined, required + Separator defines the character that should separate the values from each + other in the joined string. + """ + + + separator: str + + +schema ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0PatchesItems0TransformsItems0StringRegexp: + """ + Extract a match from the input using a regular expression. + + Attributes + ---------- + group : int, default is Undefined, optional + Group number to match. 0 (the default) matches the entire expression. + match : str, default is Undefined, required + Match string. May optionally include submatches, aka capture groups. + See https://pkg.go.dev/regexp/ for details. + """ + + + group?: int + + match: str + + +schema ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0ReadinessChecksItems0: + """ + ReadinessCheck is used to indicate how to tell whether a resource is ready + for consumption. + + Attributes + ---------- + fieldPath : str, default is Undefined, optional + FieldPath shows the path of the field whose value will be used. + matchCondition : ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0ReadinessChecksItems0MatchCondition, default is Undefined, optional + match condition + matchInteger : int, default is Undefined, optional + MatchInt is the value you'd like to match if you're using "MatchInt" type. + matchString : str, default is Undefined, optional + MatchString is the value you'd like to match if you're using "MatchString" type. + $type : str, default is Undefined, required + Type indicates the type of probe you'd like to use. + """ + + + fieldPath?: str + + matchCondition?: ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0ReadinessChecksItems0MatchCondition + + matchInteger?: int + + matchString?: str + + $type: "MatchString" | "MatchInteger" | "NonEmpty" | "MatchCondition" | "MatchTrue" | "MatchFalse" | "None" + + +schema ApiextensionsCrossplaneIoV1CompositionSpecResourcesItems0ReadinessChecksItems0MatchCondition: + """ + MatchCondition specifies the condition you'd like to match if you're using "MatchCondition" type. + + Attributes + ---------- + status : str, default is "True", required + Status is the status of the condition you'd like to match. + $type : str, default is "Ready", required + Type indicates the type of condition you'd like to use. + """ + + + status: str = "True" + + $type: str = "Ready" + + diff --git a/pkg/kube_resource/generator/testdata/default_value/models/k8s/apimachinery/pkg/apis/meta/v1/managed_fields_entry.k b/pkg/kube_resource/generator/testdata/default_value/models/k8s/apimachinery/pkg/apis/meta/v1/managed_fields_entry.k new file mode 100644 index 0000000..8d20935 --- /dev/null +++ b/pkg/kube_resource/generator/testdata/default_value/models/k8s/apimachinery/pkg/apis/meta/v1/managed_fields_entry.k @@ -0,0 +1,41 @@ +""" +This is the managed_fields_entry module in k8s.apimachinery.pkg.apis.meta.v1 package. +This file was generated by the KCL auto-gen tool. DO NOT EDIT. +Editing this file might prove futile when you re-run the KCL auto-gen generate command. +""" + + +schema ManagedFieldsEntry: + """ + ManagedFieldsEntry is a workflow-id, a FieldSet and the group version of the resource that the fieldset applies to. + + Attributes + ---------- + apiVersion : str, default is Undefined, optional + APIVersion defines the version of this resource that this field set applies to. The format is "group/version" just like the top-level APIVersion field. It is necessary to track the version of a field set because it cannot be automatically converted. + fieldsType : str, default is Undefined, optional + FieldsType is the discriminator for the different fields format and version. There is currently only one possible value: "FieldsV1" + fieldsV1 : any, default is Undefined, optional + FieldsV1 holds the first JSON version format as described in the "FieldsV1" type. + manager : str, default is Undefined, optional + Manager is an identifier of the workflow managing these fields. + operation : str, default is Undefined, optional + Operation is the type of operation which lead to this ManagedFieldsEntry being created. The only valid values for this field are 'Apply' and 'Update'. + time : str, default is Undefined, optional + Time is timestamp of when these fields were set. It should always be empty if Operation is 'Apply' + """ + + + apiVersion?: str + + fieldsType?: str + + fieldsV1?: any + + manager?: str + + operation?: str + + time?: str + + diff --git a/pkg/kube_resource/generator/testdata/default_value/models/k8s/apimachinery/pkg/apis/meta/v1/object_meta.k b/pkg/kube_resource/generator/testdata/default_value/models/k8s/apimachinery/pkg/apis/meta/v1/object_meta.k new file mode 100644 index 0000000..c84b5e3 --- /dev/null +++ b/pkg/kube_resource/generator/testdata/default_value/models/k8s/apimachinery/pkg/apis/meta/v1/object_meta.k @@ -0,0 +1,97 @@ +""" +This is the object_meta module in k8s.apimachinery.pkg.apis.meta.v1 package. +This file was generated by the KCL auto-gen tool. DO NOT EDIT. +Editing this file might prove futile when you re-run the KCL auto-gen generate command. +""" + + +schema ObjectMeta: + """ + ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create. + + Attributes + ---------- + annotations : {str:str}, default is Undefined, optional + Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. They are not queryable and should be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations + clusterName : str, default is Undefined, optional + The name of the cluster which the object belongs to. This is used to distinguish resources with same name and namespace in different clusters. This field is not set anywhere right now and apiserver is going to ignore it if set in create or update request. + creationTimestamp : str, default is Undefined, optional + CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC. + + Populated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + deletionGracePeriodSeconds : int, default is Undefined, optional + Number of seconds allowed for this object to gracefully terminate before it will be removed from the system. Only set when deletionTimestamp is also set. May only be shortened. Read-only. + deletionTimestamp : str, default is Undefined, optional + DeletionTimestamp is RFC 3339 date and time at which this resource will be deleted. This field is set by the server when a graceful deletion is requested by the user, and is not directly settable by a client. The resource is expected to be deleted (no longer visible from resource lists, and not reachable by name) after the time in this field, once the finalizers list is empty. As long as the finalizers list contains items, deletion is blocked. Once the deletionTimestamp is set, this value may not be unset or be set further into the future, although it may be shortened or the resource may be deleted prior to this time. For example, a user may request that a pod is deleted in 30 seconds. The Kubelet will react by sending a graceful termination signal to the containers in the pod. After that 30 seconds, the Kubelet will send a hard termination signal (SIGKILL) to the container and after cleanup, remove the pod from the API. In the presence of network partitions, this object may still exist after this timestamp, until an administrator or automated process can determine the resource is fully terminated. If not set, graceful deletion of the object has not been requested. + + Populated by the system when a graceful deletion is requested. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + finalizers : [str], default is Undefined, optional + Must be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed. Finalizers may be processed and removed in any order. Order is NOT enforced because it introduces significant risk of stuck finalizers. finalizers is a shared field, any actor with permission can reorder it. If the finalizer list is processed in order, then this can lead to a situation in which the component responsible for the first finalizer in the list is waiting for a signal (field value, external system, or other) produced by a component responsible for a finalizer later in the list, resulting in a deadlock. Without enforced ordering finalizers are free to order amongst themselves and are not vulnerable to ordering changes in the list. + generateName : str, default is Undefined, optional + GenerateName is an optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided. If this field is used, the name returned to the client will be different than the name passed. This value will also be combined with a unique suffix. The provided value has the same validation rules as the Name field, and may be truncated by the length of the suffix required to make the value unique on the server. + + If this field is specified and the generated name exists, the server will NOT return a 409 - instead, it will either return 201 Created or 500 with Reason ServerTimeout indicating a unique name could not be found in the time allotted, and the client should retry (optionally after the time indicated in the Retry-After header). + + Applied only if Name is not specified. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#idempotency + generation : int, default is Undefined, optional + A sequence number representing a specific generation of the desired state. Populated by the system. Read-only. + labels : {str:str}, default is Undefined, optional + Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services. More info: http://kubernetes.io/docs/user-guide/labels + managedFields : [ManagedFieldsEntry], default is Undefined, optional + ManagedFields maps workflow-id and version to the set of fields that are managed by that workflow. This is mostly for internal housekeeping, and users typically shouldn't need to set or understand this field. A workflow can be the user's name, a controller's name, or the name of a specific apply path like "ci-cd". The set of fields is always in the version that the workflow used when modifying the object. + name : str, default is Undefined, optional + Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically. Name is primarily intended for creation idempotence and configuration definition. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/identifiers#names + namespace : str, default is Undefined, optional + Namespace defines the space within each name must be unique. An empty namespace is equivalent to the "default" namespace, but "default" is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty. + + Must be a DNS_LABEL. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/namespaces + ownerReferences : [OwnerReference], default is Undefined, optional + List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller. + resourceVersion : str, default is Undefined, optional + An opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed. May be used for optimistic concurrency, change detection, and the watch operation on a resource or set of resources. Clients must treat these values as opaque and passed unmodified back to the server. They may only be valid for a particular resource or set of resources. + + Populated by the system. Read-only. Value must be treated as opaque by clients and . More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency + selfLink : str, default is Undefined, optional + SelfLink is a URL representing this object. Populated by the system. Read-only. + + DEPRECATED Kubernetes will stop propagating this field in 1.20 release and the field is planned to be removed in 1.21 release. + uid : str, default is Undefined, optional + UID is the unique in time and space value for this object. It is typically generated by the server on successful creation of a resource and is not allowed to change on PUT operations. + + Populated by the system. Read-only. More info: http://kubernetes.io/docs/user-guide/identifiers#uids + """ + + + annotations?: {str:str} + + clusterName?: str + + creationTimestamp?: str + + deletionGracePeriodSeconds?: int + + deletionTimestamp?: str + + finalizers?: [str] + + generateName?: str + + generation?: int + + labels?: {str:str} + + managedFields?: [ManagedFieldsEntry] + + name?: str + + namespace?: str + + ownerReferences?: [OwnerReference] + + resourceVersion?: str + + selfLink?: str + + uid?: str + + diff --git a/pkg/kube_resource/generator/testdata/default_value/models/k8s/apimachinery/pkg/apis/meta/v1/owner_reference.k b/pkg/kube_resource/generator/testdata/default_value/models/k8s/apimachinery/pkg/apis/meta/v1/owner_reference.k new file mode 100644 index 0000000..8d4037b --- /dev/null +++ b/pkg/kube_resource/generator/testdata/default_value/models/k8s/apimachinery/pkg/apis/meta/v1/owner_reference.k @@ -0,0 +1,41 @@ +""" +This is the owner_reference module in k8s.apimachinery.pkg.apis.meta.v1 package. +This file was generated by the KCL auto-gen tool. DO NOT EDIT. +Editing this file might prove futile when you re-run the KCL auto-gen generate command. +""" + + +schema OwnerReference: + """ + OwnerReference contains enough information to let you identify an owning object. An owning object must be in the same namespace as the dependent, or be cluster-scoped, so there is no namespace field. + + Attributes + ---------- + apiVersion : str, default is Undefined, required + API version of the referent. + blockOwnerDeletion : bool, default is Undefined, optional + If true, AND if the owner has the "foregroundDeletion" finalizer, then the owner cannot be deleted from the key-value store until this reference is removed. Defaults to false. To set this field, a user needs "delete" permission of the owner, otherwise 422 (Unprocessable Entity) will be returned. + controller : bool, default is Undefined, optional + If true, this reference points to the managing controller. + kind : str, default is Undefined, required + Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + name : str, default is Undefined, required + Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names + uid : str, default is Undefined, required + UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids + """ + + + apiVersion: str + + blockOwnerDeletion?: bool + + controller?: bool + + kind: str + + name: str + + uid: str + + diff --git a/pkg/swagger/generator/language.go b/pkg/swagger/generator/language.go index 418f849..ee9856c 100644 --- a/pkg/swagger/generator/language.go +++ b/pkg/swagger/generator/language.go @@ -15,6 +15,7 @@ package generator import ( + "encoding/json" "fmt" "log" "path" @@ -164,14 +165,46 @@ func (l *LanguageOpts) ToKclValue(data interface{}) string { return fmt.Sprintf("[%s]", content) case reflect.String: return fmt.Sprintf("\"%s\"", data) + case reflect.Int, + reflect.Int8, + reflect.Int16, + reflect.Int32, + reflect.Int64, + reflect.Uint, + reflect.Uint8, + reflect.Uint16, + reflect.Uint32, + reflect.Uint64: + return fmt.Sprintf("%v", data) + case reflect.Float32, reflect.Float64: + return fmt.Sprintf("%v", data) case reflect.Bool: if data.(bool) { return "True" } return "False" default: - //TODO(xiarui.xr): support user defined struct - return fmt.Sprintf("%v", data) + if dataValue, ok := data.(reflect.Value); ok { + return l.ToKclValue(dataValue.Interface()) + } else if dataSlice, ok := data.(yaml.MapSlice); ok { + // If is a MapSlice + var dictContents []string + for _, v := range dataSlice { + k := v.Key + v := v.Value + dictContents = append(dictContents, fmt.Sprintf("%s: %s", l.ToKclValue(k), l.ToKclValue(v))) + } + content := strings.Join(dictContents, ", ") + return fmt.Sprintf("{%s}", content) + } else { + // User defined struct + valueString, err := ToKCLValueString(data) + if err != nil { + log.Fatal(err) + return "None" + } + return valueString + } } } @@ -326,3 +359,15 @@ func KclLangOpts() *LanguageOpts { opts.Init() return opts } + +func ToKCLValueString(value interface{}) (string, error) { + jsonString, err := json.Marshal(value) + if err != nil { + return "", err + } + // In KCL, `true`, `false` and `null` are denoted by `True`, `False` and `None`. + result := strings.Replace(string(jsonString), ": true", ": True", -1) + result = strings.Replace(result, ": false", ": False", -1) + result = strings.Replace(result, ": null", ": None", -1) + return result, nil +} diff --git a/pkg/swagger/generator/model.go b/pkg/swagger/generator/model.go index a6f525d..cfe1711 100644 --- a/pkg/swagger/generator/model.go +++ b/pkg/swagger/generator/model.go @@ -1513,31 +1513,42 @@ func RecoverMapValueOrder(oldValue interface{}) interface{} { keys := value.MapKeys() var newValue yaml.MapSlice = make([]yaml.MapItem, len(keys)) - for _, key := range keys { + for i, key := range keys { k := key.Interface() v := value.MapIndex(key).Interface() - mapV := reflect.ValueOf(v) switch mapV.Kind() { case reflect.Map: + hasXOrder := false var order int64 var innerValue interface{} mapIter := mapV.MapRange() for mapIter.Next() { kk := mapIter.Key().String() if kk == xOrder { + hasXOrder = true order = int64(mapIter.Value().Interface().(float64)) } if kk == "value" { innerValue = mapIter.Value().Interface() } } - newValue[order] = yaml.MapItem{ - Key: k, - Value: RecoverMapValueOrder(innerValue), + if hasXOrder { + newValue[order] = yaml.MapItem{ + Key: k, + Value: RecoverMapValueOrder(innerValue), + } + } else { + newValue[i] = yaml.MapItem{ + Key: k, + Value: RecoverMapValueOrder(v), + } } default: - log.Fatalf("unexpected ordered map value: %s", v) + newValue[i] = yaml.MapItem{ + Key: k, + Value: RecoverMapValueOrder(v), + } } } return newValue diff --git a/pkg/swagger/generator/spec.go b/pkg/swagger/generator/spec.go index 50ddd95..b3dbba2 100644 --- a/pkg/swagger/generator/spec.go +++ b/pkg/swagger/generator/spec.go @@ -17,7 +17,6 @@ package generator import ( "errors" "fmt" - "io/ioutil" "log" "os" "path/filepath" @@ -186,11 +185,11 @@ func WithXOrder(specPath string, addXOrderFunc func(yamlDoc interface{}) interfa panic(err) } - tmpFile, err := ioutil.TempFile("", filepath.Base(specPath)) + tmpFile, err := os.CreateTemp("", filepath.Base(specPath)) if err != nil { panic(err) } - if err := ioutil.WriteFile(tmpFile.Name(), out, 0); err != nil { + if err := os.WriteFile(tmpFile.Name(), out, 0); err != nil { panic(err) } return tmpFile.Name() @@ -250,17 +249,17 @@ func AddXOrderOnDefaultExample(yamlDoc interface{}) interface{} { break } } - // add default / example x-order + // Add default / example x-order var addXOrder func(interface{}) addXOrder = func(element interface{}) { - // 假设element是某个definition,即,是一个schema,首先找到其中的default、example选项 + // Assuming element is a certain definition, that is, a schema, first find the default and example options in it if defaultValue, ok := lookForSlice(element, "default"); ok { addXOrder2MapValue(defaultValue) } if exampleValue, ok := lookForSlice(element, "example"); ok { addXOrder2MapValue(exampleValue) } - // look for the properties and add addXOrder on each property + // Look for the properties and add addXOrder on each property if props, ok := lookForMapSlice(element, "properties"); ok { for _, prop := range props { if pSlice, ok := prop.Value.(yaml.MapSlice); ok {