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

CRD-Generator: Selectable fields #6392

Open
baloo42 opened this issue Sep 30, 2024 · 0 comments
Open

CRD-Generator: Selectable fields #6392

baloo42 opened this issue Sep 30, 2024 · 0 comments
Labels
component/crd-generator Related to the CRD generator enhancement

Comments

@baloo42
Copy link
Contributor

baloo42 commented Sep 30, 2024

Is your enhancement related to a problem? Please describe

CRD-Generator should support selectable fields:

https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#crd-selectable-fields

Describe the solution you'd like

CRD-Generator should support it similar to @AdditionalPrinterColumn / @PrinterColumn

Annotations:

/**
 * Marks a field as selectable.
 *
 * @see <a href=
 *      "https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#field-selectors">Kubernetes
 *      Docs - Field Selectors</a>
 */
@Target({ ElementType.FIELD, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface SelectableField {
}
/**
 * Defines a selectable field. Must be placed at the root of the
 * custom resource.
 *
 * @see <a href=
 *      "https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#field-selectors">Kubernetes
 *      Docs - Field Selectors</a>
 */
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(AdditionalSelectableField.List.class)
public @interface AdditionalSelectableField {

  /**
   * The JSON Path to the field.
   *
   * @return the JSON path
   */
  String jsonPath();

  @Retention(RetentionPolicy.RUNTIME)
  @Target(ElementType.TYPE)
  @interface List {
    AdditionalSelectableField[] value();
  }
}

Describe alternatives you've considered

No response

Additional context

Example Approval Test:

https://github.com/baloo42/crd-generator-victools/tree/main/test/src/test/java/io/fabric8/crd/generator/victools/approvaltests/selectablefield
https://github.com/baloo42/crd-generator-victools/blob/main/test/src/test/resources/io/fabric8/crd/generator/victools/approvaltests/CRDGeneratorVictoolsApprovalTest.approvalTest.selectablefields.samples.fabric8.io.v1.approved.yml

Relates to: #6390

@baloo42 baloo42 changed the title Selectable fields for custom resources CRD-Generator: Selectable fields for custom resources Oct 5, 2024
@baloo42 baloo42 changed the title CRD-Generator: Selectable fields for custom resources CRD-Generator: Selectable fields Oct 5, 2024
@manusa manusa added component/crd-generator Related to the CRD generator enhancement labels Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/crd-generator Related to the CRD generator enhancement
Projects
None yet
Development

No branches or pull requests

2 participants