Set up first container image build process with instructions.
This commit is contained in:
12
cmd/root.go
12
cmd/root.go
@ -19,6 +19,7 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
@ -67,19 +68,18 @@ func initConfig() {
|
||||
viper.SetConfigName("mc-config") // Use "mc-config" as the config file name
|
||||
}
|
||||
|
||||
viper.SetEnvPrefix("MC") // set environment variable prefix
|
||||
viper.AutomaticEnv() // read in environment variables that match
|
||||
viper.SetEnvPrefix("MC") // set environment variable prefix
|
||||
viper.AutomaticEnv() // read in environment variables that match
|
||||
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_")) // Replace `-` with `_` in environment variable keys
|
||||
|
||||
// If a config file is found, read it in.
|
||||
if err := viper.ReadInConfig(); err != nil {
|
||||
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
|
||||
// Config file not found. This is always an error.
|
||||
fmt.Fprintln(os.Stderr, "Error: Config file not found:", err)
|
||||
os.Exit(1)
|
||||
// Config file not found. This is now a warning.
|
||||
fmt.Fprintln(os.Stderr, "Warning: Config file not found. Proceeding with defaults.")
|
||||
} else {
|
||||
// Another error occurred (e.g., malformed YAML). This should be reported.
|
||||
fmt.Fprintln(os.Stderr, "Error reading config file:", err)
|
||||
os.Exit(1) // Exit for other config read errors
|
||||
}
|
||||
} else {
|
||||
fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed())
|
||||
|
Reference in New Issue
Block a user