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

Primitive default values working now, but enumeration won't #4674

Closed
mteubner opened this issue Dec 14, 2022 · 2 comments · Fixed by #4677
Closed

Primitive default values working now, but enumeration won't #4674

mteubner opened this issue Dec 14, 2022 · 2 comments · Fixed by #4677
Assignees
Milestone

Comments

@mteubner
Copy link

Describe the bug

The generation of the code is now working after fix for #4530 by #4536.

But the generation for enumeration defaults now creates a field with a String value.

public enum State {

    @com.fasterxml.jackson.annotation.JsonProperty("STARTED")
    STARTED("STARTED"), @com.fasterxml.jackson.annotation.JsonProperty("STOPPED")
    STOPPED("STOPPED");

    java.lang.String value;

    State(java.lang.String value) {
        this.value = value;
    }
}

@com.fasterxml.jackson.annotation.JsonProperty("state")
@com.fasterxml.jackson.annotation.JsonSetter(nulls = com.fasterxml.jackson.annotation.Nulls.SKIP)
private State state = "STARTED";

public State getState() {
    return state;
}

public void setState(State state) {
    this.state = state;
}

Fabric8 Kubernetes Client version

6.3.0

Steps to reproduce

  1. Add a object with enumeration to your CRD, like

           state:
             default: STARTED
             enum:
             - STARTED
             - STOPPED
             type: string
    
  2. Generate the code

Expected behavior

Field should not have quotation if object is an enumeration.

private State state = STARTED;

Runtime

other (please specify in additional context)

Kubernetes API Server version

1.25.3@latest

Environment

Windows

Fabric8 Kubernetes Client Logs

No response

Additional context

No response

@andreaTP
Copy link
Member

I think this is a duplicate of #4664 , submitted a fix for it 🙂 , here you are proposing a direct encoding but I believe that passing through serialization is somewhat "safer" in this case (e.g. imagine value names clashing across multiple enums)

@manusa manusa added this to the 6.3.1 milestone Dec 15, 2022
@mteubner
Copy link
Author

@andreaTP Hello thank you for the fast answer. Sorry for not finding the fix. Yes this should work.

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

Successfully merging a pull request may close this issue.

3 participants