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

feat(crd-generator): Add CRD-Generator CLI #6337

Merged
merged 11 commits into from
Nov 18, 2024
Merged

Conversation

baloo42
Copy link
Contributor

@baloo42 baloo42 commented Sep 7, 2024

Description

Fixes #5958
Relates to #5950

Add CRD-Generator CLI application (using api-v2).

Usage:

crd-gen [-hVv] [--force-index] [--force-scan] [--implicit-preserve-unknown-fields] [--no-parallel]
        [-o=<outputDirectory>] [-cp=<classpathElement>]... [--exclude-package=<package>]...
        [--include-package=<package>]... <source>...

Description:

Fabric8 CRD-Generator
Generate Custom Resource Definitions (CRD) for Kubernetes from Java classes.

Parameters:
      <source>...     A directory or JAR file to scan for Custom Resource classes, or a full qualified Custom Resource
                        class name.

Options:
  -o, --output-dir=<outputDirectory>
                      The output directory where the CRDs are emitted.
                        Default: .
      -cp, --classpath=<classpathElement>
                      Additional classpath element, e.g. a dependency packaged as JAR file or a directory of class
                        files.
      --force-index   Create Jandex index even if the directory or JAR file contains an existing index.
      --force-scan    Scan directories and JAR files even if Custom Resource classes are given.
      --no-parallel   Disable parallel generation of CRDs.
      --implicit-preserve-unknown-fields
                      `x-kubernetes-preserve-unknown-fields: true` will be added on objects which contain an any-setter
                        or any-getter.
      --include-package=<package>
                      Filter Custom Resource classes after scanning by package inclusions.
      --exclude-package=<package>
                      Filter Custom Resource classes after scanning by package exclusions.
  -v                  Verbose mode. Helpful for troubleshooting.
                      Multiple -v options increase the verbosity.
  -h, --help          Show this help message and exit.
  -V, --version       Print version information and exit.

Exit Codes:
   0   Successful execution
   1   Unexpected error
   2   Invalid input
  70   Custom Resource class loading failed
  80   No Custom Resource classes retained after filtering

Examples:
  Generate CRDs for Custom Resource classes in a directory:
    crd-gen target/classes/
  Generate CRDs for Custom Resource classes in a JAR file:
    crd-gen my-jar-with-custom-resources.jar
  Generate CRD by using a single class only:
    crd-gen -cp target/classes/ com.example.MyCustomResource

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

  • Code contributed by me aligns with current project license: Apache 2.0
  • I Added CHANGELOG entry regarding this change
  • I have implemented unit tests to cover my changes
  • I have added/updated the javadocs and other documentation accordingly
  • No new bugs, code smells, etc. in SonarCloud report

@baloo42 baloo42 force-pushed the iss_5958 branch 3 times, most recently from 97841e9 to 0daccf2 Compare September 7, 2024 19:23
@baloo42 baloo42 marked this pull request as ready for review September 7, 2024 19:30
Copy link
Member

@manusa manusa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine to me,
@metacosm @andreaTP, @shawkins any additional comments?

Copy link
Contributor Author

@baloo42 baloo42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@manusa Thanks for looking into this.

I added some comments where I'm not sure if it's done right.

pom.xml Outdated Show resolved Hide resolved
crd-generator/cli/pom.xml Show resolved Hide resolved
@baloo42 baloo42 force-pushed the iss_5958 branch 3 times, most recently from 8af230d to feeb169 Compare October 6, 2024 14:56
Copy link

@manusa manusa added this to the 7.0.0 milestone Nov 18, 2024 — with automated-tasks
Copy link
Member

@manusa manusa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thx!

@manusa manusa merged commit 6223ac6 into fabric8io:main Nov 18, 2024
20 checks passed
@baloo42 baloo42 deleted the iss_5958 branch November 18, 2024 19:44
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

Successfully merging this pull request may close these issues.

CRDGenerator v2: CLI Application
4 participants