Skip to content

refactor(config): rename embedded SP kubeconfig and namespace env vars - #32

Open
jenniferubah wants to merge 3 commits into
dcm-project:mainfrom
jenniferubah:rename-config-fields
Open

refactor(config): rename embedded SP kubeconfig and namespace env vars#32
jenniferubah wants to merge 3 commits into
dcm-project:mainfrom
jenniferubah:rename-config-fields

Conversation

@jenniferubah

Copy link
Copy Markdown
Contributor

Summary

  • Rename AGENT_KUBECONFIG → SP_DEFAULT_KUBECONFIG (shared default for embedded SPs; SP_KUBECONFIG override unchanged)
  • Rename per-SP namespace env vars:
    • SP_K8S_NAMESPACE → SP_CONTAINER_NAMESPACE / SP_STORAGE_NAMESPACE
    • KUBERNETES_NAMESPACE → SP_VM_NAMESPACE

Assisted-By: Cursor AI

Assisted-By: Cursor AI

Signed-off-by: Jennifer Ubah <cju.cipher@gmail.com>
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Rename embedded SP kubeconfig and namespace environment variables

⚙️ Configuration changes 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Rename the shared embedded-SP kubeconfig default to SP_DEFAULT_KUBECONFIG.
• Give container, storage, and VM providers distinct namespace environment variables.
• Preserve SP_KUBECONFIG precedence and verify container namespace defaults.
Diagram

graph TD
  Env["SP env vars"] -->|"default kubeconfig"| Agent["Agent config"] --> Shared["Shared merge"]
  Shared --> ACM["ACM config"] & Container["Container config"] & Storage["Storage config"] & VM["VM config"]
  Env -->|"provider namespaces"| Container & Storage & VM
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Transitional legacy aliases
  • ➕ Avoids breaking existing deployments immediately
  • ➕ Allows staged migration with deprecation warnings
  • ➖ Adds temporary precedence rules and test cases
  • ➖ Delays removal of ambiguous legacy names

Recommendation: The provider-specific names and dedicated SPConfig are clearer long-term. If existing deployments may still set AGENT_KUBECONFIG, SP_K8S_NAMESPACE, or KUBERNETES_NAMESPACE, add a time-bounded compatibility layer; otherwise the direct rename is the simplest approach.

Files changed (8) +35 / -12

Refactor (1) +1 / -1
config.goSource embedded SP defaults from SPConfig +1/-1

Source embedded SP defaults from SPConfig

• Maps the root configuration's SP.DefaultKubeconfig into shared embedded-provider defaults. Existing SP_KUBECONFIG override behavior remains unchanged.

internal/openshift/shared/config.go

Tests (3) +23 / -5
config_test.goRename ACM kubeconfig precedence test descriptions +2/-2

Rename ACM kubeconfig precedence test descriptions

• Updates test names to identify SP_DEFAULT_KUBECONFIG as the fallback while retaining coverage that SP_KUBECONFIG takes precedence.

internal/openshift/acmcluster/config/config_test.go

config_unit_test.goCover the renamed container namespace setting +19/-1

Cover the renamed container namespace setting

• Updates kubeconfig fallback terminology and environment cleanup. Adds coverage for explicit SP_CONTAINER_NAMESPACE values and the default namespace when it is absent.

internal/openshift/container/config/config_unit_test.go

config_unit_test.goClarify shared kubeconfig precedence tests +2/-2

Clarify shared kubeconfig precedence tests

• Renames shared configuration test cases to reflect SP_DEFAULT_KUBECONFIG fallback and SP_KUBECONFIG override semantics.

internal/openshift/shared/config_unit_test.go

Other (4) +11 / -6
config.goMove the shared kubeconfig default into SP configuration +8/-3

Move the shared kubeconfig default into SP configuration

• Adds SPConfig to the root configuration and loads the shared embedded-provider kubeconfig from SP_DEFAULT_KUBECONFIG. Removes kubeconfig ownership from AgentConfig to clarify that the setting belongs to embedded service providers.

internal/config/config.go

config.goUse a container-specific namespace variable +1/-1

Use a container-specific namespace variable

• Changes container namespace loading from SP_K8S_NAMESPACE to SP_CONTAINER_NAMESPACE while preserving the default namespace value.

internal/openshift/container/config/config.go

config.goUse a VM-specific namespace variable +1/-1

Use a VM-specific namespace variable

• Changes KubeVirt VM namespace loading from KUBERNETES_NAMESPACE to SP_VM_NAMESPACE while retaining the default namespace.

internal/openshift/kubevirtvm/config/config.go

config.goUse a storage-specific namespace variable +1/-1

Use a storage-specific namespace variable

• Changes storage namespace loading from SP_K8S_NAMESPACE to SP_STORAGE_NAMESPACE while preserving the default namespace value.

internal/openshift/storage/config/config.go

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can type 'qodo, fix this' on a finding and the fix lands right on your PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

})

It("uses agent kubeconfig when SP_KUBECONFIG is unset", func() {
It("uses SP_DEFAULT_KUBECONFIG when SP_KUBECONFIG is unset", func() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In production the path is SP_DEFAULT_KUBECONFIG → config.Load → FromAgent → shared.Apply when SP_KUBECONFIG is unset.

This test skips that chain and passes Kubeconfig straight into shared.Agent{...}.
it never reads SP_DEFAULT_KUBECONFIG.

So the old name (“uses agent kubeconfig…”) matched what the test does.
After the rename only the title changed. I don't see a value in this change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated it to kubeconfig from shared.Agent to be more explicit - 94e1ba5

Comment thread internal/config/config.go
type SPConfig struct {
// DefaultKubeconfig is the kubeconfig path shared by all embedded SPs (SP_DEFAULT_KUBECONFIG).
// When empty, SPs use in-cluster configuration unless overridden per SP via SP_KUBECONFIG.
DefaultKubeconfig string `env:"SP_DEFAULT_KUBECONFIG"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SP_DEFAULT_KUBECONFIG moved out of AgentConfig, but internal/config/config_test.go has no case for it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, added test 94e1ba5

type Config struct {
shared.Config
Namespace string `env:"KUBERNETES_NAMESPACE" envDefault:"default"`
Namespace string `env:"SP_VM_NAMESPACE" envDefault:"default"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same small gap as storage. One test for SP_VM_NAMESPACE would mirror the container coverage and guard the KUBERNETES_NAMESPACE rename.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added tests for both 94e1ba5

Assisted-By: Cursor AI

Signed-off-by: Jennifer Ubah <cju.cipher@gmail.com>
Comment thread internal/openshift/acmcluster/config/config_test.go Outdated

@gabriel-farache gabriel-farache left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am just wondering is the new unit test for config are really needed and if those use cases/behaviours are not already tested by IT (or if they should be tested by IT). Especially as only the new SP_* var are tested

@jenniferubah

jenniferubah commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

I am just wondering is the new unit test for config are really needed and if those use cases/behaviours are not already tested by IT (or if they should be tested by IT). Especially as only the new SP_* var are tested

Some of the new tests in the acm and container config were redundant and already covered in the shared tests. While the kubevirtvm and storage config tests are of low value and not really needed. I could remove them

Assisted-By: Cursor AI

Signed-off-by: Jennifer Ubah <cju.cipher@gmail.com>
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.

3 participants