Skip to content

Commit 0ea149b

Browse files
authored
Upgrade to 1.15, mainly adding the extra resources (#5)
Signed-off-by: Knut-Erik Johnsen <[email protected]>
1 parent f1693c4 commit 0ea149b

File tree

12 files changed

+1982
-1524
lines changed

12 files changed

+1982
-1524
lines changed

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

Lines changed: 232 additions & 197 deletions
Large diffs are not rendered by default.

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

Lines changed: 1095 additions & 861 deletions
Large diffs are not rendered by default.

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

Lines changed: 531 additions & 420 deletions
Large diffs are not rendered by default.

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
22
kind: CustomResourceDefinition
33
metadata:
44
annotations:
5-
controller-gen.kubebuilder.io/version: v0.13.0
5+
controller-gen.kubebuilder.io/version: v0.14.0
66
name: environmentconfigs.apiextensions.crossplane.io
77
spec:
88
group: apiextensions.crossplane.io
@@ -28,20 +28,26 @@ spec:
2828
values.
2929
properties:
3030
apiVersion:
31-
description: 'APIVersion defines the versioned schema of this representation
32-
of an object. Servers should convert recognized schemas to the latest
33-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
31+
description: |-
32+
APIVersion defines the versioned schema of this representation of an object.
33+
Servers should convert recognized schemas to the latest internal value, and
34+
may reject unrecognized values.
35+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
3436
type: string
3537
data:
3638
additionalProperties:
3739
x-kubernetes-preserve-unknown-fields: true
38-
description: The data of this EnvironmentConfig. This may contain any
39-
kind of structure that can be serialized into JSON.
40+
description: |-
41+
The data of this EnvironmentConfig.
42+
This may contain any kind of structure that can be serialized into JSON.
4043
type: object
4144
kind:
42-
description: 'Kind is a string value representing the REST resource this
43-
object represents. Servers may infer this from the endpoint the client
44-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
45+
description: |-
46+
Kind is a string value representing the REST resource this object represents.
47+
Servers may infer this from the endpoint the client submits requests to.
48+
Cannot be updated.
49+
In CamelCase.
50+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
4551
type: string
4652
metadata:
4753
type: object

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

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
22
kind: CustomResourceDefinition
33
metadata:
44
annotations:
5-
controller-gen.kubebuilder.io/version: v0.13.0
5+
controller-gen.kubebuilder.io/version: v0.14.0
66
name: usages.apiextensions.crossplane.io
77
spec:
88
group: apiextensions.crossplane.io
@@ -32,14 +32,19 @@ spec:
3232
resources.
3333
properties:
3434
apiVersion:
35-
description: 'APIVersion defines the versioned schema of this representation
36-
of an object. Servers should convert recognized schemas to the latest
37-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
35+
description: |-
36+
APIVersion defines the versioned schema of this representation of an object.
37+
Servers should convert recognized schemas to the latest internal value, and
38+
may reject unrecognized values.
39+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
3840
type: string
3941
kind:
40-
description: 'Kind is a string value representing the REST resource this
41-
object represents. Servers may infer this from the endpoint the client
42-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
42+
description: |-
43+
Kind is a string value representing the REST resource this object represents.
44+
Servers may infer this from the endpoint the client submits requests to.
45+
Cannot be updated.
46+
In CamelCase.
47+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
4348
type: string
4449
metadata:
4550
type: object
@@ -53,7 +58,9 @@ spec:
5358
description: API version of the referent.
5459
type: string
5560
kind:
56-
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
61+
description: |-
62+
Kind of the referent.
63+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
5764
type: string
5865
resourceRef:
5966
description: Reference to the resource.
@@ -65,12 +72,14 @@ spec:
6572
- name
6673
type: object
6774
resourceSelector:
68-
description: Selector to the resource. This field will be ignored
69-
if ResourceRef is set.
75+
description: |-
76+
Selector to the resource.
77+
This field will be ignored if ResourceRef is set.
7078
properties:
7179
matchControllerRef:
72-
description: MatchControllerRef ensures an object with the
73-
same controller reference as the selecting object is selected.
80+
description: |-
81+
MatchControllerRef ensures an object with the same controller reference
82+
as the selecting object is selected.
7483
type: boolean
7584
matchLabels:
7685
additionalProperties:
@@ -91,7 +100,9 @@ spec:
91100
description: API version of the referent.
92101
type: string
93102
kind:
94-
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
103+
description: |-
104+
Kind of the referent.
105+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
95106
type: string
96107
resourceRef:
97108
description: Reference to the resource.
@@ -103,12 +114,14 @@ spec:
103114
- name
104115
type: object
105116
resourceSelector:
106-
description: Selector to the resource. This field will be ignored
107-
if ResourceRef is set.
117+
description: |-
118+
Selector to the resource.
119+
This field will be ignored if ResourceRef is set.
108120
properties:
109121
matchControllerRef:
110-
description: MatchControllerRef ensures an object with the
111-
same controller reference as the selecting object is selected.
122+
description: |-
123+
MatchControllerRef ensures an object with the same controller reference
124+
as the selecting object is selected.
112125
type: boolean
113126
matchLabels:
114127
additionalProperties:
@@ -145,13 +158,15 @@ spec:
145158
description: A Condition that may apply to a resource.
146159
properties:
147160
lastTransitionTime:
148-
description: LastTransitionTime is the last time this condition
149-
transitioned from one status to another.
161+
description: |-
162+
LastTransitionTime is the last time this condition transitioned from one
163+
status to another.
150164
format: date-time
151165
type: string
152166
message:
153-
description: A Message containing details about this condition's
154-
last transition from one status to another, if any.
167+
description: |-
168+
A Message containing details about this condition's last transition from
169+
one status to another, if any.
155170
type: string
156171
reason:
157172
description: A Reason for this condition's last transition from
@@ -162,8 +177,9 @@ spec:
162177
False, or Unknown?
163178
type: string
164179
type:
165-
description: Type of this condition. At most one of each condition
166-
type may apply to a resource at any point in time.
180+
description: |-
181+
Type of this condition. At most one of each condition type may apply to
182+
a resource at any point in time.
167183
type: string
168184
required:
169185
- lastTransitionTime

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="release-1.14"
3+
release="release-1.15"
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: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
import io.crossplane.compositefunctions.protobuf.FunctionRunnerServiceGrpc;
5+
import io.crossplane.compositefunctions.protobuf.Requirements;
56
import io.crossplane.compositefunctions.protobuf.RunFunctionRequest;
67
import io.crossplane.compositefunctions.protobuf.RunFunctionResponse;
78
import io.crossplane.compositefunctions.protobuf.State;
@@ -32,9 +33,9 @@ public void runFunction(RunFunctionRequest request, StreamObserver<RunFunctionRe
3233
desiredBuilder.putAllResources(desired.getResourcesMap());
3334

3435
CrossplaneFunctionRequest crossplaneFunctionRequest = new CrossplaneFunctionRequest(request.getObserved(),
35-
request.getDesired());
36+
request.getExtraResourcesMap(), request.getDesired());
3637

37-
// request.getExtraResourcesMap(), request.getCredentialsMap()
38+
// request.getCredentialsMap(),
3839

3940
logger.debug("Calling method with implemented logic");
4041
CrossplaneFunctionResponse crossplaneFunctionResponse = runFunction(crossplaneFunctionRequest);
@@ -46,14 +47,14 @@ public void runFunction(RunFunctionRequest request, StreamObserver<RunFunctionRe
4647

4748
RunFunctionResponse.Builder responseBuilder = RunFunctionResponse.newBuilder();
4849

49-
/*
50+
5051
if (! crossplaneFunctionResponse.resourceSelectors().isEmpty()) {
5152
Requirements requirements = Requirements.newBuilder()
5253
.putAllExtraResources(crossplaneFunctionResponse.resourceSelectors())
5354
.build();
5455
responseBuilder.setRequirements(requirements);
5556
}
56-
*/
57+
5758

5859
if (! crossplaneFunctionResponse.results().isEmpty()) {
5960
responseBuilder.addAllResults(crossplaneFunctionResponse.results());
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
package io.crossplane.compositefunctions.base;
22

3+
import io.crossplane.compositefunctions.protobuf.Resources;
34
import io.crossplane.compositefunctions.protobuf.State;
45

56
import java.util.Map;
67

78
/**
89
* Holder for the request from crossplane
910
* @param observedState The observedstate of the crossplane resources
11+
* @param extraResourcesMap A map of any extra resources requested
1012
* @param desiredState The sum of previously called functions state. To override, create a new resource with the same name in the response
1113
*/
12-
public record CrossplaneFunctionRequest(State observedState, State desiredState) {
14+
public record CrossplaneFunctionRequest(State observedState, Map<String, Resources> extraResourcesMap, State desiredState) {
1315

14-
// * @param extraResourcesMap A map of any extra resources requested
16+
// *
1517
// * @param credentialsMap A map of credentials sent as input
16-
// Map<String, Resources> extraResourcesMap,
18+
//
1719
// Map<String, Credentials> credentialsMap
1820
}
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.crossplane.compositefunctions.base;
22

3+
import io.crossplane.compositefunctions.protobuf.ResourceSelector;
34
import io.crossplane.compositefunctions.protobuf.Result;
45

56
import java.util.ArrayList;
@@ -10,19 +11,21 @@
1011
/**
1112
* Holder for the response to Crossplane
1213
* @param desiredResources Map of the desired resources
14+
* @param resourceSelectors Map of the resource selectors for any extra resources
1315
* @param results List of the results
1416
*/
1517
public record CrossplaneFunctionResponse(Map<String, Object> desiredResources,
18+
Map<String, ResourceSelector> resourceSelectors,
1619
List<Result> results) {
1720

18-
// @param resourceSelectors Map of the resource selectors for any extra resources
19-
// Map<String, ResourceSelector> resourceSelectors,
21+
//
22+
//
2023

2124

2225
/**
2326
* Create an empty response with all fields initiated
2427
*/
2528
public CrossplaneFunctionResponse() {
26-
this(new HashMap<>(), new ArrayList<>());
29+
this(new HashMap<>(), new HashMap<>(), new ArrayList<>());
2730
}
2831
}

crossplane-function-springboot-starter/src/main/java/io/crossplane/compositefunctions/starter/conversion/CrossplaneExtraResourcesService.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,29 @@
22

33
import com.google.protobuf.util.JsonFormat;
44

5+
import io.crossplane.compositefunctions.protobuf.ResourceSelector;
6+
import io.crossplane.compositefunctions.protobuf.Resources;
7+
import io.crossplane.compositefunctions.starter.exception.CrossplaneUnexpectedItemsException;
8+
import io.crossplane.compositefunctions.starter.exception.CrossplaneUnmarshallException;
9+
import io.fabric8.kubernetes.api.model.HasMetadata;
10+
import io.fabric8.kubernetes.client.utils.Serialization;
511
import org.slf4j.Logger;
612
import org.slf4j.LoggerFactory;
713
import org.springframework.stereotype.Component;
814

15+
import java.util.ArrayList;
16+
import java.util.List;
17+
import java.util.Map;
18+
import java.util.Optional;
19+
920

1021
@Component
1122
public class CrossplaneExtraResourcesService {
1223

1324
private static final Logger logger = LoggerFactory.getLogger(CrossplaneExtraResourcesService.class);
1425
private final JsonFormat.Printer printer = JsonFormat.printer();
1526

16-
/*
27+
1728
public <T> Optional<T> getExtraResource(Map<String, Resources> extraResources, String resourceName, Class<T> clazz) {
1829
return getExtraResources(extraResources, resourceName, 1, clazz).get(0);
1930
}
@@ -49,5 +60,5 @@ public Map<String, ResourceSelector> createExtraResourcesSelector(String resourc
4960
return Map.of(resourceName, resourceSelector);
5061
}
5162

52-
*/
63+
5364
}

0 commit comments

Comments
 (0)