Set up first container image build process with instructions.

This commit is contained in:
2025-05-17 11:06:07 -05:00
parent 1dc68374e3
commit 1fa4473244
5 changed files with 129 additions and 6 deletions

View File

@ -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())