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

Strange *FluentImpl generation behavior #2916

Closed
Fabian-K opened this issue Mar 16, 2021 · 4 comments
Closed

Strange *FluentImpl generation behavior #2916

Fabian-K opened this issue Mar 16, 2021 · 4 comments

Comments

@Fabian-K
Copy link
Contributor

Hi,

while working on #2872 I noticed a strange behavior. When serializing an EventListener, one field is not included for some cases.

The field in question is .spec.resources.customResource. You should be able to include any K8s entity there, the example shows a Knative Service.

apiVersion: "triggers.tekton.dev/v1alpha1"
kind: "EventListener"
metadata:
  name: "sample"
spec:
  resources:
    customResource:
      apiVersion: "serving.knative.dev/v1"
      kind: "Service"
      spec:
        ...

In the model generator, I mapped this to io.fabric8.kubernetes.api.model.HasMetadata. The generated class looks good to me:

public class Resources implements io.fabric8.kubernetes.api.model.KubernetesResource
{

    @JsonProperty("customResource")
    private HasMetadata customResource;
<...>
}

The generated FluentImpl however has some strange logic within withCustomResource which I don´t understand.

public class ResourcesFluentImpl<A extends ResourcesFluent<A>> extends io.fabric8.kubernetes.api.builder.BaseFluent<A> implements ResourcesFluent<A> {

    private VisitableBuilder<? extends HasMetadata,?> customResource;
    
    <...>

    public ResourcesFluentImpl(Resources instance) {
        this.withCustomResource(instance.getCustomResource()); 
        this.withKubernetesResource(instance.getKubernetesResource()); 
    }

    public A withCustomResource(HasMetadata customResource) {
        if (customResource instanceof TriggerTemplate){ this.customResource= new TriggerTemplateBuilder((TriggerTemplate)customResource); _visitables.get("customResource").add(this.customResource);}
        if (customResource instanceof TriggerBinding){ this.customResource= new TriggerBindingBuilder((TriggerBinding)customResource); _visitables.get("customResource").add(this.customResource);}
        if (customResource instanceof ClusterTriggerBinding){ this.customResource= new ClusterTriggerBindingBuilder((ClusterTriggerBinding)customResource); _visitables.get("customResource").add(this.customResource);}
        if (customResource instanceof EventListener){ this.customResource= new EventListenerBuilder((EventListener)customResource); _visitables.get("customResource").add(this.customResource);}
        return (A) this;
    }

    <...>
}

If I see it correctly, this will drop customResources when it´s not one of the explicitly included classes (TriggerTemplate, TriggerBinding, ...). As a consequence, in my Knative Service example the information is lost.

I hope that does make sense, let me know if you need more information!

Thanks, Fabian

@rohanKanojia
Copy link
Member

rohanKanojia commented Mar 19, 2021

I'm wondering if this behaviour is due to some bug/misconfiguration in sundrio

@stale
Copy link

stale bot commented Jun 17, 2021

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

@shawkins
Copy link
Contributor

Addressed by sundrio/sundrio#374 and sundrio/sundrio#350

We can mark this as resolved once we get a new sundrio release.

@stale
Copy link

stale bot commented Aug 21, 2023

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

@stale stale bot added the status/stale label Aug 21, 2023
@stale stale bot closed this as completed Sep 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants