-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[java-generator] "package" is not handled as keyword #5380
Comments
Obirah
changed the title
[java-generator] word "package" is not handled as keyword
[java-generator] "package" is not handled as keyword
Aug 10, 2023
Thanks a lot for taking the time to file this issue! I'm actually surprised as we are already sanitizing strings and excluding keywords, but I can reproduce the issue with a CRD like: apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: dummies.example.com
spec:
group: example.com
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
package:
type: object
properties:
foo:
type: object
properties:
bar:
type: string
scope: Namespaced
names:
plural: dummies
singular: dummy
kind: Dummy |
11 tasks
Next time I'll assign the issue to you 😜 😄 ! |
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
When using
io.fabric8.java-generator
to genreate Java code from a CRD which contains an object that is named packagepackage
and has objects underneath it, the generator simply uses the namepackage
as package name even though it is a Java keyword which results in broken code.Fabric8 Kubernetes Client version
6.8.0
Steps to reproduce
Create a CRD which contains an object named
package
anywhere in the Spec or Status.Example for such an object:
Generate code for your CRD and you will see that the package name for the nested object
repository
will look something like this:com.acme.mycr.package
which will not be compilable.Expected behavior
Expected behavior would be to have compilable Java code even when an object is called
package
.In my mind, one possible solution would be to prepend the name of the parent package to the package name if a package is called
package
, e.g. instead ofcom.acme.mycr.package
the generator producescom.acme.mycr.mycrpackage
.Another solution would be to throw an error if a keyword occurs and make the users specify
keywordOverrides
similar to thepackageOverrides
.Runtime
Kubernetes (vanilla)
Kubernetes API Server version
1.25.3@latest
Environment
Linux
Fabric8 Kubernetes Client Logs
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: