Skip to content

Conversation

@eshulman2
Copy link
Contributor

@eshulman2 eshulman2 commented Dec 30, 2025

To avoid cyclomatic complexity issue I added a global dependency helper that reduces code duplication and complexity across the code (similar to the one I added to the server controller). Now it should be easier to manage dependencies and the code duplication should be (somewhat reduced).

  • create a dependency helper replacing repetitive parts of code
  • update template to use it

@github-actions github-actions bot added the semver:patch No API change label Dec 30, 2025
@eshulman2 eshulman2 changed the title globalize get dependency helper Cyclomatic complexity: globalize get dependency helper Dec 30, 2025
@eshulman2 eshulman2 changed the title Cyclomatic complexity: globalize get dependency helper Cyclomatic complexity: globalize fetch dependency helper Dec 31, 2025
Copy link
Collaborator

@mandre mandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is great! Would it also be possible to update existing controllers to use this new FetchDependency() function? This would help visualize the changes made to the template.

Description: string(ptr.Deref(filter.Description, "")),
{{- range .ImportDependencies }}
{{ . }}: ptr.Deref({{ . | camelCase }}.Status.ID, ""),
{{ . }}ID: {{ . | camelCase }}ID,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this a bug in the original template? I'm unclean why this is changed while ImportDependencies remains identical.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most ID fields in gophercloud uses ResourceID in ListOpts from what I saw so the change seemed appropriate, I can change it back if needed

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gophercloud is not really consistent, so either is fine. We should probably have avoided a functional change in a refactoring PR but that's not the end of the world because anyone using the scaffolding tool will have, at some point, to verify what fields the List() function takes, and LSP will highlight invalid fields anyway when your editor is configured correctly.

@eshulman2
Copy link
Contributor Author

@mandre sure, I'll work on updating the rest of the controllers tomorrow

@eshulman2
Copy link
Contributor Author

/retest

@eshulman2 eshulman2 force-pushed the depHelper branch 4 times, most recently from 6709f79 to 7fcbfa9 Compare January 6, 2026 08:41
- create a dependency helper replacing repetative parts of code
- update template to use it
- Remove local getDependencyHelper and wrapper functions from server actuator
- Use dependency.FetchDependency directly in CreateResource and ListOSResourcesForImport
Copy link
Contributor

@winiciusallan winiciusallan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, it looks very good to me. Good job, Ella!

Copy link
Collaborator

@mandre mandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice refactoring. Thanks a lot!

@mandre mandre added this pull request to the merge queue Jan 7, 2026
Merged via the queue into k-orc:main with commit 6a516d7 Jan 7, 2026
9 checks passed
@eshulman2 eshulman2 deleted the depHelper branch January 8, 2026 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver:patch No API change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants