config

package
v0.0.0-...-a4b769c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package config contains the implementation and data structures related to configurations and configuration (log and adapter config) parsing. If a new configuration is introduced to the adapter configuration file, the corresponding change needs to be added to the relevant data stucture as well.

Index

Constants

View Source
const DefaultGatewayName = "Default"

DefaultGatewayName represents the name of the default gateway

View Source
const DefaultGatewayVHost = "localhost"

DefaultGatewayVHost represents the default vhost of default gateway environment if it is not configured For /testtoken and /health check, if user not configured default env, we have no vhost

View Source
const (
	//UnassignedAsDeprecated is used by the configurations which are deprecated.
	UnassignedAsDeprecated string = "unassigned-as-deprecated"
)

Variables

View Source
var (
	C chan string // better to be interface{} type which could send any type of data.
)

C represents the channel to identify modifications added to the configuration file TODO: (VirajSalaka) remove this as unused.

Functions

func ClearLogConfigInstance

func ClearLogConfigInstance()

ClearLogConfigInstance removes the existing configuration. Then the log configuration can be re-initialized.

func GetControlPlaneConnectedTenantDomain

func GetControlPlaneConnectedTenantDomain() string

GetControlPlaneConnectedTenantDomain returns the tenant domain of the user used to authenticate with event hub.

func GetKeyLocations

func GetKeyLocations() (string, string, string)

GetKeyLocations function returns the public key path and private key path

func GetLogConfigPath

func GetLogConfigPath() (string, error)

GetLogConfigPath returns the file location of the log-config path

func GetMgwHome

func GetMgwHome() string

GetMgwHome reads the MGW_HOME environmental variable and returns the value. This represent the directory where the distribution is located. If the env variable is not present, the directory from which the executable is triggered will be assigned.

func GetServerCertificate

func GetServerCertificate(tlsCertificate string, tlsCertificateKey string) (tls.Certificate, error)

GetServerCertificate returns the certificate (used for the restAPI server and GRPC server) created based on configuration values. Move to pkg. remove config and read from a file path

func GetTrustedCertPool

func GetTrustedCertPool(truststoreLocation string) *x509.CertPool

GetTrustedCertPool returns the trusted certificate (used for the restAPI server and xds server) created based on the provided directory/file path. Move to pkg

func IsPublicCertificate

func IsPublicCertificate(certContent []byte) bool

IsPublicCertificate checks if the file content represents valid public certificate in PEM format. Move to pkg

func NewReceiver

func NewReceiver() chan string

NewReceiver initializes the channel if it is not created an returns

func NewSender

func NewSender() chan string

NewSender initializes the channel if it is not created an returns

func ReadLogConfigs

func ReadLogConfigs() *pkgconf.LogConfig

ReadLogConfigs implements adapter/proxy log-configuration read operation.The read operation will happen only once, hence the consistancy is ensured.

If the "MGW_HOME" variable is set, the log configuration file location would be picked relative to the variable's value ("/conf/log_config.toml"). otherwise, the "MGW_HOME" variable would be set to the directory from where the executable is called from.

Returns the log configuration object mapped from the configuration file during the startup.

func SetConfig

func SetConfig(conf *Config)

SetConfig sets the given configuration to the adapter configuration

func SetDefaultConfig

func SetDefaultConfig()

SetDefaultConfig sets the default configuration to the adapter configuration

func UpdateLoggers

func UpdateLoggers()

UpdateLoggers initializes the logger package references

Types

type Config

type Config struct {
	ControlPlane controlPlane `toml:"controlPlane"`
	DataPlane    dataPlane    `toml:"dataPlane"`
	Agent        agent        `toml:"agent"`
	// Metric represents configurations to expose/export go metrics
	Metrics metrics `toml:"metrics"`
}

Config represents the adapter configuration. It is created directly from the configuration toml file. Note :

Don't use toml tag for configuration properties as it may affect environment variable based
config resolution.

func ReadConfigs

func ReadConfigs() (*Config, error)

ReadConfigs implements adapter configuration read operation. The read operation will happen only once, hence the consistancy is ensured.

If the "MGW_HOME" variable is set, the configuration file location would be picked relative to the variable's value ("/conf/config.toml"). otherwise, the "MGW_HOME" variable would be set to the directory from where the executable is called from.

Returns the configuration object that is initialized with default values. Changes to the default configuration object is achieved through the configuration file.

type WireLogConfig

type WireLogConfig struct {
	LogBodyEnabled     bool
	LogHeadersEnabled  bool
	LogTrailersEnabled bool
}

WireLogConfig is the config holder for wire logs

func GetWireLogConfig

func GetWireLogConfig() *WireLogConfig

GetWireLogConfig converts the wire log configs read from the config file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL