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

Refactor identifier logic in pkg/generate/code #922

Closed
brycahta opened this issue Aug 30, 2021 · 1 comment
Closed

Refactor identifier logic in pkg/generate/code #922

brycahta opened this issue Aug 30, 2021 · 1 comment
Assignees
Labels
kind/enhancement Categorizes issue or PR as related to existing feature enhancements.

Comments

@brycahta
Copy link
Contributor

brycahta commented Aug 30, 2021

Is your feature request related to a problem?
No, this is to consolidate and clean up some recently introduced code that works with shape and model identifiers.

Describe the solution you'd like

crd.go

  • Move getSanitizedMemberPath and FindIdentifiersInCRD here as member functions
  • Introduce GetPrimaryIdentifier member func. Precedence: Arn, Id, Name
    • Not seeing the value in this when FindPrimaryIdentifierFieldNames exists

check.go

  • Move getSanitizedMemberPath out of here

common.go

  • Move Find members relating to CRD to crd.go
  • Add more unit tests to common_test.go

set_resource.go

  • Refactor setResourceForScalar() to no longer construct paths, but simply take fully-qualified target var name and the source var name to set it to.
    • users of setResourceForScalar that use CRD members can use getSanitizedMemberPath to construct fully-qualified name
      • most users of that func also require targetShapeRef which getSanitized doesn't support right now.

set_sdk.go

  • Refactor setSDKReadMany() to use refactored identifier logic

Describe alternatives you've considered
Discussed with @RedbackThomson offline

@brycahta brycahta added the kind/enhancement Categorizes issue or PR as related to existing feature enhancements. label Aug 30, 2021
ack-bot pushed a commit to aws-controllers-k8s/code-generator that referenced this issue Aug 31, 2021
Issue #, if available: [#922](aws-controllers-k8s/community#922)

Description of changes:
* Moving 2 helper funcs to become *methods* of CRD Struct for clearer encapsulation:
  * `GetSanitizedMemberPath`
  * `GetIdentifiers`

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
ack-bot pushed a commit to aws-controllers-k8s/code-generator that referenced this issue Sep 1, 2021
Issue #, if available: [#922](aws-controllers-k8s/community#922)


Description of changes:
* Increasing test coverage of identifier helpers

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
ack-bot pushed a commit to aws-controllers-k8s/code-generator that referenced this issue Sep 2, 2021
Issue #, if available: [#922](aws-controllers-k8s/community#922)

Description of changes:
* Refactor `setSDKReadMany`:
  * use *FindPluralizedIdentifiersInShape* helpers to simplify logic
* Refactor `setResourceForScalar`:
  * Remove unused params
  * Add `targetVar` param to be the variable's fully-qualified name (i.e. fieldPath+varName r.ko.Spec.CacheClusterID)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
@brycahta
Copy link
Contributor Author

brycahta commented Sep 2, 2021

All enhancements have been implemented; resolving.

@brycahta brycahta closed this as completed Sep 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Categorizes issue or PR as related to existing feature enhancements.
Projects
None yet
Development

No branches or pull requests

1 participant