Skip to content

Commit

Permalink
Merge pull request #780 from k0sproject/0.11_backport_validate_fix
Browse files Browse the repository at this point in the history
Don't validate empty config files
  • Loading branch information
trawler authored Mar 17, 2021
2 parents 6201f80 + b62f854 commit 0b639fc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import (
"os"
"strings"

config "github.com/k0sproject/k0s/pkg/apis/v1beta1"
"github.com/spf13/cobra"

config "github.com/k0sproject/k0s/pkg/apis/v1beta1"
)

var (
Expand Down Expand Up @@ -49,10 +50,15 @@ func init() {
addPersistentFlags(validateConfigCmd)
}

// XXX: This is a duplication of the code under cmd/helpers.go ConfigFromYaml function.
// XXX: we should fix this and remove the duplication
func validateConfig(cfgPath string) (err error) {
var clusterConfig *config.ClusterConfig

if isInputFromPipe() {
if cfgPath == "" {
// no config file exists, using defaults
clusterConfig = config.DefaultClusterConfig()
} else if isInputFromPipe() {
clusterConfig, err = config.FromYamlPipe(os.Stdin)
} else {
clusterConfig, err = config.FromYamlFile(cfgPath)
Expand Down

0 comments on commit 0b639fc

Please sign in to comment.