mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-08 23:12:18 -04:00
consistently use stdout and stderr (#502)
* consistently use stdout and stderr Signed-off-by: Fabian Kammel <fk@edgeless.systems>
This commit is contained in:
parent
6702b25758
commit
889a6b1893
14 changed files with 61 additions and 59 deletions
|
@ -15,30 +15,30 @@ import (
|
|||
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||
)
|
||||
|
||||
func readConfig(out io.Writer, fileHandler file.Handler, name string) (*config.Config, error) {
|
||||
func readConfig(errWriter io.Writer, fileHandler file.Handler, name string) (*config.Config, error) {
|
||||
cnf, err := config.FromFile(fileHandler, name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := validateConfig(out, cnf); err != nil {
|
||||
if err := validateConfig(errWriter, cnf); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return cnf, nil
|
||||
}
|
||||
|
||||
func validateConfig(out io.Writer, cnf *config.Config) error {
|
||||
func validateConfig(errWriter io.Writer, cnf *config.Config) error {
|
||||
msgs, err := cnf.Validate()
|
||||
if err != nil {
|
||||
return fmt.Errorf("performing config validation: %w", err)
|
||||
}
|
||||
|
||||
if len(msgs) > 0 {
|
||||
fmt.Fprintln(out, "Invalid fields in config file:")
|
||||
fmt.Fprintln(errWriter, "Invalid fields in config file:")
|
||||
for _, m := range msgs {
|
||||
fmt.Fprintln(out, "\t"+m)
|
||||
fmt.Fprintln(errWriter, "\t"+m)
|
||||
}
|
||||
fmt.Fprintln(out, "Fix the invalid entries or generate a new configuration using `constellation config generate`")
|
||||
fmt.Fprintln(errWriter, "Fix the invalid entries or generate a new configuration using `constellation config generate`")
|
||||
return errors.New("invalid configuration")
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue