Skip to content

Commit f450712

Browse files
committed
Create 2.2 version, now supporting the required schema both in request and response
1 parent 7cf4dc6 commit f450712

18 files changed

Lines changed: 324 additions & 145 deletions

‎crossplane-crd-model/src/main/resources/kubernetes/apiextensions.crossplane.io_compositeresourcedefinitions.yaml‎

Lines changed: 98 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ spec:
4040
API.
4141
4242
Read the Crossplane documentation for
43-
[more information about CustomResourceDefinitions](https://docs.crossplane.io/latest/concepts/composite-resource-definitions).
43+
[more information about CustomResourceDefinitions](https://docs.crossplane.io/latest/composition/composite-resource-definitions/).
4444
properties:
4545
apiVersion:
4646
description: |-
@@ -261,6 +261,54 @@ spec:
261261
required:
262262
- name
263263
type: object
264+
defaultCompositionRevisionSelector:
265+
description: |-
266+
DefaultCompositionRevisionSelector refers to the CompositionRevision that will be used
267+
in case no compositionRevision selector is given.
268+
properties:
269+
matchExpressions:
270+
description: matchExpressions is a list of label selector requirements.
271+
The requirements are ANDed.
272+
items:
273+
description: |-
274+
A label selector requirement is a selector that contains values, a key, and an operator that
275+
relates the key and values.
276+
properties:
277+
key:
278+
description: key is the label key that the selector applies
279+
to.
280+
type: string
281+
operator:
282+
description: |-
283+
operator represents a key's relationship to a set of values.
284+
Valid operators are In, NotIn, Exists and DoesNotExist.
285+
type: string
286+
values:
287+
description: |-
288+
values is an array of string values. If the operator is In or NotIn,
289+
the values array must be non-empty. If the operator is Exists or DoesNotExist,
290+
the values array must be empty. This array is replaced during a strategic
291+
merge patch.
292+
items:
293+
type: string
294+
type: array
295+
x-kubernetes-list-type: atomic
296+
required:
297+
- key
298+
- operator
299+
type: object
300+
type: array
301+
x-kubernetes-list-type: atomic
302+
matchLabels:
303+
additionalProperties:
304+
type: string
305+
description: |-
306+
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
307+
map is equivalent to an element of matchExpressions, whose key field is "key", the
308+
operator is "In", and the values array contains only "value". The requirements are ANDed.
309+
type: object
310+
type: object
311+
x-kubernetes-map-type: atomic
264312
defaultCompositionUpdatePolicy:
265313
default: Automatic
266314
description: |-
@@ -628,7 +676,7 @@ spec:
628676
API.
629677
630678
Read the Crossplane documentation for
631-
[more information about CustomResourceDefinitions](https://docs.crossplane.io/latest/concepts/composite-resource-definitions).
679+
[more information about CustomResourceDefinitions](https://docs.crossplane.io/latest/composition/composite-resource-definitions/).
632680
properties:
633681
apiVersion:
634682
description: |-
@@ -844,6 +892,54 @@ spec:
844892
required:
845893
- name
846894
type: object
895+
defaultCompositionRevisionSelector:
896+
description: |-
897+
DefaultCompositionRevisionSelector refers to the CompositionRevision that will be used
898+
in case no compositionRevision selector is given.
899+
properties:
900+
matchExpressions:
901+
description: matchExpressions is a list of label selector requirements.
902+
The requirements are ANDed.
903+
items:
904+
description: |-
905+
A label selector requirement is a selector that contains values, a key, and an operator that
906+
relates the key and values.
907+
properties:
908+
key:
909+
description: key is the label key that the selector applies
910+
to.
911+
type: string
912+
operator:
913+
description: |-
914+
operator represents a key's relationship to a set of values.
915+
Valid operators are In, NotIn, Exists and DoesNotExist.
916+
type: string
917+
values:
918+
description: |-
919+
values is an array of string values. If the operator is In or NotIn,
920+
the values array must be non-empty. If the operator is Exists or DoesNotExist,
921+
the values array must be empty. This array is replaced during a strategic
922+
merge patch.
923+
items:
924+
type: string
925+
type: array
926+
x-kubernetes-list-type: atomic
927+
required:
928+
- key
929+
- operator
930+
type: object
931+
type: array
932+
x-kubernetes-list-type: atomic
933+
matchLabels:
934+
additionalProperties:
935+
type: string
936+
description: |-
937+
matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
938+
map is equivalent to an element of matchExpressions, whose key field is "key", the
939+
operator is "In", and the values array contains only "value". The requirements are ANDed.
940+
type: object
941+
type: object
942+
x-kubernetes-map-type: atomic
847943
defaultCompositionUpdatePolicy:
848944
default: Automatic
849945
description: |-

‎crossplane-crd-model/src/main/resources/kubernetes/apiextensions.crossplane.io_compositionrevisions.yaml‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,36 @@ spec:
218218
x-kubernetes-list-map-keys:
219219
- requirementName
220220
x-kubernetes-list-type: map
221+
requiredSchemas:
222+
description: |-
223+
RequiredSchemas is a list of OpenAPI schemas that must be fetched before
224+
this function is called.
225+
items:
226+
description: RequiredSchemaSelector selects a required
227+
OpenAPI schema.
228+
properties:
229+
apiVersion:
230+
description: APIVersion of the resource kind whose
231+
schema is required, e.g. "example.org/v1".
232+
type: string
233+
kind:
234+
description: Kind of resource whose schema is required,
235+
e.g. "MyResource".
236+
type: string
237+
requirementName:
238+
description: |-
239+
RequirementName is the unique name to identify this required schema
240+
in the Required Schemas map in the function request.
241+
type: string
242+
required:
243+
- apiVersion
244+
- kind
245+
- requirementName
246+
type: object
247+
type: array
248+
x-kubernetes-list-map-keys:
249+
- requirementName
250+
x-kubernetes-list-type: map
221251
type: object
222252
step:
223253
description: Step name. Must be unique within its Pipeline.

‎crossplane-crd-model/src/main/resources/kubernetes/apiextensions.crossplane.io_compositions.yaml‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ spec:
3636
Crossplane uses to create and manage new composite resources.
3737
3838
Read the Crossplane documentation for
39-
[more information about Compositions](https://docs.crossplane.io/latest/concepts/compositions).
39+
[more information about Compositions](https://docs.crossplane.io/latest/composition/compositions/).
4040
properties:
4141
apiVersion:
4242
description: |-
@@ -214,6 +214,36 @@ spec:
214214
x-kubernetes-list-map-keys:
215215
- requirementName
216216
x-kubernetes-list-type: map
217+
requiredSchemas:
218+
description: |-
219+
RequiredSchemas is a list of OpenAPI schemas that must be fetched before
220+
this function is called.
221+
items:
222+
description: RequiredSchemaSelector selects a required
223+
OpenAPI schema.
224+
properties:
225+
apiVersion:
226+
description: APIVersion of the resource kind whose
227+
schema is required, e.g. "example.org/v1".
228+
type: string
229+
kind:
230+
description: Kind of resource whose schema is required,
231+
e.g. "MyResource".
232+
type: string
233+
requirementName:
234+
description: |-
235+
RequirementName is the unique name to identify this required schema
236+
in the Required Schemas map in the function request.
237+
type: string
238+
required:
239+
- apiVersion
240+
- kind
241+
- requirementName
242+
type: object
243+
type: array
244+
x-kubernetes-list-map-keys:
245+
- requirementName
246+
x-kubernetes-list-type: map
217247
type: object
218248
step:
219249
description: Step name. Must be unique within its Pipeline.

‎crossplane-crd-model/src/main/resources/kubernetes/apiextensions.crossplane.io_environmentconfigs.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ spec:
3030
use in a Composition.
3131
3232
Read the Crossplane documentation for
33-
[more information about EnvironmentConfigs](https://docs.crossplane.io/latest/concepts/environment-configs).
33+
[more information about EnvironmentConfigs](https://docs.crossplane.io/latest/composition/environment-configs/).
3434
properties:
3535
apiVersion:
3636
description: |-

‎crossplane-crd-model/src/main/resources/kubernetes/apiextensions.crossplane.io_usages.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ spec:
3939
resources with dependent resources.
4040
4141
Read the Crossplane documentation for
42-
[more information about Usages](https://docs.crossplane.io/latest/concepts/usages).
42+
[more information about Usages](https://docs.crossplane.io/latest/managed-resources/usages/).
4343
4444
Deprecated: Use protection.crossplane.io Usage or ClusterUsage.
4545
properties:
@@ -241,7 +241,7 @@ spec:
241241
resources with dependent resources.
242242
243243
Read the Crossplane documentation for
244-
[more information about Usages](https://docs.crossplane.io/latest/concepts/usages).
244+
[more information about Usages](https://docs.crossplane.io/latest/managed-resources/usages/).
245245
246246
Deprecated: Use protection.crossplane.io Usage or ClusterUsage.
247247
properties:

‎crossplane-crd-model/src/main/resources/kubernetes/fetch.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
release="v2.0.6"
3+
release="v2.2.0"
44

55
apiextensions=$(gh api --jq '.[].name' "/repos/crossplane/crossplane/contents/cluster/crds?ref=${release}" | grep apiextensions)
66

‎crossplane-function-base/src/main/java/io/crossplane/compositefunctions/base/CrossplaneCompositeFunctionBase.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public void runFunction(RunFunctionRequest request, StreamObserver<RunFunctionRe
3434
// Copy existing state into new desired state
3535
desiredBuilder.putAllResources(desired.getResourcesMap());
3636

37-
CrossplaneFunctionRequest crossplaneFunctionRequest = new CrossplaneFunctionRequest(request.getObserved(),
38-
request.getRequiredResourcesMap(), request.getCredentialsMap(), request.getDesired());
37+
CrossplaneFunctionRequest crossplaneFunctionRequest = new CrossplaneFunctionRequest(request.getMeta(), request.getObserved(),
38+
request.getRequiredResourcesMap(), request.getRequiredSchemasMap(), request.getCredentialsMap(), request.getDesired());
3939

4040

4141
logger.debug("Calling method with implemented logic");
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
package io.crossplane.compositefunctions.base;
22

33
import io.crossplane.compositefunctions.protobuf.v1.Credentials;
4+
import io.crossplane.compositefunctions.protobuf.v1.RequestMeta;
45
import io.crossplane.compositefunctions.protobuf.v1.Resources;
6+
import io.crossplane.compositefunctions.protobuf.v1.Schema;
57
import io.crossplane.compositefunctions.protobuf.v1.State;
68

79
import java.util.Map;
810

911
/**
1012
* Holder for the request from crossplane
13+
* @param requestMeta Holds the tag of the request and the capabilities of the crossplane version running
1114
* @param observedState The observedstate of the crossplane resources
1215
* @param requiredResourcesMap A map of any required resources requested, either dynamic or bootstrap resources
16+
* @param requiredSchemasMap A map of any required schemas requested
1317
* @param credentialsMap A map of credentials sent as input
1418
* @param desiredState The sum of previously called functions state. To override, create a new resource with the same name in the response
1519
*/
16-
public record CrossplaneFunctionRequest(State observedState, Map<String, Resources> requiredResourcesMap,
17-
Map<String, Credentials> credentialsMap, State desiredState) {
20+
public record CrossplaneFunctionRequest(RequestMeta requestMeta, State observedState, Map<String, Resources> requiredResourcesMap,
21+
Map<String, Schema> requiredSchemasMap, Map<String, Credentials> credentialsMap, State desiredState) {
1822

1923
}

‎crossplane-function-base/src/main/java/io/crossplane/compositefunctions/base/CrossplaneFunctionResponse.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io.crossplane.compositefunctions.protobuf.v1.Condition;
44
import io.crossplane.compositefunctions.protobuf.v1.ResourceSelector;
55
import io.crossplane.compositefunctions.protobuf.v1.Result;
6+
import io.crossplane.compositefunctions.protobuf.v1.SchemaSelector;
67

78
import java.util.ArrayList;
89
import java.util.HashMap;
@@ -12,13 +13,15 @@
1213
/**
1314
* Holder for the response to Crossplane
1415
* @param desiredResources Map of the desired resources
15-
* @param resourceSelectors Map of the resource selectors for any extra resources
16+
* @param resourceSelectors Map of the resource selectors for any required resources
17+
* @param schemaSelectors Map of the schema selectors for any required schemas
1618
* @param results List of the results
1719
* @param conditions List of the conditions of the function response
1820
* @param ttl Time to live for the response in positive seconds. This is an alpha feature, and needs to be explicitly enabled in Crossplane.
1921
*/
2022
public record CrossplaneFunctionResponse(Map<String, Object> desiredResources,
2123
Map<String, ResourceSelector> resourceSelectors,
24+
Map<String, SchemaSelector> schemaSelectors,
2225
List<Result> results, List<Condition> conditions,
2326
long ttl) {
2427

@@ -30,6 +33,6 @@ public record CrossplaneFunctionResponse(Map<String, Object> desiredResources,
3033
* Create an empty response with all fields initiated
3134
*/
3235
public CrossplaneFunctionResponse() {
33-
this(new HashMap<>(), new HashMap<>(), new ArrayList<>(), new ArrayList<>(), 0);
36+
this(new HashMap<>(), new HashMap<>(), new HashMap<>(), new ArrayList<>(), new ArrayList<>(), 0);
3437
}
3538
}

‎crossplane-function-base/src/main/java/io/crossplane/compositefunctions/base/model/CrossplaneDesiredObjectStatus.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public enum CrossplaneDesiredObjectStatus {
88
NOT_READY(Ready.READY_FALSE);
99

1010
private final Ready status;
11-
private CrossplaneDesiredObjectStatus(Ready status) {
11+
CrossplaneDesiredObjectStatus(Ready status) {
1212
this.status = status;
1313
}
1414

0 commit comments

Comments
 (0)