...
1 package config
2
3 import (
4 "context"
5 "time"
6
7 "github.com/sethvargo/go-envconfig"
8 )
9
10 type Configuration struct {
11 DockerCmd string `env:"DOCKER_CMD,default=docker"`
12 Globalodoconfig *string `env:"GLOBALODOCONFIG,noinit"`
13 OdoDebugTelemetryFile *string `env:"ODO_DEBUG_TELEMETRY_FILE,noinit"`
14 OdoDisableTelemetry *bool `env:"ODO_DISABLE_TELEMETRY,noinit"`
15 OdoLogLevel *int `env:"ODO_LOG_LEVEL,noinit"`
16 OdoTrackingConsent *string `env:"ODO_TRACKING_CONSENT,noinit"`
17 PodmanCmd string `env:"PODMAN_CMD,default=podman"`
18 PodmanCmdInitTimeout time.Duration `env:"PODMAN_CMD_INIT_TIMEOUT,default=1s"`
19 TelemetryCaller string `env:"TELEMETRY_CALLER,default="`
20 OdoExperimentalMode bool `env:"ODO_EXPERIMENTAL_MODE,default=false"`
21 PushImages bool `env:"ODO_PUSH_IMAGES,default=true"`
22 OdoContainerBackendGlobalArgs []string `env:"ODO_CONTAINER_BACKEND_GLOBAL_ARGS,noinit,delimiter=;"`
23 OdoImageBuildArgs []string `env:"ODO_IMAGE_BUILD_ARGS,noinit,delimiter=;"`
24 OdoContainerRunArgs []string `env:"ODO_CONTAINER_RUN_ARGS,noinit,delimiter=;"`
25 }
26
27
28
29 func GetConfiguration() (*Configuration, error) {
30 return GetConfigurationWith(envconfig.OsLookuper())
31 }
32
33
34
35
36 func GetConfigurationWith(lookuper envconfig.Lookuper) (*Configuration, error) {
37 var s Configuration
38 c := envconfig.Config{
39 Target: &s,
40 Lookuper: lookuper,
41 }
42 err := envconfig.ProcessWith(context.Background(), &c)
43 if err != nil {
44 return nil, err
45 }
46 return &s, nil
47 }
48
View as plain text