Documentation
¶
Overview ¶
Package config provides support for configuring the system.
BaseConfig provides the data structures that represent the configuration and can be used to load configuration from a TOML file.
Config consumes the BaseConfig and returns implementations of the various interfaces used by the application (in a dependency-injection style).
Index ¶
- Variables
- type ApiSettings
- type ApiSettingsConfig
- type BaseConfig
- type ChargeStationCertProviderConfig
- type CompositeRootCertProviderConfig
- type Config
- type ContractCertProviderConfig
- type ContractCertValidatorConfig
- type DelegatingChargeStationCertProviderConfig
- type EnvHttpTokenConfig
- type FileRootCertProviderConfig
- type FirestoreStorageConfig
- type FixedHttpTokenConfig
- type HttpAuthConfig
- type HubjectTestHttpTokenConfig
- type InMemoryStorageConfig
- type LocalChargeStationCertProviderConfig
- type LocalSourceConfig
- type MqttSettingsConfig
- type OAuth2HttpTokenConfig
- type ObservabilitySettingsConfig
- type OcpiConfig
- type OcppSettingsConfig
- type OcspContractCertValidatorConfig
- type OpcpChargeStationCertProviderConfig
- type OpcpContractCertProviderConfig
- type OpcpRootCertProviderConfig
- type RootCertProviderConfig
- type StorageConfig
- type TariffServiceConfig
- type TransportConfig
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = BaseConfig{ Api: ApiSettingsConfig{ Addr: "localhost:9410", Host: "localhost", WsPort: 80, WssPort: 443, OrgName: "Thoughtworks", }, Transport: TransportConfig{ Type: "mqtt", Mqtt: &MqttSettingsConfig{ Urls: []string{"mqtt://localhost:1883"}, Prefix: "cs", Group: "manager", ConnectTimeout: "10s", ConnectRetryDelay: "1s", KeepAliveInterval: "10s", }, }, Ocpp: OcppSettingsConfig{ HeartbeatInterval: "5m", Ocpp16Enabled: true, Ocpp201Enabled: true, }, Observability: ObservabilitySettingsConfig{ LogFormat: "text", }, Storage: StorageConfig{ Type: "in_memory", }, ContractCertValidator: ContractCertValidatorConfig{ Type: "ocsp", Ocsp: &OcspContractCertValidatorConfig{ RootCertProvider: RootCertProviderConfig{ Type: "file", File: &FileRootCertProviderConfig{ FileNames: []string{"root_ca.pem"}, }, }, MaxAttempts: 1, }, }, ContractCertProvider: ContractCertProviderConfig{ Type: "default", }, ChargeStationCertProvider: ChargeStationCertProviderConfig{ Type: "default", }, TariffService: TariffServiceConfig{ Type: "kwh", }, }
DefaultConfig provides the default configuration. The configuration read from the TOML file will overlay this configuration.
Functions ¶
This section is empty.
Types ¶
type ApiSettings ¶
type ApiSettingsConfig ¶
type ApiSettingsConfig struct {
Addr string `mapstructure:"addr" toml:"addr" validate:"required"`
Host string `mapstructure:"host,omitempty" toml:"host,omitempty"`
WsPort int `mapstructure:"ws_port,omitempty" toml:"ws_port,omitempty"`
WssPort int `mapstructure:"wss_port,omitempty" toml:"wss_port,omitempty"`
OrgName string `mapstructure:"org_name,omitempty" toml:"org_name,omitempty"`
}
type BaseConfig ¶
type BaseConfig struct {
Api ApiSettingsConfig `mapstructure:"api" toml:"api" validate:"required"`
Transport TransportConfig `mapstructure:"transport" toml:"transport" validate:"required"`
Ocpp OcppSettingsConfig `mapstructure:"ocpp" toml:"ocpp" validate:"required"`
Observability ObservabilitySettingsConfig `mapstructure:"observability" toml:"observability" validate:"required"`
Storage StorageConfig `mapstructure:"storage" toml:"storage" validate:"required"`
ContractCertValidator ContractCertValidatorConfig `mapstructure:"contract_cert_validator" toml:"contract_cert_validator" validate:"required"`
ContractCertProvider ContractCertProviderConfig `mapstructure:"contract_cert_provider" toml:"contract_cert_provider" validate:"required"`
ChargeStationCertProvider ChargeStationCertProviderConfig `mapstructure:"charge_station_cert_provider" toml:"charge_station_cert_provider" validate:"required"`
TariffService TariffServiceConfig `mapstructure:"tariff_service" toml:"tariff_service" validate:"required"`
Ocpi *OcpiConfig `mapstructure:"ocpi,omitempty" toml:"ocpi,omitempty"`
}
BaseConfig provides the data structures that represent the configuration and provides the ability to load the configuration from a TOML file.
func (*BaseConfig) Load ¶
func (c *BaseConfig) Load(reader io.Reader) error
Load reads TOML configuration from a reader.
func (*BaseConfig) LoadFromFile ¶
func (c *BaseConfig) LoadFromFile(configFile string) error
LoadFromFile reads TOML configuration from a file.
func (*BaseConfig) Validate ¶
func (c *BaseConfig) Validate() error
Validate ensures that the configuration is structurally valid.
type ChargeStationCertProviderConfig ¶
type ChargeStationCertProviderConfig struct {
Type string `mapstructure:"type" toml:"type" validate:"required,oneof=default opcp local delegating"`
Opcp *OpcpChargeStationCertProviderConfig `mapstructure:"opcp,omitempty" toml:"opcp,omitempty" validate:"required_if=Type opcp"`
Local *LocalChargeStationCertProviderConfig `mapstructure:"local,omitempty" toml:"local,omitempty" validate:"required_if=Type local"`
Delegating *DelegatingChargeStationCertProviderConfig `mapstructure:"delegating,omitempty" toml:"delegating,omitempty" validate:"required_if=Type delegating"`
}
type CompositeRootCertProviderConfig ¶
type CompositeRootCertProviderConfig struct {
Providers []RootCertProviderConfig `mapstructure:"providers" toml:"providers" validate:"required,dive,required"`
}
type Config ¶
type Config struct {
Api ApiSettings
Tracer oteltrace.Tracer
TracerProvider *trace.TracerProvider
Storage store.Engine
MsgEmitter transport.Emitter
MsgListener transport.Listener
Ocpp16Handler transport.MessageHandler
Ocpp201Handler transport.MessageHandler
ContractCertValidationService services.CertificateValidationService
ContractCertProviderService services.ContractCertificateProvider
ChargeStationCertProviderService services.ChargeStationCertificateProvider
TariffService services.TariffService
OcpiApi ocpi.Api
}
type ContractCertProviderConfig ¶
type ContractCertProviderConfig struct {
Type string `mapstructure:"type" toml:"type" validate:"required,oneof=default opcp"`
Opcp *OpcpContractCertProviderConfig `mapstructure:"opcp,omitempty" toml:"opcp,omitempty" validate:"required_if=Type opcp"`
}
type ContractCertValidatorConfig ¶
type ContractCertValidatorConfig struct {
Type string `mapstructure:"type" toml:"type" validate:"required,oneof=ocsp"`
Ocsp *OcspContractCertValidatorConfig `mapstructure:"ocsp,omitempty" toml:"ocsp,omitempty" validate:"required_if=Type ocsp"`
}
type DelegatingChargeStationCertProviderConfig ¶
type DelegatingChargeStationCertProviderConfig struct {
V2G *ChargeStationCertProviderConfig `mapstructure:"v2g" toml:"v2g" validate:"required"`
CSO *ChargeStationCertProviderConfig `mapstructure:"cso" toml:"cso" validate:"required"`
}
type EnvHttpTokenConfig ¶
type EnvHttpTokenConfig struct {
EnvVar string `mapstructure:"variable" toml:"variable" validate:"required"`
}
type FileRootCertProviderConfig ¶
type FileRootCertProviderConfig struct {
FileNames []string `mapstructure:"files" toml:"files" validate:"required,dive,required"`
}
type FirestoreStorageConfig ¶
type FirestoreStorageConfig struct {
ProjectId string `mapstructure:"project_id" toml:"project_id" validate:"required"`
}
type FixedHttpTokenConfig ¶
type FixedHttpTokenConfig struct {
Token string `mapstructure:"token" toml:"token" validate:"required"`
}
type HttpAuthConfig ¶
type HttpAuthConfig struct {
Type string `mapstructure:"type" toml:"type" validate:"required,oneof=env_token fixed_token oauth2_token hubject_test_token"`
EnvToken *EnvHttpTokenConfig `mapstructure:"env_token,omitempty" toml:"env_token,omitempty" validate:"required_if=Type env_token"`
FixedToken *FixedHttpTokenConfig `mapstructure:"fixed_token,omitempty" toml:"fixed_token,omitempty" validate:"required_if=Type fixed_token"`
OAuth2Token *OAuth2HttpTokenConfig `mapstructure:"oauth2_token,omitempty" toml:"oauth2_token,omitempty" validate:"required_if=Type oauth2_token"`
HubjectTestToken *HubjectTestHttpTokenConfig `` /* 126-byte string literal not displayed */
}
type InMemoryStorageConfig ¶
type InMemoryStorageConfig struct{}
type LocalChargeStationCertProviderConfig ¶
type LocalChargeStationCertProviderConfig struct {
CertificateSource *LocalSourceConfig `mapstructure:"cert" toml:"cert" validate:"required"`
PrivateKeySource *LocalSourceConfig `mapstructure:"key" toml:"key" validate:"required"`
}
type LocalSourceConfig ¶
type LocalSourceConfig struct {
Type string `mapstructure:"type" toml:"type" validate:"required,oneof=file google_cloud_secret"`
File string `mapstructure:"file,omitempty" toml:"file,omitempty" validate:"required_if=Type file"`
GoogleCloudSecret string `` /* 129-byte string literal not displayed */
}
type MqttSettingsConfig ¶
type MqttSettingsConfig struct {
Urls []string `mapstructure:"urls" toml:"urls" validate:"required,dive,required"`
Prefix string `mapstructure:"prefix" toml:"prefix" validate:"required"`
Group string `mapstructure:"group" toml:"group" validate:"required"`
ConnectTimeout string `mapstructure:"connect_timeout" toml:"connect_timeout" validate:"required"`
ConnectRetryDelay string `mapstructure:"connect_retry_delay" toml:"connect_retry_delay" validate:"required"`
KeepAliveInterval string `mapstructure:"keep_alive_interval" toml:"keep_alive_interval" validate:"required"`
}
type OAuth2HttpTokenConfig ¶
type OAuth2HttpTokenConfig struct {
Url string `mapstructure:"url" toml:"url" validate:"required"`
ClientId string `mapstructure:"client_id" toml:"client_id" validate:"required"`
ClientSecret *string `mapstructure:"client_secret,omitempty" toml:"client_secret,omitempty" validate:"required_without=ClientSecretEnvVar"`
ClientSecretEnvVar *string `` /* 126-byte string literal not displayed */
}
type OcpiConfig ¶
type OcpiConfig struct {
Addr string `mapstructure:"addr" toml:"addr" validate:"required"`
ExternalURL string `mapstructure:"external_url" toml:"external_url" validate:"required"`
CountryCode string `mapstructure:"country_code" toml:"country_code" validate:"required"`
PartyId string `mapstructure:"party_id" toml:"party_id" validate:"required"`
}
type OcppSettingsConfig ¶
type OcppSettingsConfig struct {
HeartbeatInterval string `mapstructure:"heartbeat_interval" toml:"heartbeat_interval" validate:"required"`
Ocpp16Enabled bool `mapstructure:"ocpp16_enabled" toml:"ocpp16_enabled" validate:"required_without=Ocpp201Enabled"`
Ocpp201Enabled bool `mapstructure:"ocpp201_enabled" toml:"ocpp201_enabled" validate:"required_without=Ocpp16Enabled"`
}
type OcspContractCertValidatorConfig ¶
type OcspContractCertValidatorConfig struct {
RootCertProvider RootCertProviderConfig `mapstructure:"root_certs" toml:"root_certs" validate:"required"`
MaxAttempts int `mapstructure:"max_attempts" toml:"max_attempts" validate:"required"`
}
type OpcpChargeStationCertProviderConfig ¶
type OpcpChargeStationCertProviderConfig struct {
Url string `mapstructure:"url" toml:"url" validate:"required"`
HttpAuth HttpAuthConfig `mapstructure:"auth" toml:"auth" validate:"required"`
}
type OpcpContractCertProviderConfig ¶
type OpcpContractCertProviderConfig struct {
Url string `mapstructure:"url" toml:"url" validate:"required"`
HttpAuth HttpAuthConfig `mapstructure:"auth" toml:"auth" validate:"required"`
}
type OpcpRootCertProviderConfig ¶
type OpcpRootCertProviderConfig struct {
Url string `mapstructure:"url" toml:"url" validate:"required"`
Ttl string `mapstructure:"ttl" toml:"ttl" validate:"required"`
HttpAuth HttpAuthConfig `mapstructure:"auth" toml:"auth" validate:"required"`
}
type RootCertProviderConfig ¶
type RootCertProviderConfig struct {
Type string `mapstructure:"type" toml:"type" validate:"required,oneof=opcp file composite"`
Opcp *OpcpRootCertProviderConfig `mapstructure:"opcp,omitempty" toml:"opcp,omitempty" validate:"required_if=Type opcp"`
File *FileRootCertProviderConfig `mapstructure:"file,omitempty" toml:"file,omitempty" validate:"required_if=Type file"`
Composite *CompositeRootCertProviderConfig `mapstructure:"composite,omitempty" toml:"composite,omitempty" validate:"required_if=Type composite"`
}
type StorageConfig ¶
type StorageConfig struct {
Type string `mapstructure:"type" toml:"type" validate:"required,oneof=firestore in_memory"`
FirestoreStorage *FirestoreStorageConfig `mapstructure:"firestore,omitempty" toml:"firestore,omitempty" validate:"required_if=Type firestore"`
InMemoryStorage *InMemoryStorageConfig `mapstructure:"in_memory,omitempty" toml:"in_memory,omitempty"`
}
type TariffServiceConfig ¶
type TariffServiceConfig struct {
Type string `mapstructure:"type" toml:"type" validate:"required,oneof=kwh"`
}
type TransportConfig ¶
type TransportConfig struct {
Type string `mapstructure:"type" toml:"type" validate:"required,oneof=mqtt"`
Mqtt *MqttSettingsConfig `mapstructure:"mqtt,omitempty" toml:"mqtt,omitempty" validate:"required_if=Type mqtt"`
}