From e43f7cce9a084dfd547982d87f7c647efea95675 Mon Sep 17 00:00:00 2001 From: Tom Wieczorek Date: Wed, 8 Jan 2025 14:25:03 +0100 Subject: [PATCH] Remove unused CfgVars origin It was never assigned, and the Cleanup method has been unused, as well. Signed-off-by: Tom Wieczorek --- pkg/config/cfgvars.go | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/pkg/config/cfgvars.go b/pkg/config/cfgvars.go index 1863dbb6ab71..024bbbececd1 100644 --- a/pkg/config/cfgvars.go +++ b/pkg/config/cfgvars.go @@ -25,19 +25,11 @@ import ( "os" "path/filepath" - "github.com/k0sproject/k0s/internal/pkg/file" "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1" "github.com/k0sproject/k0s/pkg/constant" "github.com/spf13/pflag" ) -type CfgVarsOriginType int - -const ( - CfgVarsOriginDefault CfgVarsOriginType = iota - CfgVarsOriginRuntime -) - // CfgVars is a struct that holds all the config variables required for K0s // Some of the variables are duplicates of the ones in the CLIOptions struct // for historical and convenience reasons. @@ -71,7 +63,6 @@ type CfgVars struct { stdin io.Reader nodeConfig *v1beta1.ClusterConfig - origin CfgVarsOriginType } func (c *CfgVars) DeepCopy() *CfgVars { @@ -218,8 +209,7 @@ func NewCfgVars(cobraCmd command, dirs ...string) (*CfgVars, error) { HelmRepositoryCache: filepath.Join(helmHome, "cache"), HelmRepositoryConfig: filepath.Join(helmHome, "repositories.yaml"), - stdin: os.Stdin, - origin: CfgVarsOriginDefault, + stdin: os.Stdin, } if cobraCmd != nil { @@ -229,13 +219,6 @@ func NewCfgVars(cobraCmd command, dirs ...string) (*CfgVars, error) { return vars, nil } -func (c *CfgVars) Cleanup() error { - if c.origin == CfgVarsOriginDefault && file.Exists(c.RuntimeConfigPath) { - return os.Remove(c.RuntimeConfigPath) - } - return nil -} - func (c *CfgVars) defaultStorageSpec() *v1beta1.StorageSpec { if c.DefaultStorageType == v1beta1.KineStorageType { return &v1beta1.StorageSpec{ @@ -254,10 +237,6 @@ func (c *CfgVars) NodeConfig() (*v1beta1.ClusterConfig, error) { return c.nodeConfig, nil } - if c.origin == CfgVarsOriginRuntime { - return nil, errors.New("runtime config is not available") - } - if c.StartupConfigPath == "" { return nil, errors.New("config path is not set") }