-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
In a series of PRs for #4316 we removed the dependency on tlscfg.Options
producing tls.Config
by replacing it with the corresponding OTEL functions (PR #6345).
We can clean this up even further and make Options struct to be private in tlscfg, by changing the signature of ServerFlagsConfig.InitFromViper
and ClientFlagsConfig.InitFromViper
to return the corresponding OTEL structs directly, rather than returning Options, because every time we call those functions we immediately call ToOtelServerConfig()
on the returned value, for example
jaeger/cmd/collector/app/flags/flags.go
Lines 211 to 215 in 08a2bff
tlsOpts, err := cfg.tls.InitFromViper(v) | |
if err != nil { | |
return fmt.Errorf("failed to parse GRPC TLS options: %w", err) | |
} | |
opts.TLSSetting = tlsOpts.ToOtelServerConfig() |
Sample change:
-func (c ServerFlagsConfig) InitFromViper(v *viper.Viper) (Options, error) {
+func (c ServerFlagsConfig) InitFromViper(v *viper.Viper) (*configtls.ServerConfig, error) {
var p Options
p.Enabled = v.GetBool(c.Prefix + tlsEnabled)
p.CertPath = v.GetString(c.Prefix + tlsCert)
@@ -99,11 +100,11 @@ func (c ServerFlagsConfig) InitFromViper(v *viper.Viper) (Options, error) {
if !p.Enabled {
var empty Options
if !reflect.DeepEqual(&p, &empty) {
- return p, fmt.Errorf("%s.tls.* options cannot be used when %s is false", c.Prefix, c.Prefix+tlsEnabled)
+ return nil, fmt.Errorf("%s.tls.* options cannot be used when %s is false", c.Prefix, c.Prefix+tlsEnabled)
}
}
- return p, nil
+ return p.ToOtelServerConfig(), nil
}
We should also remove mapstructure
tags from the Options struct, since we're not using it in the config files.