mirror of
https://github.com/hanzoai/ingress.git
synced 2026-10-26 02:47:15 +00:00
- Fork github.com/traefik/paerser to github.com/hanzoai/ingress-parser with rebranded prefixes (TRAEFIK_ → INGRESS_, traefik. → ingress.) - Update all 71 Go files importing paerser to use ingress-parser - CLI flags: traefik.configfile → ingress.configfile - Env prefix: TRAEFIK_* → INGRESS_* - Deprecation loader: traefik. label prefix → ingress. - Recompute digest auth test hashes for realm "ingress" - Rename traefiker test realm → ingresser - Fix remaining comment URLs to hanzoai/ingress 7 remaining "traefik" refs are Go import paths for external packages (traefik/yaegi, traefik/grpc-web) — these are the packages' module identity, cannot be renamed without forking the entire Go interpreter and gRPC-Web proxy.
32 lines
903 B
Go
32 lines
903 B
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/rs/zerolog/log"
|
|
"github.com/hanzoai/ingress-parser/cli"
|
|
"github.com/hanzoai/ingress-parser/env"
|
|
)
|
|
|
|
// EnvLoader loads a configuration from all the environment variables prefixed with "INGRESS_".
|
|
type EnvLoader struct{}
|
|
|
|
// Load loads the command's configuration from the environment variables.
|
|
func (e *EnvLoader) Load(_ []string, cmd *cli.Command) (bool, error) {
|
|
vars := env.FindPrefixedEnvVars(os.Environ(), env.DefaultNamePrefix, cmd.Configuration)
|
|
if len(vars) == 0 {
|
|
return false, nil
|
|
}
|
|
|
|
if err := env.Decode(vars, env.DefaultNamePrefix, cmd.Configuration); err != nil {
|
|
log.Debug().Msgf("environment variables: %s", strings.Join(vars, ", "))
|
|
return false, fmt.Errorf("failed to decode configuration from environment variables: %w", err)
|
|
}
|
|
|
|
log.Print("Configuration loaded from environment variables")
|
|
|
|
return true, nil
|
|
}
|