Skip to content

Latest commit

 

History

History
107 lines (74 loc) · 3.65 KB

CRD-generator-migration-v2.md

File metadata and controls

107 lines (74 loc) · 3.65 KB

Migration from CRD Generator v1 to CRD Generator v2

Overview

CRD Generator v1

Deprecated since 7.0.0

  • CRD Generator API v1 - io.fabric8:crd-generator-api
    Core implementation of the old generator, based on sundrio.
  • CRD Generator annotation processing tool (APT) - io.fabric8:crd-generator-apt
    Annotation processor which hooks into the build process to generate CRDs.

CRD Generator v2

GA since 7.0.0

  • CRD Generator API v2 - io.fabric8:crd-generator-api-v2
    Core implementation of the new generator, based on Jackson/jsonSchema.
  • CRD Generator Collector - io.fabric8:crd-generator-collector
    Shared component to find and load compiled Custom Resource classes in directories and Jar files.
  • CRD Generator Maven Plugin - io.fabric8:crd-generator-maven-plugin
    Maven plugin that generates CRDs during the build process.
  • CRD Generator CLI - io.fabric8:crd-generator-cli
    CLI tool that generates CRDs when executed.

API Compatibility

CRD Generator v1 and v2 are using the same set of annotations.
This means you can keep your code as is and replace just the CRD Generator annotation processor with your tool of choice.

The API itself is not compatible but very similar.

Breaking Changes

New restrictions on annotations

With CRD Generator v2 the following annotations are restricted to certain field types:

  • @Min and @Max are restricted to numeric fields
  • @Pattern is restricted to string fields

Migrating from v6

In case you are migrating directly from fabric8/kubernetes-client v6, the following change affects you:

The type of format in @PrinterColumn has changed from string to enum PrinterColumnFormat.

New Tooling

To replace the CRD Generator annotation processor you can use the following tools:

The tools use the same base, which means they should generate the same CRDs if similar configuration parameter are used. One of the enhancements of the new tooling is that they can be configured easily. Please read the README of the tool for details on usage and configuration.

New annotations

Several new annotations have been introduced since 7.0.0. They will be used by the CRD Generator v2 implementation only since CRD Generator v1 won't get new features from now on.

  • @Categories
  • @AdditionalPrinterColumn
  • @SelectableField
  • @AdditionalSelectableField
  • @Size

Read the Javadoc of the annotations and the CRD Generator documentation to get details.

@Min / @Max inclusiveness

The @Min and @Max annotations have been extended with a second argument to define the inclusiveness. By default, the value in the annotation is meant to be inclusive like before.

Annotated Types

@Pattern, @Min, @Max will be detected if they are used to annotate the type of a List or a Map.

Example:

List<@Pattern("(a|b)") String> myList;
Map<String, @Pattern("(a|b)") String> myMap;

Result:

myList:
  items:
    pattern: "(a|b)+"
    type: "string"
  type: "array"
myMap:
  additionalProperties:
    pattern: "(a|b)+"
    type: "string"
  type: "object"

Default values for CRD fields can be numeric or boolean

Previously default values defined by @Default could only be used on string fields. With CRD Generator v2 defaults can be set on numeric and boolean fields, too. In the same way is @JsonProperty(defaultValue) now working.