Revert "cmd: accept an !include tag for YAML files"

This reverts commit b8698bc060. This
change is not complete, it is missing adaptations in docker-compose.yml.
This commit is contained in:
Vincent Bernat
2023-02-12 14:40:56 +01:00
parent 829887f1e0
commit cdbae1c643
22 changed files with 422 additions and 593 deletions

View File

@@ -6,11 +6,11 @@ package cmd
import (
"fmt"
"io"
"io/ioutil"
"mime"
"net/http"
"net/url"
"os"
"path/filepath"
"reflect"
"sort"
"strconv"
@@ -19,8 +19,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/go-playground/validator/v10"
"github.com/mitchellh/mapstructure"
"akvorado/common/helpers/yaml"
"gopkg.in/yaml.v3"
"akvorado/common/helpers"
)
@@ -67,15 +66,11 @@ func (c ConfigRelatedOptions) Parse(out io.Writer, component string, config inte
return fmt.Errorf("unable to parse YAML configuration file: %w", err)
}
} else {
cfgFile, err := filepath.EvalSymlinks(cfgFile)
input, err := ioutil.ReadFile(cfgFile)
if err != nil {
return fmt.Errorf("cannot follow symlink: %w", err)
return fmt.Errorf("unable to read configuration file: %w", err)
}
dirname, filename := filepath.Split(cfgFile)
if dirname == "" {
dirname = "."
}
if err := yaml.UnmarshalWithInclude(os.DirFS(dirname), filename, &rawConfig); err != nil {
if err := yaml.Unmarshal(input, &rawConfig); err != nil {
return fmt.Errorf("unable to parse YAML configuration file: %w", err)
}
}