Remove embedded (anonymous) fields from configs (#2019)

This PR removes the use of all anonymous struct fields that were introduced by myself as per my work on splitting up boulder-config (#1962).

The root of the bug was related to the loading of the json configuration file into the config struct. The config structs contained several embedded (anonymous) fields. An embedded (anonymous) field in a struct actually results in the flattening of the json structure. This caused json.Unmarshal to look not at the nested level, but at the root level of the json object and hence not find the nested field (i.e. AllowedSigningAlgos).

See https://play.golang.org/p/6uVCsEu3Df for a working example.

This fixes the reported bug: #2018
This commit is contained in:
Ben Irving 2016-07-07 10:16:41 -07:00 committed by Roland Bracewell Shoemaker
parent 4f4f7d942c
commit 298774e1db
6 changed files with 23 additions and 23 deletions

View File

@ -27,13 +27,13 @@ const clientName = "CA"
type config struct {
CA cmd.CAConfig
*cmd.AllowedSigningAlgos
AllowedSigningAlgos *cmd.AllowedSigningAlgos
PA cmd.PAConfig
cmd.StatsdConfig
Statsd cmd.StatsdConfig
cmd.SyslogConfig
Syslog cmd.SyslogConfig
Common struct {
// Path to a PEM-encoded copy of the issuer certificate.
@ -132,7 +132,7 @@ func main() {
go cmd.DebugServer(c.CA.DebugAddr)
stats, logger := cmd.StatsAndLogging(c.StatsdConfig, c.SyslogConfig)
stats, logger := cmd.StatsAndLogging(c.Statsd, c.Syslog)
defer logger.AuditPanic()
logger.Info(cmd.VersionString(clientName))
@ -155,7 +155,7 @@ func main() {
clock.Default(),
stats,
issuers,
c.KeyPolicy(),
c.AllowedSigningAlgos.KeyPolicy(),
logger)
cmd.FailOnError(err, "Failed to create CA impl")
cai.PA = pa

View File

@ -24,9 +24,9 @@ type config struct {
MaxConcurrentRPCServerRequests int64
}
cmd.StatsdConfig
Statsd cmd.StatsdConfig
cmd.SyslogConfig
Syslog cmd.SyslogConfig
Common struct {
CT struct {
@ -50,7 +50,7 @@ func main() {
go cmd.DebugServer(c.Publisher.DebugAddr)
stats, logger := cmd.StatsAndLogging(c.StatsdConfig, c.SyslogConfig)
stats, logger := cmd.StatsAndLogging(c.Statsd, c.Syslog)
defer logger.AuditPanic()
logger.Info(cmd.VersionString(clientName))

View File

@ -52,13 +52,13 @@ type config struct {
ReuseValidAuthz bool
}
*cmd.AllowedSigningAlgos
AllowedSigningAlgos *cmd.AllowedSigningAlgos
PA cmd.PAConfig
cmd.StatsdConfig
Statsd cmd.StatsdConfig
cmd.SyslogConfig
Syslog cmd.SyslogConfig
Common struct {
DNSResolver string
@ -81,7 +81,7 @@ func main() {
go cmd.DebugServer(c.RA.DebugAddr)
stats, logger := cmd.StatsAndLogging(c.StatsdConfig, c.SyslogConfig)
stats, logger := cmd.StatsAndLogging(c.Statsd, c.Syslog)
defer logger.AuditPanic()
logger.Info(cmd.VersionString(clientName))

View File

@ -22,9 +22,9 @@ type config struct {
MaxConcurrentRPCServerRequests int64
}
cmd.StatsdConfig
Statsd cmd.StatsdConfig
cmd.SyslogConfig
Syslog cmd.SyslogConfig
}
func main() {
@ -41,7 +41,7 @@ func main() {
go cmd.DebugServer(c.SA.DebugAddr)
stats, logger := cmd.StatsAndLogging(c.StatsdConfig, c.SyslogConfig)
stats, logger := cmd.StatsAndLogging(c.Statsd, c.Syslog)
defer logger.AuditPanic()
logger.Info(cmd.VersionString(clientName))

View File

@ -40,13 +40,13 @@ type config struct {
CheckMalformedCSR bool
}
*cmd.AllowedSigningAlgos
AllowedSigningAlgos *cmd.AllowedSigningAlgos
cmd.StatsdConfig
Statsd cmd.StatsdConfig
SubscriberAgreementURL string
cmd.SyslogConfig
Syslog cmd.SyslogConfig
Common struct {
BaseURL string
@ -79,7 +79,7 @@ func main() {
go cmd.DebugServer(c.WFE.DebugAddr)
stats, logger := cmd.StatsAndLogging(c.StatsdConfig, c.SyslogConfig)
stats, logger := cmd.StatsAndLogging(c.Statsd, c.Syslog)
defer logger.AuditPanic()
logger.Info(cmd.VersionString(clientName))
@ -116,7 +116,7 @@ func main() {
wfe.IssuerCert, err = cmd.LoadCert(c.Common.IssuerCert)
cmd.FailOnError(err, fmt.Sprintf("Couldn't read issuer cert [%s]", c.Common.IssuerCert))
logger.Info(fmt.Sprintf("WFE using key policy: %#v", c.KeyPolicy()))
logger.Info(fmt.Sprintf("WFE using key policy: %#v", c.AllowedSigningAlgos.KeyPolicy()))
go cmd.ProfileCmd("WFE", stats)

View File

@ -552,9 +552,9 @@ const clientName = "OCSP"
type config struct {
OCSPUpdater cmd.OCSPUpdaterConfig
cmd.StatsdConfig
Statsd cmd.StatsdConfig
cmd.SyslogConfig
Syslog cmd.SyslogConfig
Common struct {
IssuerCert string
@ -603,7 +603,7 @@ func main() {
go cmd.DebugServer(conf.DebugAddr)
stats, auditlogger := cmd.StatsAndLogging(c.StatsdConfig, c.SyslogConfig)
stats, auditlogger := cmd.StatsAndLogging(c.Statsd, c.Syslog)
defer auditlogger.AuditPanic()
auditlogger.Info(cmd.VersionString(clientName))