Skip to content

feat(resolver): implement granular resolution and default shard injection#104

Merged
fernando-villalba merged 4 commits intomainfrom
feat/granular-resolver-logic
Jan 5, 2026
Merged

feat(resolver): implement granular resolution and default shard injection#104
fernando-villalba merged 4 commits intomainfrom
feat/granular-resolver-logic

Conversation

@fernando-villalba
Copy link
Collaborator

@fernando-villalba fernando-villalba commented Jan 4, 2026

This PR is needs to be merged before #105

This commit refactors the resolver package to implement the "Granular Resolver Pattern" required for the upcoming validating/mutating webhook.

Changes:

  • Implemented ResolveGlobalTopo, ResolveMultiAdmin, ResolveCell, and ResolveShard to orchestrate the full template resolution cycle (Fetch -> Merge -> Default).
  • Updated PopulateClusterDefaults to inject a mandatory default Shard ("0") if a TableGroup has no shards. This ensures the "Ultra-Minimalist" configuration (End-User Example 1) results in running pods.
  • Moved shared defaulting helpers (defaultStatelessSpec, defaultEtcdSpec) to resolver.go for shared use across components.
  • Fixed template resolution to return empty structs instead of nil for implicit fallbacks, preventing nil-pointer issues in callers.
  • Added comprehensive unit tests for all new resolution methods.

…tion

This commit refactors the resolver package to implement the "Granular
Resolver Pattern" required for the upcoming validating/mutating webhook.

Changes:
- Implemented `ResolveGlobalTopo`, `ResolveMultiAdmin`, `ResolveCell`,
  and `ResolveShard` to orchestrate the full template resolution cycle
  (Fetch -> Merge -> Default).
- Updated `PopulateClusterDefaults` to inject a mandatory default Shard
  ("0") if a TableGroup has no shards. This ensures the "Ultra-Minimalist"
  configuration (End-User Example 1) results in running pods.
- Moved shared defaulting helpers (`defaultStatelessSpec`, `defaultEtcdSpec`)
  to `resolver.go` for shared use across components.
- Fixed template resolution to return empty structs instead of `nil`
  for implicit fallbacks, preventing nil-pointer issues in callers.
- Added comprehensive unit tests for all new resolution methods.
@github-actions

This comment has been minimized.

@rytswd
Copy link
Member

rytswd commented Jan 5, 2026

Looks like the test coverage went down?

github.com/numtide/multigres-operator/pkg/resolver/cluster.go:131:	ResolveMultiAdmin	92.3%

Adds missing test cases to `pkg/resolver/cluster_test.go` to cover conditional branches and edge cases that were previously missed.

Changes:
- Adds "Pre-populated Fields" test case to `PopulateClusterDefaults` to verify that existing values are preserved and defaults are skipped.
- Adds "Fallback" test case to `ResolveMultiAdmin` to cover the path where neither an inline Spec nor a Template is provided.

This ensures all logical branches in `pkg/resolver/cluster.go` are fully exercised.
@github-actions

This comment has been minimized.

@fernando-villalba
Copy link
Collaborator Author

Looks like the test coverage went down?

github.com/numtide/multigres-operator/pkg/resolver/cluster.go:131:	ResolveMultiAdmin	92.3%

Back to 100%

@github-actions

This comment has been minimized.

@github-actions
Copy link

github-actions bot commented Jan 5, 2026

🔬 Go Test Coverage Report

Summary

Coverage Type Result
Threshold 0%
Previous Test Coverage 0.0%
New Test Coverage 100.0%

Status

✅ PASS

Detail

Show New Coverage
github.com/numtide/multigres-operator/pkg/resolver/cell.go:16:		ResolveCell		100.0%
github.com/numtide/multigres-operator/pkg/resolver/cell.go:47:		ResolveCellTemplate	100.0%
github.com/numtide/multigres-operator/pkg/resolver/cell.go:78:		mergeCellConfig		100.0%
github.com/numtide/multigres-operator/pkg/resolver/cluster.go:17:	PopulateClusterDefaults	100.0%
github.com/numtide/multigres-operator/pkg/resolver/cluster.go:91:	ResolveGlobalTopo	100.0%
github.com/numtide/multigres-operator/pkg/resolver/cluster.go:131:	ResolveMultiAdmin	100.0%
github.com/numtide/multigres-operator/pkg/resolver/cluster.go:162:	ResolveCoreTemplate	100.0%
github.com/numtide/multigres-operator/pkg/resolver/defaults.go:57:	DefaultResourcesAdmin	100.0%
github.com/numtide/multigres-operator/pkg/resolver/defaults.go:71:	DefaultResourcesEtcd	100.0%
github.com/numtide/multigres-operator/pkg/resolver/resolver.go:22:	NewResolver		100.0%
github.com/numtide/multigres-operator/pkg/resolver/resolver.go:38:	mergeStatelessSpec	100.0%
github.com/numtide/multigres-operator/pkg/resolver/resolver.go:73:	isResourcesZero		100.0%
github.com/numtide/multigres-operator/pkg/resolver/resolver.go:82:	defaultEtcdSpec		100.0%
github.com/numtide/multigres-operator/pkg/resolver/resolver.go:101:	defaultStatelessSpec	100.0%
github.com/numtide/multigres-operator/pkg/resolver/shard.go:16:		ResolveShard		100.0%
github.com/numtide/multigres-operator/pkg/resolver/shard.go:42:		ResolveShardTemplate	100.0%
github.com/numtide/multigres-operator/pkg/resolver/shard.go:73:		mergeShardConfig	100.0%
github.com/numtide/multigres-operator/pkg/resolver/shard.go:117:	mergeMultiOrchSpec	100.0%
github.com/numtide/multigres-operator/pkg/resolver/shard.go:127:	mergePoolSpec		100.0%
total:									(statements)		100.0%

@fernando-villalba fernando-villalba merged commit 0c8be56 into main Jan 5, 2026
3 checks passed
@fernando-villalba fernando-villalba deleted the feat/granular-resolver-logic branch January 5, 2026 14:47
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.

2 participants