...

Source file src/github.com/redhat-developer/odo/pkg/config/config.go

Documentation: github.com/redhat-developer/odo/pkg/config

     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  // GetConfiguration initializes a Configuration for odo by using the system environment.
    28  // See GetConfigurationWith for a more configurable version.
    29  func GetConfiguration() (*Configuration, error) {
    30  	return GetConfigurationWith(envconfig.OsLookuper())
    31  }
    32  
    33  // GetConfigurationWith initializes a Configuration for odo by using the specified envconfig.Lookuper to resolve values.
    34  // It is recommended to use this function (instead of GetConfiguration) if you don't need to depend on the current system environment,
    35  // typically in unit tests.
    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