Skip to content

feat: extract nats cluster config lookup from manager#149

Open
thobiaskarlsson wants to merge 1 commit intomainfrom
fix/namespace-clash
Open

feat: extract nats cluster config lookup from manager#149
thobiaskarlsson wants to merge 1 commit intomainfrom
fix/namespace-clash

Conversation

@thobiaskarlsson
Copy link
Collaborator

@thobiaskarlsson thobiaskarlsson commented Mar 2, 2026

Today we are resolving the cluster specific details within the Account Manager, -Factory and even the NATS client (implementation). With the introduction of NatsClusterRef this quickly turns into spaghetti code. A NatsCluster resource defaults to the Account namespace if absent, while legacy secrets lookup (System Account Admin creds & Operator Signing Key) defaults to the NAuth Operator namespace. Due to this it's close to impossible to understand what "default-"/"nauth-"/"operator-"/(simply) namespace relates to. Short answer is that it depends on the context, becoming extremely error-prone. Extracting the lookup of cluster details into a separate, testable port ensures separation of concerns and more focused unit tests, not at least for the (business related) account management flows.

@thobiaskarlsson thobiaskarlsson force-pushed the fix/namespace-clash branch 2 times, most recently from be428aa to 70adaa7 Compare March 3, 2026 13:50
@thobiaskarlsson thobiaskarlsson changed the title refactor: extract nats cluster details lookup feat: extract nats cluster config lookup from manager Mar 3, 2026
@thobiaskarlsson thobiaskarlsson force-pushed the fix/namespace-clash branch 5 times, most recently from d859e19 to cad6926 Compare March 4, 2026 10:30
}
return account
}
// FIXME: Re-write all Account Manager test cases
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

note: After refactoring into interfaces the original Account Manager tests are not working at all. To re-write them would be horribly with the current account secrets handling we have nested within this manager. The plan is to rely on the E2E tests for now, extract the Account Secrets management to it's own testable interface + impl to ensure that Account Manager unit tests focuses on the actual business flow instead of a X^n amount of secret lookup permutations.

Today we are resolving the cluster specific details within the Account Manager, -Factory and even the NATS client (implementation). With the introduction of `NatsClusterRef` this quickly turns into spaghetti code. A `NatsCluster` resource defaults to the Account namespace if absent, while legacy secrets lookup (System Account Admin creds & Operator Signing Key) defaults to the NAuth Operator namespace. Due to this it's close to impossible to understand what "default-"/"nauth-"/"operator-"/(simply) namespace relates to. Short answer is that it depends on the context, becoming extremely error-prone. Extracting the lookup of cluster details into a separate, testable port ensures separation of concerns and more focused unit tests, not at least for the (business related) account management flows.

Signed-off-by: Thobias Karlsson <thobias.karlsson@gmail.com>
@thobiaskarlsson thobiaskarlsson marked this pull request as ready for review March 4, 2026 11:16
@thobiaskarlsson thobiaskarlsson requested a review from a team as a code owner March 4, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant