Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused CfgVars origin #5420

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions pkg/config/cfgvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -71,7 +63,6 @@ type CfgVars struct {

stdin io.Reader
nodeConfig *v1beta1.ClusterConfig
origin CfgVarsOriginType
}

func (c *CfgVars) DeepCopy() *CfgVars {
Expand Down Expand Up @@ -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 {
Expand All @@ -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{
Expand All @@ -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")
}
Expand Down
Loading