fix: split more report global keys into raw and computed
Three plugins still leaked the built-in default through `<plugin>-global-<property>` after the broader raw/computed split in #8640. External tooling reading `:report --format json` for drift detection could not distinguish "set to default" from "never set" - after a `:set --global` followed by an unset, the JSON still reported the default value. The `<plugin>-global-<property>` keys now hold the raw stored value (empty when nothing has been set) and `<plugin>-computed-<property>` keys hold the effective value with per-app, global, and built-in default fallback. Every global property now has a computed sibling for shape consistency, including those whose default is empty. Internal callers in `scheduler-k3s` that previously read the default-applied global helpers now consume new `getComputed*` helpers, keeping deploy-time behavior unchanged.
This commit is contained in:
15 files changed
+575
-162
No files matched your search
@@ -40,12 +40,30 @@ import (
|
||||
"k8s.io/utils/ptr"
|
||||
)
|
||||
|
||||
func getKubeconfigPath() string {
|
||||
return common.PropertyGetDefault("scheduler-k3s", "--global", "kubeconfig-path", KubeConfigPath)
|
||||
func getGlobalKubeconfigPath() string {
|
||||
return common.PropertyGet("scheduler-k3s", "--global", "kubeconfig-path")
|
||||
}
|
||||
|
||||
func getKubeContext() string {
|
||||
return common.PropertyGetDefault("scheduler-k3s", "--global", "kube-context", DefaultKubeContext)
|
||||
func getComputedKubeconfigPath() string {
|
||||
kubeconfigPath := getGlobalKubeconfigPath()
|
||||
if kubeconfigPath == "" {
|
||||
kubeconfigPath = KubeConfigPath
|
||||
}
|
||||
|
||||
return kubeconfigPath
|
||||
}
|
||||
|
||||
func getGlobalKubeContext() string {
|
||||
return common.PropertyGet("scheduler-k3s", "--global", "kube-context")
|
||||
}
|
||||
|
||||
func getComputedKubeContext() string {
|
||||
kubeContext := getGlobalKubeContext()
|
||||
if kubeContext == "" {
|
||||
kubeContext = DefaultKubeContext
|
||||
}
|
||||
|
||||
return kubeContext
|
||||
}
|
||||
|
||||
type NotFoundError struct {
|
||||
@@ -84,8 +102,8 @@ type KubernetesClient struct {
|
||||
|
||||
// NewKubernetesClient creates a new Kubernetes client
|
||||
func NewKubernetesClient() (KubernetesClient, error) {
|
||||
kubeconfigPath := getKubeconfigPath()
|
||||
kubeContext := getKubeContext()
|
||||
kubeconfigPath := getComputedKubeconfigPath()
|
||||
kubeContext := getComputedKubeContext()
|
||||
clientConfig := KubernetesClientConfig(kubeconfigPath, kubeContext)
|
||||
restConf, err := clientConfig.ClientConfig()
|
||||
if err != nil {
|
||||
@@ -220,11 +238,11 @@ func (k KubernetesClient) ApplyKubernetesManifest(ctx context.Context, input App
|
||||
input.Manifest,
|
||||
}
|
||||
|
||||
if kubeContext := getKubeContext(); kubeContext != "" {
|
||||
if kubeContext := getComputedKubeContext(); kubeContext != "" {
|
||||
args = append([]string{"--context", kubeContext}, args...)
|
||||
}
|
||||
|
||||
if kubeconfigPath := getKubeconfigPath(); kubeconfigPath != "" {
|
||||
if kubeconfigPath := getComputedKubeconfigPath(); kubeconfigPath != "" {
|
||||
args = append([]string{"--kubeconfig", kubeconfigPath}, args...)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user