Upgrade to 1.16, adding the credentialmap and observedgeneration to the crossplane crds (#6)

Signed-off-by: Knut-Erik Johnsen <abstract@knut-erik.org>
This commit is contained in:
Knut-Erik Johnsen 2024-06-25 00:13:46 +02:00 committed by GitHub
parent 0ea149bed5
commit fe64d75730
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 237 additions and 33 deletions

View File

@ -32,9 +32,12 @@ spec:
schema: schema:
openAPIV3Schema: openAPIV3Schema:
description: |- description: |-
A CompositeResourceDefinition defines a new kind of composite infrastructure A CompositeResourceDefinition defines the schema for a new custom Kubernetes
resource. The new resource is composed of other composite or managed API.
infrastructure resources.
Read the Crossplane documentation for
[more information about CustomResourceDefinitions](https://docs.crossplane.io/latest/concepts/composite-resource-definitions).
properties: properties:
apiVersion: apiVersion:
description: |- description: |-
@ -480,6 +483,13 @@ spec:
A Message containing details about this condition's last transition from A Message containing details about this condition's last transition from
one status to another, if any. one status to another, if any.
type: string type: string
observedGeneration:
description: |-
ObservedGeneration represents the .metadata.generation that the condition was set based upon.
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
with respect to the current state of the instance.
format: int64
type: integer
reason: reason:
description: A Reason for this condition's last transition from description: A Reason for this condition's last transition from
one status to another. one status to another.

View File

@ -34,8 +34,12 @@ spec:
schema: schema:
openAPIV3Schema: openAPIV3Schema:
description: |- description: |-
A CompositionRevision represents a revision in time of a Composition. A CompositionRevision represents a revision of a Composition. Crossplane
Revisions are created by Crossplane; they should be treated as immutable. creates new revisions when there are changes to the Composition.
Crossplane creates and manages CompositionRevisions. Don't directly edit
CompositionRevisions.
properties: properties:
apiVersion: apiVersion:
description: |- description: |-
@ -283,7 +287,7 @@ spec:
type: string type: string
mergeOptions: mergeOptions:
description: MergeOptions Specifies merge options on description: MergeOptions Specifies merge options on
a field path a field path.
properties: properties:
appendSlice: appendSlice:
description: Specifies that already existing elements description: Specifies that already existing elements
@ -697,7 +701,7 @@ spec:
type: string type: string
mergeOptions: mergeOptions:
description: MergeOptions Specifies merge options description: MergeOptions Specifies merge options
on a field path on a field path.
properties: properties:
appendSlice: appendSlice:
description: Specifies that already existing elements description: Specifies that already existing elements
@ -987,6 +991,46 @@ spec:
items: items:
description: A PipelineStep in a Composition Function pipeline. description: A PipelineStep in a Composition Function pipeline.
properties: properties:
credentials:
description: Credentials are optional credentials that the Composition
Function needs.
items:
description: |-
FunctionCredentials are optional credentials that a Composition Function
needs to run.
properties:
name:
description: Name of this set of credentials.
type: string
secretRef:
description: |-
A SecretRef is a reference to a secret containing credentials that should
be supplied to the function.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
- namespace
type: object
source:
description: Source of the function credentials.
enum:
- None
- Secret
type: string
required:
- name
- source
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
functionRef: functionRef:
description: |- description: |-
FunctionRef is a reference to the Composition Function this step should FunctionRef is a reference to the Composition Function this step should
@ -1195,7 +1239,7 @@ spec:
type: string type: string
mergeOptions: mergeOptions:
description: MergeOptions Specifies merge options description: MergeOptions Specifies merge options
on a field path on a field path.
properties: properties:
appendSlice: appendSlice:
description: Specifies that already existing elements description: Specifies that already existing elements
@ -1477,7 +1521,7 @@ spec:
items: items:
description: |- description: |-
ReadinessCheck is used to indicate how to tell whether a resource is ready ReadinessCheck is used to indicate how to tell whether a resource is ready
for consumption for consumption.
properties: properties:
fieldPath: fieldPath:
description: FieldPath shows the path of the field whose description: FieldPath shows the path of the field whose
@ -1570,6 +1614,13 @@ spec:
A Message containing details about this condition's last transition from A Message containing details about this condition's last transition from
one status to another, if any. one status to another, if any.
type: string type: string
observedGeneration:
description: |-
ObservedGeneration represents the .metadata.generation that the condition was set based upon.
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
with respect to the current state of the instance.
format: int64
type: integer
reason: reason:
description: A Reason for this condition's last transition from description: A Reason for this condition's last transition from
one status to another. one status to another.
@ -1616,8 +1667,12 @@ spec:
schema: schema:
openAPIV3Schema: openAPIV3Schema:
description: |- description: |-
A CompositionRevision represents a revision in time of a Composition. A CompositionRevision represents a revision of a Composition. Crossplane
Revisions are created by Crossplane; they should be treated as immutable. creates new revisions when there are changes to the Composition.
Crossplane creates and manages CompositionRevisions. Don't directly edit
CompositionRevisions.
properties: properties:
apiVersion: apiVersion:
description: |- description: |-
@ -1865,7 +1920,7 @@ spec:
type: string type: string
mergeOptions: mergeOptions:
description: MergeOptions Specifies merge options on description: MergeOptions Specifies merge options on
a field path a field path.
properties: properties:
appendSlice: appendSlice:
description: Specifies that already existing elements description: Specifies that already existing elements
@ -2279,7 +2334,7 @@ spec:
type: string type: string
mergeOptions: mergeOptions:
description: MergeOptions Specifies merge options description: MergeOptions Specifies merge options
on a field path on a field path.
properties: properties:
appendSlice: appendSlice:
description: Specifies that already existing elements description: Specifies that already existing elements
@ -2569,6 +2624,46 @@ spec:
items: items:
description: A PipelineStep in a Composition Function pipeline. description: A PipelineStep in a Composition Function pipeline.
properties: properties:
credentials:
description: Credentials are optional credentials that the Composition
Function needs.
items:
description: |-
FunctionCredentials are optional credentials that a Composition Function
needs to run.
properties:
name:
description: Name of this set of credentials.
type: string
secretRef:
description: |-
A SecretRef is a reference to a secret containing credentials that should
be supplied to the function.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
- namespace
type: object
source:
description: Source of the function credentials.
enum:
- None
- Secret
type: string
required:
- name
- source
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
functionRef: functionRef:
description: |- description: |-
FunctionRef is a reference to the Composition Function this step should FunctionRef is a reference to the Composition Function this step should
@ -2777,7 +2872,7 @@ spec:
type: string type: string
mergeOptions: mergeOptions:
description: MergeOptions Specifies merge options description: MergeOptions Specifies merge options
on a field path on a field path.
properties: properties:
appendSlice: appendSlice:
description: Specifies that already existing elements description: Specifies that already existing elements
@ -3059,7 +3154,7 @@ spec:
items: items:
description: |- description: |-
ReadinessCheck is used to indicate how to tell whether a resource is ready ReadinessCheck is used to indicate how to tell whether a resource is ready
for consumption for consumption.
properties: properties:
fieldPath: fieldPath:
description: FieldPath shows the path of the field whose description: FieldPath shows the path of the field whose
@ -3152,6 +3247,13 @@ spec:
A Message containing details about this condition's last transition from A Message containing details about this condition's last transition from
one status to another, if any. one status to another, if any.
type: string type: string
observedGeneration:
description: |-
ObservedGeneration represents the .metadata.generation that the condition was set based upon.
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
with respect to the current state of the instance.
format: int64
type: integer
reason: reason:
description: A Reason for this condition's last transition from description: A Reason for this condition's last transition from
one status to another. one status to another.

View File

@ -30,7 +30,13 @@ spec:
name: v1 name: v1
schema: schema:
openAPIV3Schema: openAPIV3Schema:
description: A Composition specifies how a composite resource should be composed. description: |-
A Composition defines a collection of managed resources or functions that
Crossplane uses to create and manage new composite resources.
Read the Crossplane documentation for
[more information about Compositions](https://docs.crossplane.io/latest/concepts/compositions).
properties: properties:
apiVersion: apiVersion:
description: |- description: |-
@ -276,7 +282,7 @@ spec:
type: string type: string
mergeOptions: mergeOptions:
description: MergeOptions Specifies merge options on description: MergeOptions Specifies merge options on
a field path a field path.
properties: properties:
appendSlice: appendSlice:
description: Specifies that already existing elements description: Specifies that already existing elements
@ -690,7 +696,7 @@ spec:
type: string type: string
mergeOptions: mergeOptions:
description: MergeOptions Specifies merge options description: MergeOptions Specifies merge options
on a field path on a field path.
properties: properties:
appendSlice: appendSlice:
description: Specifies that already existing elements description: Specifies that already existing elements
@ -980,6 +986,46 @@ spec:
items: items:
description: A PipelineStep in a Composition Function pipeline. description: A PipelineStep in a Composition Function pipeline.
properties: properties:
credentials:
description: Credentials are optional credentials that the Composition
Function needs.
items:
description: |-
FunctionCredentials are optional credentials that a Composition Function
needs to run.
properties:
name:
description: Name of this set of credentials.
type: string
secretRef:
description: |-
A SecretRef is a reference to a secret containing credentials that should
be supplied to the function.
properties:
name:
description: Name of the secret.
type: string
namespace:
description: Namespace of the secret.
type: string
required:
- name
- namespace
type: object
source:
description: Source of the function credentials.
enum:
- None
- Secret
type: string
required:
- name
- source
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
functionRef: functionRef:
description: |- description: |-
FunctionRef is a reference to the Composition Function this step should FunctionRef is a reference to the Composition Function this step should
@ -1007,6 +1053,9 @@ spec:
- step - step
type: object type: object
type: array type: array
x-kubernetes-list-map-keys:
- step
x-kubernetes-list-type: map
publishConnectionDetailsWithStoreConfigRef: publishConnectionDetailsWithStoreConfigRef:
default: default:
name: default name: default
@ -1188,7 +1237,7 @@ spec:
type: string type: string
mergeOptions: mergeOptions:
description: MergeOptions Specifies merge options description: MergeOptions Specifies merge options
on a field path on a field path.
properties: properties:
appendSlice: appendSlice:
description: Specifies that already existing elements description: Specifies that already existing elements
@ -1470,7 +1519,7 @@ spec:
items: items:
description: |- description: |-
ReadinessCheck is used to indicate how to tell whether a resource is ready ReadinessCheck is used to indicate how to tell whether a resource is ready
for consumption for consumption.
properties: properties:
fieldPath: fieldPath:
description: FieldPath shows the path of the field whose description: FieldPath shows the path of the field whose

View File

@ -24,8 +24,13 @@ spec:
name: v1alpha1 name: v1alpha1
schema: schema:
openAPIV3Schema: openAPIV3Schema:
description: A EnvironmentConfig contains a set of arbitrary, unstructured description: |-
values. An EnvironmentConfig contains user-defined unstructured values for
use in a Composition.
Read the Crossplane documentation for
[more information about EnvironmentConfigs](https://docs.crossplane.io/latest/concepts/environment-configs).
properties: properties:
apiVersion: apiVersion:
description: |- description: |-

View File

@ -28,8 +28,16 @@ spec:
name: v1alpha1 name: v1alpha1
schema: schema:
openAPIV3Schema: openAPIV3Schema:
description: A Usage defines a deletion blocking relationship between two description: |-
resources. A Usage defines a deletion blocking relationship between two resources.
Usages prevent accidental deletion of a single resource or deletion of
resources with dependent resources.
Read the Crossplane documentation for
[more information about Compositions](https://docs.crossplane.io/latest/concepts/usages).
properties: properties:
apiVersion: apiVersion:
description: |- description: |-
@ -168,6 +176,13 @@ spec:
A Message containing details about this condition's last transition from A Message containing details about this condition's last transition from
one status to another, if any. one status to another, if any.
type: string type: string
observedGeneration:
description: |-
ObservedGeneration represents the .metadata.generation that the condition was set based upon.
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
with respect to the current state of the instance.
format: int64
type: integer
reason: reason:
description: A Reason for this condition's last transition from description: A Reason for this condition's last transition from
one status to another. one status to another.

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
release="release-1.15" release="release-1.16"
apiextensions=$(gh api --jq '.[].name' "/repos/crossplane/crossplane/contents/cluster/crds?ref=${release}" | grep apiextensions) apiextensions=$(gh api --jq '.[].name' "/repos/crossplane/crossplane/contents/cluster/crds?ref=${release}" | grep apiextensions)

View File

@ -33,9 +33,8 @@ public abstract class CrossplaneCompositeFunctionBase extends FunctionRunnerServ
desiredBuilder.putAllResources(desired.getResourcesMap()); desiredBuilder.putAllResources(desired.getResourcesMap());
CrossplaneFunctionRequest crossplaneFunctionRequest = new CrossplaneFunctionRequest(request.getObserved(), CrossplaneFunctionRequest crossplaneFunctionRequest = new CrossplaneFunctionRequest(request.getObserved(),
request.getExtraResourcesMap(), request.getDesired()); request.getExtraResourcesMap(), request.getCredentialsMap(), request.getDesired());
// request.getCredentialsMap(),
logger.debug("Calling method with implemented logic"); logger.debug("Calling method with implemented logic");
CrossplaneFunctionResponse crossplaneFunctionResponse = runFunction(crossplaneFunctionRequest); CrossplaneFunctionResponse crossplaneFunctionResponse = runFunction(crossplaneFunctionRequest);

View File

@ -1,5 +1,6 @@
package io.crossplane.compositefunctions.base; package io.crossplane.compositefunctions.base;
import io.crossplane.compositefunctions.protobuf.Credentials;
import io.crossplane.compositefunctions.protobuf.Resources; import io.crossplane.compositefunctions.protobuf.Resources;
import io.crossplane.compositefunctions.protobuf.State; import io.crossplane.compositefunctions.protobuf.State;
@ -9,12 +10,10 @@ import java.util.Map;
* Holder for the request from crossplane * Holder for the request from crossplane
* @param observedState The observedstate of the crossplane resources * @param observedState The observedstate of the crossplane resources
* @param extraResourcesMap A map of any extra resources requested * @param extraResourcesMap A map of any extra resources requested
* @param credentialsMap A map of credentials sent as input
* @param desiredState The sum of previously called functions state. To override, create a new resource with the same name in the response * @param desiredState The sum of previously called functions state. To override, create a new resource with the same name in the response
*/ */
public record CrossplaneFunctionRequest(State observedState, Map<String, Resources> extraResourcesMap, State desiredState) { public record CrossplaneFunctionRequest(State observedState, Map<String, Resources> extraResourcesMap,
Map<String, Credentials> credentialsMap, State desiredState) {
// *
// * @param credentialsMap A map of credentials sent as input
//
// Map<String, Credentials> credentialsMap
} }

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
release="release-1.15" release="release-1.16"
file="run_function.proto" file="run_function.proto"
gh api -H "Accept: application/vnd.github.raw+json" "/repos/crossplane/crossplane/contents/apis/apiextensions/fn/proto/v1beta1/${file}?ref=${release}" > $file gh api -H "Accept: application/vnd.github.raw+json" "/repos/crossplane/crossplane/contents/apis/apiextensions/fn/proto/v1beta1/${file}?ref=${release}" > $file

View File

@ -70,6 +70,24 @@ message RunFunctionRequest {
// did not exist, Crossplane sets the map key to an empty Resources message to // did not exist, Crossplane sets the map key to an empty Resources message to
// indicate that it attempted to satisfy the request. // indicate that it attempted to satisfy the request.
map<string, Resources> extra_resources = 6; map<string, Resources> extra_resources = 6;
// Optional credentials that this Function may use to communicate with an
// external system.
map <string, Credentials> credentials = 7;
}
// Credentials that a Function may use to communicate with an external system.
message Credentials {
// Source of the credentials.
oneof source {
// Credential data loaded by Crossplane, for example from a Secret.
CredentialData credential_data = 1;
}
}
// CredentialData loaded by Crossplane, for example from a Secret.
message CredentialData {
map<string, bytes> data = 1;
} }
// Resources represents the state of several Crossplane resources. // Resources represents the state of several Crossplane resources.
@ -123,11 +141,18 @@ message Requirements {
// ResourceSelector selects a group of resources, either by name or by label. // ResourceSelector selects a group of resources, either by name or by label.
message ResourceSelector { message ResourceSelector {
// API version of resources to select.
string api_version = 1; string api_version = 1;
// Kind of resources to select.
string kind = 2; string kind = 2;
// Resources to match.
oneof match { oneof match {
// Match the resource with this name.
string match_name = 3; string match_name = 3;
// Match all resources with these labels.
MatchLabels match_labels = 4; MatchLabels match_labels = 4;
} }
} }