community icon indicating copy to clipboard operation
community copied to clipboard

Allow configuration of `SetManyOutputNotFoundErrReturn` per Operation

Open EdgeJ opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Now that the setResourceReadMany function has been set to pull double duty when passed a Create operation with a list element as the output (in https://github.com/aws-controllers-k8s/code-generator/pull/337) there can arise problems from the return value within the loop. Create and Describe operations can be used in different places in Go code (the templates for Crossplane generation specifically) that expect different return types (e.g. the number of returned objects).

Describe the solution you'd like I think it would make sense and not be particularly difficult to implement adding an additional config to apply SetManyOutputNotFoundErrReturn options from the Operations configs.

I'm Imagining something like this:

operations:
  CreateLoadBalancer:
    operation_type:
      - Create
    output_wrapper_field_path: LoadBalancers
    set_many_output_notfound_err_return: return nil, errors.New(errNotFound)

Describe alternatives you've considered Other than setting the top level option to something no-op (e.g. setting to something like "_ = found"), I don't think there's really much of a workaround here.

EdgeJ avatar Jul 01 '22 20:07 EdgeJ

@EdgeJ As I noted in comments in the https://github.com/aws-controllers-k8s/code-generator/pull/337 review, the code for SetResourceReadyMany is getting really ugly and messy. I think the longer-term solution there is to have two separate Go code-generating functions, one for the "find-a-specific-resource-in-a-list-of-resources" problem and another function that actually sets values on the resource that is returned from the first function. This second function should probably just be the "normal" SetResource function implementation that assumes a single resource object and sets field values on it.

jaypipes avatar Jul 11 '22 13:07 jaypipes

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with /close. Provide feedback via https://github.com/aws-controllers-k8s/community. /lifecycle stale

eks-bot avatar Oct 09 '22 16:10 eks-bot

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. If this issue is safe to close now please do so with /close. Provide feedback via https://github.com/aws-controllers-k8s/community. /lifecycle rotten

eks-bot avatar Nov 08 '22 16:11 eks-bot

/remove-lifecycle rotten

a-hilaly avatar Nov 08 '22 18:11 a-hilaly

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with /close. Provide feedback via https://github.com/aws-controllers-k8s/community. /lifecycle stale

ack-bot avatar Feb 08 '23 21:02 ack-bot

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with /close. Provide feedback via https://github.com/aws-controllers-k8s/community. /lifecycle stale

ack-bot avatar May 10 '23 03:05 ack-bot

/lifecycle frozen

RedbackThomson avatar May 16 '23 17:05 RedbackThomson