Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRDGenerator: Support for MapType #6668

Open
baloo42 opened this issue Nov 27, 2024 · 0 comments
Open

CRDGenerator: Support for MapType #6668

baloo42 opened this issue Nov 27, 2024 · 0 comments

Comments

@baloo42
Copy link
Contributor

baloo42 commented Nov 27, 2024

Is your enhancement related to a problem? Please describe

In Kubernetes the topology of maps can be described further:

https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#jsonschemaprops-v1-apiextensions-k8s-io

Map restrictions are sometimes required to apply CEL validation rules. Those rules can't be used at the moment because we don't offer a way to configure the topology.

Relates to #5881

Describe the solution you'd like

Suggested Annotation:

/**
 * Annotates a map or object to further describe its topology.
 * <p>
 * Emits {@code x-kubernetes-map-type}
 * </p>
 */
@Inherited
@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.TYPE, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface MapType {

  /**
   * @return the map type
   */
  Type value() default Type.GRANULAR;

  /**
   * The Kubernetes Map Type
   */
  enum Type {
    /**
     * These maps are actual maps (key-value pairs) and each field is independent
     * of each other (they can each be manipulated by separate actors). This is
     * the default behaviour for all maps.
     */
    GRANULAR,

    /**
     * The map is treated as a single entity, like a scalar.
     * Atomic maps will be entirely replaced when updated.
     */
    ATOMIC
  }

}

Describe alternatives you've considered

No response

Additional context

Example:
https://github.com/baloo42/crd-generator-victools/blob/main/test/src/test/java/io/fabric8/crd/generator/victools/approvaltests/maptype/MapTypeSpec.java
https://github.com/baloo42/crd-generator-victools/blob/main/test/src/test/resources/io/fabric8/crd/generator/victools/approvaltests/CRDGeneratorVictoolsApprovalTest.approvalTest.maptypes.samples.fabric8.io.v1.approved.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant