Skip to content

Conversation

@rmvangun
Copy link
Contributor

@rmvangun rmvangun commented Nov 14, 2025

Signed-off-by: Ryan VanGundy 85766511+rmvangun@users.noreply.github.com


Note

Eliminates dependency-injector usage across provisioner, terraform stack, Kubernetes manager, and Talos client by passing explicit runtime/clients, updates CLI flows and tests accordingly.

  • Core Refactor (DI removal):
    • pkg/provisioner/Provisioner: embeds *runtime.Runtime; constructor NewProvisioner(rt, blueprintHandler, opts...) creates deps explicitly (optional Terraform based on terraform.enabled), and Up/Down no-op when Terraform disabled.
    • pkg/provisioner/kubernetes/BaseKubernetesManager: NewKubernetesManager(client) now accepts a KubernetesClient; removed Initialize; logic unchanged (SSA apply, waits, health checks).
    • pkg/provisioner/terraform:
      • BaseStack/WindsorStack now take *runtime.Runtime and blueprint.Handler; removed Initialize; use runtime.EnvPrinters.TerraformEnv and runtime.Shell for TF ops; path/source resolution preserved.
    • pkg/provisioner/cluster/TalosClusterClient: removed injector; plain constructor NewTalosClusterClient().
  • CLI and Project Wiring:
    • pkg/project/Project: NewProject(injector, contextName, opts...) builds Composer and Provisioner with new signatures; loads env earlier in Configure.
    • Commands (cmd/check node-health, up, init, bundle, push): construct Runtime/Composer/Provisioner per new APIs; add context override keys (projectOverrides, composerOverrides).
    • Minor UX: up prints success message; workstation Up no longer prints success directly.
  • Tests: Updated across packages to use new constructors and remove Initialize calls; added/adjusted mocks to pass explicit clients/handlers and runtime env printers.

Written by Cursor Bugbot for commit 84609a0. This will update automatically on new commits. Configure here.

We are phasing out the dependency injector. This PR removes it from the provisioner, instead using explicit dependencies passed to constructors.

Signed-off-by: Ryan VanGundy <85766511+rmvangun@users.noreply.github.com>
Signed-off-by: Ryan VanGundy <85766511+rmvangun@users.noreply.github.com>
@rmvangun rmvangun added the chore label Nov 14, 2025
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Bug: Method fails instead of skipping disabled Terraform.

The Down method returns an error when TerraformStack is nil, but TerraformStack is only created when terraform.enabled config is true. This causes Down to fail even in valid configurations where terraform is disabled. The method should skip terraform operations when the stack is not configured rather than treating it as an error condition.

pkg/provisioner/provisioner.go#L117-L129

// Down orchestrates the high-level infrastructure teardown process. It executes terraform destroy operations
// for all components in the stack in reverse dependency order. Components with Destroy set to false are skipped.
// This method coordinates terraform, kubernetes, and cluster operations to tear down the infrastructure.
// Initializes components as needed. The blueprint parameter is required. Returns an error if any destroy operation fails.
func (i *Provisioner) Down(blueprint *blueprintv1alpha1.Blueprint) error {
if blueprint == nil {
return fmt.Errorf("blueprint not provided")
}
if i.TerraformStack == nil {
return fmt.Errorf("terraform stack not configured")
}

Fix in Cursor Fix in Web


@rmvangun rmvangun changed the title Refactor/remove-di-from-provisioner refactor(provisioner): Remove dependency injector Nov 14, 2025
Signed-off-by: Ryan VanGundy <85766511+rmvangun@users.noreply.github.com>

if err := p.Runtime.LoadEnvironment(false); err != nil {
return fmt.Errorf("failed to load environment: %w", err)
}
Copy link

Choose a reason for hiding this comment

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

Bug: Double Environment Initialization

The Configure method calls LoadEnvironment(false), but Initialize already calls LoadEnvironment(true). Since all commands call Configure followed by Initialize, LoadEnvironment executes twice for every command, causing redundant component initialization and potential side effects from re-initializing environment printers, tools manager, and secrets providers.

Fix in Cursor Fix in Web

@rmvangun rmvangun merged commit 87656c7 into main Nov 14, 2025
13 checks passed
@rmvangun rmvangun deleted the refactor/remove-di-from-provisioner branch November 14, 2025 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants