Skip to content

Refactor /inventory code to expose some helpers#4090

Merged
foot merged 10 commits intomainfrom
expose-inventory-helpers
Nov 8, 2023
Merged

Refactor /inventory code to expose some helpers#4090
foot merged 10 commits intomainfrom
expose-inventory-helpers

Conversation

@foot
Copy link
Copy Markdown
Contributor

@foot foot commented Oct 18, 2023

weaveworks/weave-gitops-enterprise#2776

What changed?

  • Refactor inventory code
  • Expose some of it so we can use it any parts of the code eg: in wge
  • Fixes logic to look for children in the parentObjects namespace, not the automation's namespace

Why was this change made?

Other similar CRDs that match the flux inventory pattern can share similar code like this

How was this change implemented?

How did you validate the change?
unit tests

Release notes
Expose some inventory directory helper functions

Documentation Changes

@foot foot force-pushed the expose-inventory-helpers branch from 86a9aaa to 6f356db Compare October 20, 2023 11:05
@ranatrk ranatrk force-pushed the expose-inventory-helpers branch 3 times, most recently from dbea5b3 to dae5fc6 Compare November 2, 2023 13:17
@ranatrk ranatrk marked this pull request as ready for review November 2, 2023 13:53
@ranatrk ranatrk added the type/enhancement New feature or request label Nov 2, 2023
@ranatrk ranatrk requested a review from a team November 2, 2023 14:19
Comment thread core/server/inventory.go Outdated
Comment thread core/server/inventory.go Outdated
result = append(result, entry)
resultMu.Unlock()
}(*o)
// FIXME: do we need this?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When you are getting them from Kubernetes, they should have their namespace (even if it's corev1.NamespaceDefault).

Comment thread core/server/inventory.go Outdated
if unstructuredObj.GetKind() == "Secret" {
unstructuredObj, err = sanitizeUnstructuredSecret(unstructuredObj)
var err error
unstructuredObj, err = SanitizeUnstructuredSecret(unstructuredObj)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SanitizeUnstructuredSecret isn't used outside of the server package?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no, i'll make it private

@ranatrk ranatrk force-pushed the expose-inventory-helpers branch from 1c2e26e to 4199b60 Compare November 6, 2023 14:40
@ranatrk ranatrk requested a review from bigkevmcd November 7, 2023 12:09
Copy link
Copy Markdown
Contributor Author

@foot foot left a comment

Choose a reason for hiding this comment

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

LGTM!

@ranatrk ranatrk force-pushed the expose-inventory-helpers branch from 97584fa to 71167b3 Compare November 8, 2023 12:18
@foot foot merged commit 8e11144 into main Nov 8, 2023
@foot foot deleted the expose-inventory-helpers branch November 8, 2023 12:41
This was referenced Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants