Repository navigation
refactor(sdk): separate OpenTofu execution from deployment orchestration - #12863
Merged
Merged
Conversation
Cover the provider mirror path for a bundle directory with spaces and the refusal of foreign OpenTofu configuration before moving this code. Signed-off-by: Bowen Zhu <[email protected]>
Move OpenTofu configuration, command execution, saved plans, and credential environments from deployment/mod.rs into deployment/opentofu.rs. The moved code changes only in visibility. Signed-off-by: Bowen Zhu <[email protected]>
Teardown repeated initialize inline: it prepared the configuration and ran init -upgrade with the schema environment under the same timing label. Signed-off-by: Bowen Zhu <[email protected]>
4 tasks
cv
approved these changes
Oct 9, 2026
cv
enabled auto-merge (squash)
October 9, 2026 10:01
8 tasks
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
OpenTofu configuration, command execution, saved plans, and credential environments move from
deployment/mod.rsintodeployment/opentofu.rs, and teardown now initializes through that module.mod.rskeeps the public deployment API and the lifecycle. The moved code changes only in visibility.Fixes #12531.
Failure
deployment/mod.rsmixed the public API and the plan, apply, and teardown lifecycle with about 210 lines that run OpenTofu. Those lines writemain.tf.jsonandproviders.tfrc, refuse foreign configuration, choose each command's environment, save plans, and resolve credentials. Teardown also repeatedinitializeinline.Changes
deployment/opentofu.rsholds theDeploymentmethodsinitialize,prepare,tofu,saved_plan, andprovider_environment, and the functionscommand_environment,gateway_environment, andcredential_environment.pub(super)gives them the same reach they had as private items ofdeployment, so the lifecycle inmod.rs, export, the runtime stage, and Helm recovery call them unchanged.mod.rskeeps the API types,run,state_bindings,sandbox_observations, the destroy entry points, and the plan-validation helpers. It shrinks from 704 to 496 lines.initializeinstead ofpreparefollowed bytofu init -upgrade. Both run the same command with the schema environment under thetofu.initlabel.docs/state.mdlinks the new module formain.tf.jsonandproviders.tfrc.Evidence
prepare's signature, which rustfmt wraps oncepub(super)is added.git diff --color-movedshows the rest as moved lines..tf,.tf.json,.tofu, and.tofu.jsonfiles in the state directory are refused without replacingmain.tf.json.providers.tfrckeeps the spaces of a bundle path and uses forward slashes; this pins the generated text, not OpenTofu's parsing of it. Each test fails when the behavior it covers is removed fromprepare.schema_commands_do_not_require_inference_credentials,gateway_observation_resolves_only_gateway_credentials, the twocredential_references_cannot_override_*tests, and the Kubernetes environment tests.discovery_session.rs, which held the second provider-mirror writer and the onlyinit -backend=false.prepareis the only mirror writer outside test harnesses, so neither the sharing step nor the discovery criteria leave anything to change.cargo cipasses on Linux ARM64 (1293 tests, 109 lifecycle tests) and macOS ARM64 (1260 tests, 109 lifecycle tests).cargo ci live-dockerpasses all 10 Docker live tests on Linux.fern checkand thedocs::andfern::tests pass.Not in this PR
state_bindingsstays inmod.rs. It chooses the root or runtime graph before reading state and reaches OpenTofu only throughinitializeand the state store.export.rsand Helm recovery callcrate::process::rundirectly forplan -refresh-only,show -json, andstate mv. Routing them throughtofuwould resolve the full credential environment and add-json, progress, and timing, which changes behavior.Signed-off-by: Bowen Zhu [email protected]