Repository navigation
refactor(bridge): move chart resolution and ConfigMap values out of helm_manager.go - #1067
Merged
Merged
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the Helm manager implementation by extracting chart resolution and component values mutation logic into dedicated files (chart_resolver.go and component_values.go), along with their respective tests. It also moves the mock action runner to a shared test doubles file. Feedback on these changes highlights a potential nil pointer dereference panic in mutateComponentValues due to a missing nil receiver check, and a path traversal vulnerability in containsPathTraversal where Windows-style backslashes are not properly handled on Unix-like systems.
pachopepe
previously approved these changes
Oct 6, 2026
VLukiantsev
force-pushed
the
refactor/helm-split-chart-values
branch
2 times, most recently
from
October 6, 2026 15:00
37078b0 to
db8542e
Compare
…elm_manager.go Pure move, no behaviour change. First slice of the helm_manager.go SRP split: - chart_resolver.go: ChartPathResolver, ResolveComponentChartPath and its path-safety helpers, resolveChartPathForComponent, loadComponentChart. - component_values.go: ComponentValuesConfigMapName, persist/disable/remove ComponentValues, setDisabledValues, extractComponentEnabledFromValuesJSON. - Matching tests move to chart_resolver_test.go and component_values_test.go. - mockHelmActionRunner moves to test_doubles_test.go (also used by reconciler_test.go). TAG=agy CONV=25ae2278-aa0f-44db-af8a-4f9deda0d399
persistComponentValues, disableComponentValues and removeComponentValues each repeated the same RetryOnConflict Get/Create/Update loop and the ConfigMap label literals. They are now one-line valuesMutation functions applied by mutateComponentValues, which owns the retry loop, the no-op detection, and the only ConfigMap constructor. - componentValuesKey/componentValuesKeySuffix replace the ".json" literals, including in hydrateNamespaceFromConfigMap. - Drops the unreachable nil-receiver guards (all callers check m first). - Adds direct tests for every mutation path (create, overwrite, no-op, parameter-preserving disable, remove, missing ConfigMap, nil client). No behaviour change. TAG=agy CONV=25ae2278-aa0f-44db-af8a-4f9deda0d399
…es creation Add TestK8sHelmManager_ComponentValues_CreateAlreadyExistsRetriesAsUpdate to verify that when createComponentValues races with a concurrent writer and receives AlreadyExists, the error is translated to Conflict so RetryOnConflict re-reads the existing ConfigMap, preserves other components' keys, and re-applies the mutation onto the existing entry. TAG=agy CONV=25ae2278-aa0f-44db-af8a-4f9deda0d399
…t in chart_resolver Replace the legacy xmanager_cloud/logging/logging alias with the canonical xmanager_cloud/internal/logging import path to satisfy the google3 legacy import ratchet check. TAG=agy CONV=25ae2278-aa0f-44db-af8a-4f9deda0d399
VLukiantsev
force-pushed
the
refactor/helm-split-chart-values
branch
from
October 6, 2026 15:01
db8542e to
be99c97
Compare
pachopepe
approved these changes
Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First slice of splitting
pkg/components/bridge/helm_manager.go(about 1,500 lines, several unrelated jobs) into files with one job each. This PR moves chart path resolution intochart_resolver.goand the per-component values ConfigMap code intocomponent_values.go. It then merges the three copies of the ConfigMap read-modify-write loop into one.Motivation & Context
K8sHelmManagermixed chart resolution, ConfigMap persistence, Helm execution, health and repair, and actuation state in one file, which made it hard to review and easy to break. The split is a stack of small PRs. The first commit of each PR is a pure move, and the second fixes duplication in the code it just moved.Part 1 of 6 of the
helm_manager.gosplit stack.Key Changes
chart_resolver.go:ChartPathResolver,ResolveComponentChartPathand its path-safety checks,resolveChartPathForComponent,loadComponentChart.component_values.go: the values ConfigMap name, the persist/disable/remove functions,setDisabledValues,extractComponentEnabledFromValuesJSON.chart_resolver_test.goandcomponent_values_test.go.mockHelmActionRunnermoves totest_doubles_test.go, becausereconciler_test.gouses it too.persistComponentValues,disableComponentValuesandremoveComponentValuesbecome one-linevaluesMutations run bymutateComponentValues. That one function owns theRetryOnConflictGet/Create/Update loop, the no-op detection, and the only ConfigMap constructor.componentValuesKeyandcomponentValuesKeySuffixreplace the scattered".json"literals.Assumptions
Verification & Testing
bazel test //pkg/components/bridge:bridge_test --test_output=errors --runs_per_test=3: passes.bazel build //pkg/components/... //cmd/xmc_bridge/...: passes.dupl, addlicense): passes.git diff --color-moved=dimmed-zebra.Related Issues / Bugs
N/A
TAG=agy
CONV=25ae2278-aa0f-44db-af8a-4f9deda0d399