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

Golang generator does not support Enumerators #3592

Closed
Sgitario opened this issue Nov 15, 2021 · 0 comments · Fixed by #3602
Closed

Golang generator does not support Enumerators #3592

Sgitario opened this issue Nov 15, 2021 · 0 comments · Fixed by #3602
Assignees
Labels
component/go-genarator Deals with the Golang generator part for core and extension models
Milestone

Comments

@Sgitario
Copy link
Contributor

The golang generator for extensions used to map Golang model to Java model does not work properly when the Golang model contains consts (or enums). For example, given the Golang model:

Golang type PeerAuthentication_MutualTLS that uses a const:

type PeerAuthentication_MutualTLS_Mode int32

type PeerAuthentication_MutualTLS struct {
	// Defines the mTLS mode used for peer authentication.
	Mode                 PeerAuthentication_MutualTLS_Mode `protobuf:"varint,1,opt,name=mode,proto3,enum=istio.security.v1beta1.PeerAuthentication_MutualTLS_Mode" json:"mode,omitempty"`
}

Where the const is:

type PeerAuthentication_MutualTLS_Mode int32

const (
	// Inherit from parent, if has one. Otherwise treated as PERMISSIVE.
	PeerAuthentication_MutualTLS_UNSET PeerAuthentication_MutualTLS_Mode = 0
	// Connection is not tunneled.
	PeerAuthentication_MutualTLS_DISABLE PeerAuthentication_MutualTLS_Mode = 1
	// Connection can be either plaintext or mTLS tunnel.
	PeerAuthentication_MutualTLS_PERMISSIVE PeerAuthentication_MutualTLS_Mode = 2
	// Connection is an mTLS tunnel (TLS with client cert must be presented).
	PeerAuthentication_MutualTLS_STRICT PeerAuthentication_MutualTLS_Mode = 3
)

The resulting Java model contains:

// ...
public class PeerAuthentication_MutualTLS implements KubernetesResource
{

    @JsonProperty("mode")
    private Integer mode;
    // ...
}

And the expected output should be:

// ...
public class PeerAuthentication_MutualTLS implements KubernetesResource
{

    @JsonProperty("mode")
    private PeerAuthentication_MutualTLS_Mode mode;
    // ...
}
public enum PeerAuthentication_MutualTLS_Mode {
        // Inherit from parent, if has one. Otherwise treated as PERMISSIVE.
	UNSET,
	// Connection is not tunneled.
	DISABLE,
	// Connection can be either plaintext or mTLS tunnel.
	PERMISSIVE,
	// Connection is an mTLS tunnel (TLS with client cert must be presented).
	STRICT;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/go-genarator Deals with the Golang generator part for core and extension models
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants