Compare commits
4 Commits
main
...
1.15.0-del
Author | SHA1 | Date |
---|---|---|
|
ee19313ea9 | |
|
58cf299286 | |
|
f25bf16b83 | |
|
22907e78a0 |
|
@ -26,7 +26,7 @@ jobs:
|
||||||
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
|
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
|
||||||
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
|
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
|
||||||
- name: Set the revision property
|
- name: Set the revision property
|
||||||
run: mvn versions:set-property -Dproperty=revision "-DnewVersion==${{ github.event.inputs.releaseversion }}" -DgenerateBackupPoms=false
|
run: mvn versions:set-property -Dproperty=revision "-DnewVersion=${{ github.event.inputs.releaseversion }}" -DgenerateBackupPoms=false
|
||||||
- name: Build with Maven
|
- name: Build with Maven
|
||||||
run: mvn -B deploy --file pom.xml -Pdeploy
|
run: mvn -B deploy --file pom.xml -Pdeploy
|
||||||
env:
|
env:
|
||||||
|
@ -40,5 +40,6 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
gh release create "$tag" \
|
gh release create "$tag" \
|
||||||
--repo="$GITHUB_REPOSITORY" \
|
--repo="$GITHUB_REPOSITORY" \
|
||||||
--title="${tag#v}" \
|
--title="v${tag#v}" \
|
||||||
--generate-notes
|
--generate-notes \
|
||||||
|
--target "$GITHUB_SHA"
|
|
@ -1,9 +1,48 @@
|
||||||
package io.crossplane.compositefunctions.starter.config;
|
package io.crossplane.compositefunctions.starter.config;
|
||||||
|
|
||||||
|
import io.crossplane.compositefunctions.starter.conversion.CrossplaneExtraResourcesService;
|
||||||
|
import io.crossplane.compositefunctions.starter.conversion.CrossplaneObservableService;
|
||||||
|
import io.crossplane.compositefunctions.starter.conversion.CrossplaneResourceService;
|
||||||
|
import org.checkerframework.checker.units.qual.C;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Autoconfiguration for the crossplane services.
|
||||||
|
*/
|
||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
@ComponentScan(basePackages = {"io.crossplane.compositefunctions.starter.conversion"})
|
|
||||||
public class CrossplaneServiceConfiguration {
|
public class CrossplaneServiceConfiguration {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up services for working with extra resources
|
||||||
|
* @return the crossplaneExtraResourcesService
|
||||||
|
* @since 1.15
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public CrossplaneExtraResourcesService crossplaneExtraResourcesService() {
|
||||||
|
return new CrossplaneExtraResourcesService();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up services for working with observed resources
|
||||||
|
* @return the crossplaneObservableService
|
||||||
|
* @since 1.14
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public CrossplaneObservableService crossplaneObservableService() {
|
||||||
|
return new CrossplaneObservableService();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up services for working with default resources
|
||||||
|
* @return the crossplaneResourceService
|
||||||
|
* @since 1.15
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public CrossplaneResourceService crossplaneResourceService() {
|
||||||
|
return new CrossplaneResourceService();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,21 +4,25 @@ import com.google.protobuf.util.JsonFormat;
|
||||||
|
|
||||||
import io.crossplane.compositefunctions.protobuf.ResourceSelector;
|
import io.crossplane.compositefunctions.protobuf.ResourceSelector;
|
||||||
import io.crossplane.compositefunctions.protobuf.Resources;
|
import io.crossplane.compositefunctions.protobuf.Resources;
|
||||||
import io.crossplane.compositefunctions.starter.exception.CrossplaneUnexpectedItemsException;
|
|
||||||
import io.crossplane.compositefunctions.starter.exception.CrossplaneUnmarshallException;
|
import io.crossplane.compositefunctions.starter.exception.CrossplaneUnmarshallException;
|
||||||
import io.fabric8.kubernetes.api.model.HasMetadata;
|
import io.fabric8.kubernetes.api.model.HasMetadata;
|
||||||
import io.fabric8.kubernetes.client.utils.Serialization;
|
import io.fabric8.kubernetes.client.utils.Serialization;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
@Component
|
* Class that helps with the extra resources map and also to create ResourceSelector in order to get extra resources
|
||||||
|
* to the function
|
||||||
|
*
|
||||||
|
* Commented out in 1.14
|
||||||
|
*
|
||||||
|
* @since 1.15
|
||||||
|
*/
|
||||||
public class CrossplaneExtraResourcesService {
|
public class CrossplaneExtraResourcesService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CrossplaneExtraResourcesService.class);
|
private static final Logger logger = LoggerFactory.getLogger(CrossplaneExtraResourcesService.class);
|
||||||
|
@ -26,17 +30,19 @@ public class CrossplaneExtraResourcesService {
|
||||||
|
|
||||||
|
|
||||||
public <T> Optional<T> getExtraResource(Map<String, Resources> extraResources, String resourceName, Class<T> clazz) {
|
public <T> Optional<T> getExtraResource(Map<String, Resources> extraResources, String resourceName, Class<T> clazz) {
|
||||||
return getExtraResources(extraResources, resourceName, 1, clazz).get(0);
|
List<Optional<T>> resources = getExtraResources(extraResources, resourceName, 1, clazz);
|
||||||
|
|
||||||
|
if (resources.isEmpty()) {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
return resources.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> List<Optional<T>> getExtraResources(Map<String, Resources> extraResources, String resourceName, int expectedResources, Class<T> clazz) {
|
public <T> List<Optional<T>> getExtraResources(Map<String, Resources> extraResources, String resourceName, int expectedResources, Class<T> clazz) {
|
||||||
List<Optional<T>> result = new ArrayList<>();
|
List<Optional<T>> result = new ArrayList<>();
|
||||||
Resources resources = extraResources.get(resourceName);
|
Resources resources = extraResources.get(resourceName);
|
||||||
|
|
||||||
if (resources != null ) {
|
if (resources != null && resources.getItemsCount() == expectedResources) {
|
||||||
if (resources.getItemsCount() != expectedResources) {
|
|
||||||
throw new CrossplaneUnexpectedItemsException("Unexpected number of resources. Expected " + expectedResources + " but got " + resources.getItemsCount() + ".");
|
|
||||||
}
|
|
||||||
for (int i = 0; i < expectedResources; i++) {
|
for (int i = 0; i < expectedResources; i++) {
|
||||||
try {
|
try {
|
||||||
logger.debug("We have an extra resource " + clazz.getSimpleName());
|
logger.debug("We have an extra resource " + clazz.getSimpleName());
|
||||||
|
|
|
@ -8,16 +8,25 @@ import io.crossplane.compositefunctions.starter.exception.CrossplaneUnmarshallEx
|
||||||
import io.fabric8.kubernetes.client.utils.Serialization;
|
import io.fabric8.kubernetes.client.utils.Serialization;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Component
|
/**
|
||||||
|
* Class with helper methods for observable resources.
|
||||||
|
*/
|
||||||
public class CrossplaneObservableService {
|
public class CrossplaneObservableService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CrossplaneObservableService.class);
|
private static final Logger logger = LoggerFactory.getLogger(CrossplaneObservableService.class);
|
||||||
private final JsonFormat.Printer printer = JsonFormat.printer();
|
private final JsonFormat.Printer printer = JsonFormat.printer();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a resource from the observedstate and convert in into class T
|
||||||
|
* @param resourceName The resource name to find in the observed state
|
||||||
|
* @param observedState The observed state from the crossplane input
|
||||||
|
* @param clazz The class/type to create
|
||||||
|
* @return An instance of class T from the observed state
|
||||||
|
* @param <T> The class/type to create
|
||||||
|
*/
|
||||||
public <T> Optional<T> getObservableResource(String resourceName, State observedState, Class<T> clazz) {
|
public <T> Optional<T> getObservableResource(String resourceName, State observedState, Class<T> clazz) {
|
||||||
Resource observedResource = observedState.getResourcesOrDefault(resourceName, null);
|
Resource observedResource = observedState.getResourcesOrDefault(resourceName, null);
|
||||||
Optional<T> result = Optional.empty();
|
Optional<T> result = Optional.empty();
|
||||||
|
|
|
@ -4,15 +4,23 @@ import com.google.protobuf.util.JsonFormat;
|
||||||
import io.crossplane.compositefunctions.protobuf.State;
|
import io.crossplane.compositefunctions.protobuf.State;
|
||||||
import io.crossplane.compositefunctions.starter.exception.CrossplaneUnmarshallException;
|
import io.crossplane.compositefunctions.starter.exception.CrossplaneUnmarshallException;
|
||||||
import io.fabric8.kubernetes.client.utils.Serialization;
|
import io.fabric8.kubernetes.client.utils.Serialization;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Component
|
/**
|
||||||
|
* Class with helper methods for default resources.
|
||||||
|
*/
|
||||||
public class CrossplaneResourceService {
|
public class CrossplaneResourceService {
|
||||||
|
|
||||||
final JsonFormat.Printer printer = JsonFormat.printer();
|
final JsonFormat.Printer printer = JsonFormat.printer();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the incoming Composite to instance of class T
|
||||||
|
* @param observedState The observed state from the crossplane input
|
||||||
|
* @param clazz The class/type to create
|
||||||
|
* @return An instance of class T from the observed state
|
||||||
|
* @param <T> The class/type to create
|
||||||
|
*/
|
||||||
public <T> Optional<T> getResource(State observedState, Class<T> clazz) {
|
public <T> Optional<T> getResource(State observedState, Class<T> clazz) {
|
||||||
try {
|
try {
|
||||||
String resource = printer.print(observedState.getComposite().getResource());
|
String resource = printer.print(observedState.getComposite().getResource());
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
package io.crossplane.compositefunctions.starter.exception;
|
|
||||||
|
|
||||||
public class CrossplaneUnexpectedItemsException extends RuntimeException {
|
|
||||||
|
|
||||||
public CrossplaneUnexpectedItemsException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CrossplaneUnexpectedItemsException(String message, Throwable cause) {
|
|
||||||
super(message, cause);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +1,23 @@
|
||||||
package io.crossplane.compositefunctions.starter.exception;
|
package io.crossplane.compositefunctions.starter.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception for errors when unmarhsalling
|
||||||
|
*/
|
||||||
public class CrossplaneUnmarshallException extends RuntimeException {
|
public class CrossplaneUnmarshallException extends RuntimeException {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor with message
|
||||||
|
* @param message The exception message
|
||||||
|
*/
|
||||||
public CrossplaneUnmarshallException(String message) {
|
public CrossplaneUnmarshallException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor with message and cause
|
||||||
|
* @param message The exception message
|
||||||
|
* @param cause The throwable that caused the exception
|
||||||
|
*/
|
||||||
public CrossplaneUnmarshallException(String message, Throwable cause) {
|
public CrossplaneUnmarshallException(String message, Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,10 @@ package io.crossplane.compositefunctions.starter.registration;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import io.fabric8.kubernetes.api.model.ObjectMeta;
|
import io.fabric8.kubernetes.api.model.ObjectMeta;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class to aid in setting up autoregistration. Used to ignore the default
|
||||||
|
* fields when creating the openapiv3schema
|
||||||
|
*/
|
||||||
public abstract class CrossplaneCompositeResourceMixin {
|
public abstract class CrossplaneCompositeResourceMixin {
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
|
|
|
@ -19,22 +19,33 @@ import io.fabric8.kubernetes.client.dsl.Resource;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static io.crossplane.compositefunctions.starter.registration.CrossplanJsonSchemaGenerator.getOpenAPIV3Schema;
|
import static io.crossplane.compositefunctions.starter.registration.CrossplaneJsonSchemaGenerator.getOpenAPIV3Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service that can register the composite resource together with a function,
|
||||||
|
* which can also add other function to the pipeline definition
|
||||||
|
*/
|
||||||
public class CrossplaneCompositeResourceService {
|
public class CrossplaneCompositeResourceService {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
public static <T extends CustomResource<?, Void>> void registerOrUpdateCompositeResource(String functionName,
|
* Register or update the composite resource definition using the provided client.
|
||||||
List<String> additionalFunctions,
|
* The client needs access to register the types
|
||||||
T functionDefinition,
|
*
|
||||||
|
* @param pipelineFunctions A list of functionnames to add to the composition pipeline
|
||||||
|
* @param compositionDefinition The object that has the composition definiton
|
||||||
|
* @param kubernetesClient The client to use to register the definition
|
||||||
|
* @param <T> Must extend CustomResource
|
||||||
|
*/
|
||||||
|
public static <T extends CustomResource<?, Void>> void registerOrUpdateCompositeResource(List<String> pipelineFunctions,
|
||||||
|
T compositionDefinition,
|
||||||
KubernetesClient kubernetesClient) {
|
KubernetesClient kubernetesClient) {
|
||||||
|
|
||||||
CompositeResourceDefinition compositeResourceDefinition = createCompositeResourceDefinition(functionDefinition);
|
CompositeResourceDefinition compositeResourceDefinition = createCompositeResourceDefinition(compositionDefinition);
|
||||||
|
|
||||||
registerOrUpdateCompositeResourceDefinition(compositeResourceDefinition, kubernetesClient);
|
registerOrUpdateCompositeResourceDefinition(compositeResourceDefinition, kubernetesClient);
|
||||||
|
|
||||||
Composition composition = createCompositionDefinition(functionName, additionalFunctions, functionDefinition);
|
Composition composition = createCompositionDefinition(pipelineFunctions, compositionDefinition);
|
||||||
|
|
||||||
registerOrUpdateCompositeResourceDefinition(composition, kubernetesClient);
|
registerOrUpdateCompositeResourceDefinition(composition, kubernetesClient);
|
||||||
|
|
||||||
|
@ -52,41 +63,49 @@ public class CrossplaneCompositeResourceService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends CustomResource<?, Void>> CompositeResourceDefinition createCompositeResourceDefinition(T functionDefinition) { //}, Class functionMixin) {
|
/**
|
||||||
|
* Create a CompositeResourceDefinition based on the provided CustomResource
|
||||||
|
* If Namespaced, ClaimNames will be added in addition to Names.
|
||||||
|
*
|
||||||
|
* @param compositionDefinition The composition definition
|
||||||
|
* @return A CompositeResourceDefintion based on the provided CustomResource
|
||||||
|
* @param <T> Must extend CustomResource
|
||||||
|
*/
|
||||||
|
public static <T extends CustomResource<?, Void>> CompositeResourceDefinition createCompositeResourceDefinition(T compositionDefinition) { //}, Class functionMixin) {
|
||||||
|
|
||||||
CompositeResourceDefinition compositeResourceDefinition = new CompositeResourceDefinition();
|
CompositeResourceDefinition compositeResourceDefinition = new CompositeResourceDefinition();
|
||||||
compositeResourceDefinition.setMetadata(CrossplaneMetadataBuilder.createMetadata(functionDefinition.getCRDName()));
|
|
||||||
|
|
||||||
CompositeResourceDefinitionSpec spec = new CompositeResourceDefinitionSpec();
|
CompositeResourceDefinitionSpec spec = new CompositeResourceDefinitionSpec();
|
||||||
spec.setGroup(functionDefinition.getGroup());
|
spec.setGroup(compositionDefinition.getGroup());
|
||||||
|
|
||||||
String namePrefix = "";
|
String namePrefix = "";
|
||||||
|
|
||||||
if (functionDefinition instanceof Namespaced) {
|
if (compositionDefinition instanceof Namespaced) {
|
||||||
ClaimNames claimNames = new ClaimNames();
|
ClaimNames claimNames = new ClaimNames();
|
||||||
claimNames.setKind(functionDefinition.getKind());
|
claimNames.setKind(compositionDefinition.getKind());
|
||||||
claimNames.setPlural(functionDefinition.getPlural());
|
claimNames.setPlural(compositionDefinition.getPlural());
|
||||||
claimNames.setSingular(functionDefinition.getSingular());
|
claimNames.setSingular(compositionDefinition.getSingular());
|
||||||
spec.setClaimNames(claimNames);
|
spec.setClaimNames(claimNames);
|
||||||
namePrefix = "x";
|
namePrefix = "x";
|
||||||
}
|
}
|
||||||
|
|
||||||
Names names = new Names();
|
Names names = new Names();
|
||||||
names.setKind(namePrefix + functionDefinition.getKind());
|
names.setKind(namePrefix + compositionDefinition.getKind());
|
||||||
names.setPlural(namePrefix + functionDefinition.getPlural());
|
names.setPlural(namePrefix + compositionDefinition.getPlural());
|
||||||
names.setSingular(namePrefix + functionDefinition.getSingular());
|
names.setSingular(namePrefix + compositionDefinition.getSingular());
|
||||||
spec.setNames(names);
|
spec.setNames(names);
|
||||||
|
|
||||||
Versions versions = new Versions();
|
Versions versions = new Versions();
|
||||||
versions.setName(functionDefinition.getVersion());
|
versions.setName(compositionDefinition.getVersion());
|
||||||
|
|
||||||
// This is not 100%. isStorage vs referencable. Need to check the crossplan docs
|
// This is not 100%. isStorage vs referencable. Need to check the crossplane docs
|
||||||
versions.setReferenceable(functionDefinition.isStorage());
|
versions.setReferenceable(compositionDefinition.isStorage());
|
||||||
versions.setServed(functionDefinition.isServed());
|
versions.setServed(compositionDefinition.isServed());
|
||||||
|
|
||||||
|
compositeResourceDefinition.setMetadata(CrossplaneMetadataBuilder.createMetadata(namePrefix + compositionDefinition.getCRDName()));
|
||||||
|
|
||||||
Schema schema = new Schema();
|
Schema schema = new Schema();
|
||||||
schema.setOpenAPIV3Schema(getOpenAPIV3Schema(functionDefinition.getClass(), CrossplaneCompositeResourceMixin.class));
|
schema.setOpenAPIV3Schema(getOpenAPIV3Schema(compositionDefinition.getClass(), CrossplaneCompositeResourceMixin.class));
|
||||||
|
|
||||||
versions.setSchema(schema);
|
versions.setSchema(schema);
|
||||||
spec.setVersions(List.of(versions));
|
spec.setVersions(List.of(versions));
|
||||||
|
@ -108,26 +127,23 @@ public class CrossplaneCompositeResourceService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T extends CustomResource<?, Void>> Composition createCompositionDefinition(
|
private static <T extends CustomResource<?, Void>> Composition createCompositionDefinition(
|
||||||
String functionName, List<String> additionalFunctions,
|
List<String> pipelineFunctions, T compositionDefinition) {
|
||||||
T functionDefinition) {
|
|
||||||
|
|
||||||
Composition composition = new Composition();
|
Composition composition = new Composition();
|
||||||
|
|
||||||
composition.setMetadata(CrossplaneMetadataBuilder.createMetadata(functionDefinition.getKind().toLowerCase() + "-composition"));
|
composition.setMetadata(CrossplaneMetadataBuilder.createMetadata(compositionDefinition.getKind().toLowerCase() + "-composition"));
|
||||||
CompositionSpec compositionSpec = new CompositionSpec();
|
CompositionSpec compositionSpec = new CompositionSpec();
|
||||||
|
|
||||||
CompositeTypeRef compositeTypeRef = new CompositeTypeRef();
|
CompositeTypeRef compositeTypeRef = new CompositeTypeRef();
|
||||||
compositeTypeRef.setKind(functionDefinition.getKind());
|
compositeTypeRef.setKind(compositionDefinition.getKind());
|
||||||
compositeTypeRef.setApiVersion(functionDefinition.getApiVersion());
|
compositeTypeRef.setApiVersion(compositionDefinition.getApiVersion());
|
||||||
|
|
||||||
compositionSpec.setCompositeTypeRef(compositeTypeRef);
|
compositionSpec.setCompositeTypeRef(compositeTypeRef);
|
||||||
compositionSpec.setMode(CompositionSpec.Mode.PIPELINE);
|
compositionSpec.setMode(CompositionSpec.Mode.PIPELINE);
|
||||||
|
|
||||||
List<Pipeline> pipelineList = new ArrayList<>();
|
List<Pipeline> pipelineList = new ArrayList<>();
|
||||||
|
|
||||||
pipelineList.add(createPipeline(functionName));
|
pipelineFunctions.forEach(s -> pipelineList.add(createPipeline(s)));
|
||||||
|
|
||||||
additionalFunctions.forEach(s -> pipelineList.add(createPipeline(s)));
|
|
||||||
|
|
||||||
compositionSpec.setPipeline(pipelineList);
|
compositionSpec.setPipeline(pipelineList);
|
||||||
composition.setSpec(compositionSpec);
|
composition.setSpec(compositionSpec);
|
||||||
|
|
|
@ -12,8 +12,17 @@ import io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaProps;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class CrossplanJsonSchemaGenerator {
|
/**
|
||||||
|
* Generator of OpenApiV3Schema used when creating CompositeResourceDefinition
|
||||||
|
*/
|
||||||
|
public class CrossplaneJsonSchemaGenerator {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the OpenApiV3Schema
|
||||||
|
* @param clazz The class to create the schema from
|
||||||
|
* @param mixin A mixin to use when Jackson maps the class
|
||||||
|
* @return A OpenAPIV3Schema based on the given class
|
||||||
|
*/
|
||||||
public static OpenAPIV3Schema getOpenAPIV3Schema(Class clazz, Class mixin) {
|
public static OpenAPIV3Schema getOpenAPIV3Schema(Class clazz, Class mixin) {
|
||||||
try {
|
try {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
@ -52,6 +61,11 @@ public class CrossplanJsonSchemaGenerator {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the JSONSchemaProps from the class
|
||||||
|
* @param clazz The class to get the schema from
|
||||||
|
* @return The schemaprops based on the provided class
|
||||||
|
*/
|
||||||
public static JSONSchemaProps getJsonSchema(Class clazz) {
|
public static JSONSchemaProps getJsonSchema(Class clazz) {
|
||||||
try {
|
try {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
@ -73,7 +87,9 @@ public class CrossplanJsonSchemaGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class just use to ignore the ID property that automatically gets added.
|
||||||
|
*/
|
||||||
private abstract class IdIgnorer {
|
private abstract class IdIgnorer {
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
|
@ -6,24 +6,51 @@ import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convinience methods to create the Metadata object in any kubernetes resource
|
||||||
|
*/
|
||||||
public class CrossplaneMetadataBuilder {
|
public class CrossplaneMetadataBuilder {
|
||||||
|
|
||||||
private CrossplaneMetadataBuilder() {
|
private CrossplaneMetadataBuilder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create metadata with name
|
||||||
|
* @param name The name of the resource
|
||||||
|
* @return The metdata object based on the input
|
||||||
|
*/
|
||||||
|
public static ObjectMeta createMetadata(String name) {
|
||||||
|
return createMetadata(name, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create metadata with name and namespace
|
||||||
|
* @param name The name of the resource
|
||||||
|
* @param namespace The namespace of the resource
|
||||||
|
* @return The metdata object based on the input
|
||||||
|
*/
|
||||||
public static ObjectMeta createMetadata(String name, String namespace) {
|
public static ObjectMeta createMetadata(String name, String namespace) {
|
||||||
return createMetadata(name, namespace, null);
|
return createMetadata(name, namespace, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create metadata with name, namespace and annotations
|
||||||
|
* @param name The name of the resource
|
||||||
|
* @param namespace The namespace of the resource
|
||||||
|
* @param annotations Annotations to add to the metadata
|
||||||
|
* @return The metdata object based on the input
|
||||||
|
*/
|
||||||
public static ObjectMeta createMetadata(String name, String namespace, Map<String, String> annotations) {
|
public static ObjectMeta createMetadata(String name, String namespace, Map<String, String> annotations) {
|
||||||
return new ObjectMetaBuilder().withName(name).withNamespace(namespace).withAnnotations(annotations).build();
|
return new ObjectMetaBuilder().withName(name).withNamespace(namespace).withAnnotations(annotations).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static ObjectMeta createMetadata(String name) {
|
/**
|
||||||
return createMetadata(name, null);
|
* Add extra metadata to a Metadata object
|
||||||
}
|
* @param annotations The extra metadata to add
|
||||||
|
* @param objectMeta The metadata object to add it to
|
||||||
|
* @return The metadata with the added annotations
|
||||||
|
*/
|
||||||
public static ObjectMeta addAnnotations(Map<String, String> annotations, ObjectMeta objectMeta) {
|
public static ObjectMeta addAnnotations(Map<String, String> annotations, ObjectMeta objectMeta) {
|
||||||
|
|
||||||
Map<String, String> existingAnnotations = objectMeta.getAnnotations();
|
Map<String, String> existingAnnotations = objectMeta.getAnnotations();
|
||||||
|
|
47
pom.xml
47
pom.xml
|
@ -6,7 +6,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>3.3.1</version>
|
<version>3.3.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>io.crossplane.compositefunctions</groupId>
|
<groupId>io.crossplane.compositefunctions</groupId>
|
||||||
|
@ -25,11 +25,11 @@
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
|
||||||
<!-- Dependency versions -->
|
<!-- Dependency versions -->
|
||||||
<spring-boot.version>3.3.1</spring-boot.version>
|
<spring-boot.version>3.3.3</spring-boot.version>
|
||||||
<kubernetes-client.version>6.13.0</kubernetes-client.version>
|
<kubernetes-client.version>6.13.3</kubernetes-client.version>
|
||||||
<os-maven-plugin.version>1.7.1</os-maven-plugin.version>
|
<os-maven-plugin.version>1.7.1</os-maven-plugin.version>
|
||||||
<protobuf.version>3.25.1</protobuf.version>
|
<protobuf.version>3.25.1</protobuf.version>
|
||||||
<grpc.version>1.64.0</grpc.version>
|
<grpc.version>1.63.0</grpc.version>
|
||||||
<jakarta-annotation.version>1.3.5</jakarta-annotation.version>
|
<jakarta-annotation.version>1.3.5</jakarta-annotation.version>
|
||||||
<slf4j.version>2.0.13</slf4j.version>
|
<slf4j.version>2.0.13</slf4j.version>
|
||||||
<jackson-databind.version>2.17.1</jackson-databind.version>
|
<jackson-databind.version>2.17.1</jackson-databind.version>
|
||||||
|
@ -100,43 +100,10 @@
|
||||||
<!-- Protobuf -->
|
<!-- Protobuf -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.grpc</groupId>
|
<groupId>io.grpc</groupId>
|
||||||
<artifactId>grpc-protobuf</artifactId>
|
<artifactId>grpc-bom</artifactId>
|
||||||
<version>${grpc.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.grpc</groupId>
|
|
||||||
<artifactId>grpc-stub</artifactId>
|
|
||||||
<version>${grpc.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.grpc</groupId>
|
|
||||||
<artifactId>grpc-core</artifactId>
|
|
||||||
<version>${grpc.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.grpc</groupId>
|
|
||||||
<artifactId>grpc-api</artifactId>
|
|
||||||
<version>${grpc.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.grpc</groupId>
|
|
||||||
<artifactId>grpc-util</artifactId>
|
|
||||||
<version>${grpc.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.grpc</groupId>
|
|
||||||
<artifactId>grpc-services</artifactId>
|
|
||||||
<version>${grpc.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.grpc</groupId>
|
|
||||||
<artifactId>grpc-inprocess</artifactId>
|
|
||||||
<version>${grpc.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.grpc</groupId>
|
|
||||||
<artifactId>grpc-netty-shaded</artifactId>
|
|
||||||
<version>${grpc.version}</version>
|
<version>${grpc.version}</version>
|
||||||
|
<scope>import</scope>
|
||||||
|
<type>pom</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.annotation</groupId>
|
<groupId>jakarta.annotation</groupId>
|
||||||
|
|
Loading…
Reference in New Issue