From 6503ef75707b8d4fa40e1900df5968e5d5b96b31 Mon Sep 17 00:00:00 2001 From: Yusuke Kuoka Date: Fri, 7 Jun 2024 01:05:47 +0000 Subject: [PATCH] Allow having 2 or more of kanvas.yaml, kanvas.jsonnet, kanvas.template.jsonnet --- convention.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/convention.go b/convention.go index 2387f07..835716b 100644 --- a/convention.go +++ b/convention.go @@ -3,7 +3,6 @@ package kanvas import ( "fmt" "os" - "strings" ) const ( @@ -14,10 +13,14 @@ const ( ) // DiscoverConfigFile returns the path to the config file to use. -// If the config file is not specified, it will try to find the config file in the current directory. -// The config file can be either a kanvas.yaml or kanvas.jsonnet file. // -// If both the yaml and jsonnet config files exist, it will return an error. +// If the config file is not specified, it will try to find the follwoing files in the current directory, +// and return the first one found: +// +// - kanvas.yaml +// - kanvas.jsonnet +// - kanvas.template.jsonnet +// // If the config file is not specified and no config file is found, it will return an error. func DiscoverConfigFile(opts Options) (string, error) { if opts.ConfigFile != "" { @@ -40,9 +43,7 @@ func DiscoverConfigFile(opts Options) (string, error) { found = append(found, DefaultConfigFileTemplateJsonnet) } - if len(found) > 1 { - return "", fmt.Errorf("%d config files %s found. Please specify the config file with --config-file", len(found), strings.Join(found, ", ")) - } else if len(found) == 0 { + if len(found) == 0 { return "", fmt.Errorf("unable to find config file") }