Skip to content

Commit

Permalink
Addressing Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
beautifulentropy committed Feb 12, 2021
1 parent b48184c commit 4869161
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 44 deletions.
4 changes: 2 additions & 2 deletions cmd/admin-revoker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type config struct {
DBConfig cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DatabaseConfig
cmd.DeprecatedDBConfig
// Similarly, the Revoker needs a TLSConfig to set up its GRPC client certs,
// but doesn't get the TLS field from ServiceConfig, so declares its own.
TLS cmd.TLSConfig
Expand Down Expand Up @@ -78,7 +78,7 @@ func setupContext(c config) (core.RegistrationAuthority, blog.Logger, *db.Wrappe

// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&c.Revoker.DBConfig, &c.Revoker.DatabaseConfig)
cmd.DefaultDBConfig(&c.Revoker.DBConfig, &c.Revoker.DeprecatedDBConfig)
dbURL, err := c.Revoker.DBConfig.URL()
cmd.FailOnError(err, "Couldn't load DB URL")
dbSettings := sa.DbSettings{
Expand Down
4 changes: 2 additions & 2 deletions cmd/bad-key-revoker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func main() {
DBConfig cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DatabaseConfig
cmd.DeprecatedDBConfig
DebugAddr string

TLS cmd.TLSConfig
Expand Down Expand Up @@ -394,7 +394,7 @@ func main() {

// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&config.BadKeyRevoker.DBConfig, &config.BadKeyRevoker.DatabaseConfig)
cmd.DefaultDBConfig(&config.BadKeyRevoker.DBConfig, &config.BadKeyRevoker.DeprecatedDBConfig)
dbURL, err := config.BadKeyRevoker.DBConfig.URL()
cmd.FailOnError(err, "Couldn't load DB URL")

Expand Down
4 changes: 2 additions & 2 deletions cmd/boulder-janitor/janitor/janitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type JanitorConfig struct {

// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DatabaseConfig
cmd.DeprecatedDBConfig

// JobConfigs is a list of configs for individual cleanup jobs.
JobConfigs []JobConfig
Expand Down Expand Up @@ -69,7 +69,7 @@ func New(clk clock.Clock, config JanitorConfig) (*Janitor, error) {

// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&config.DBConfig, &config.DatabaseConfig)
cmd.DefaultDBConfig(&config.DBConfig, &config.DeprecatedDBConfig)
// Create DB Map
dbURL, err := config.DBConfig.URL()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/boulder-sa/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type config struct {
DBConfig cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DatabaseConfig
cmd.DeprecatedDBConfig

Features map[string]bool

Expand Down Expand Up @@ -63,7 +63,7 @@ func main() {

// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&saConf.DBConfig, &saConf.DatabaseConfig)
cmd.DefaultDBConfig(&saConf.DBConfig, &saConf.DeprecatedDBConfig)

saDbSettings := sa.DbSettings{
MaxOpenConns: saConf.DBConfig.MaxOpenConns,
Expand Down
4 changes: 2 additions & 2 deletions cmd/cert-checker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ type config struct {
DBConfig cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DatabaseConfig
cmd.DeprecatedDBConfig
cmd.HostnamePolicyConfig

Workers int
Expand Down Expand Up @@ -376,7 +376,7 @@ func main() {

// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&config.CertChecker.DBConfig, &config.CertChecker.DatabaseConfig)
cmd.DefaultDBConfig(&config.CertChecker.DBConfig, &config.CertChecker.DeprecatedDBConfig)
saDbURL, err := config.CertChecker.DBConfig.URL()
cmd.FailOnError(err, "Couldn't load DB URL")
dbSettings := sa.DbSettings{
Expand Down
10 changes: 4 additions & 6 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,12 @@ type DBConfig struct {
ConnMaxIdleTime ConfigDuration
}

// DatabaseConfig is a temporary struct that acts as a receiver for
// DeprecatedDBConfig is a temporary type that acts as a receiver for
// fields unmarshalled from the root of a component's JSON config
// (deprecated).
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
type DatabaseConfig struct {
DBConfig
}
type DeprecatedDBConfig DBConfig

// URL returns the DBConnect URL represented by this DBConfig object, either
// loading it from disk or returning a default value. Leading and trailing
Expand All @@ -100,8 +98,8 @@ func (d *DBConfig) URL() (string, error) {
// (deprecated) to the named `DBConfig` substruct of the service config.
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
func DefaultDBConfig(dbConfig *DBConfig, databaseConfig *DatabaseConfig) {
if databaseConfig.DBConnectFile == "" {
func DefaultDBConfig(dbConfig *DBConfig, databaseConfig *DeprecatedDBConfig) {
if dbConfig.DBConnectFile != "" {
// dbConfig was specified properly in the JSON return early
return
}
Expand Down
34 changes: 20 additions & 14 deletions cmd/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,33 @@ func TestTLSConfigLoad(t *testing.T) {

func TestDefaultDBConfig(t *testing.T) {
exampleDBConfig := &DBConfig{}
exampleDatabaseConfig := &DatabaseConfig{
DBConfig{
DBConnect: "some secret",
DBConnectFile: "foo/bar",
MaxOpenConns: 100,
MaxIdleConns: 100,
ConnMaxLifetime: ConfigDuration{10000},
ConnMaxIdleTime: ConfigDuration{10000},
},
exampleDatabaseConfig := &DeprecatedDBConfig{
DBConnect: "some secret",
DBConnectFile: "foo/bar",
MaxOpenConns: 100,
MaxIdleConns: 100,
ConnMaxLifetime: ConfigDuration{10000},
ConnMaxIdleTime: ConfigDuration{10000},
}
DefaultDBConfig(exampleDBConfig, exampleDatabaseConfig)
test.AssertEquals(t, *exampleDBConfig, exampleDatabaseConfig.DBConfig)
exampleDBConfig = &DBConfig{
expected := &DBConfig{
DBConnect: "some secret",
DBConnectFile: "foo/bar",
MaxOpenConns: 100,
MaxIdleConns: 100,
ConnMaxLifetime: ConfigDuration{10000},
ConnMaxIdleTime: ConfigDuration{10000},
}
exampleDatabaseConfig = &DatabaseConfig{}
DefaultDBConfig(exampleDBConfig, exampleDatabaseConfig)
test.AssertEquals(t, exampleDBConfig.MaxOpenConns, 100)
test.AssertDeepEquals(t, exampleDBConfig, expected)

exampleDBConfig = &DBConfig{
DBConnect: "some secret",
DBConnectFile: "foo/bar",
MaxOpenConns: 100,
MaxIdleConns: 100,
ConnMaxLifetime: ConfigDuration{10000},
ConnMaxIdleTime: ConfigDuration{10000}}
exampleDatabaseConfig = &DeprecatedDBConfig{}
DefaultDBConfig(exampleDBConfig, exampleDatabaseConfig)
test.AssertDeepEquals(t, exampleDBConfig, expected)
}
4 changes: 2 additions & 2 deletions cmd/expiration-mailer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ type config struct {
DBConfig cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DatabaseConfig
cmd.DeprecatedDBConfig
cmd.SMTPConfig

From string
Expand Down Expand Up @@ -479,7 +479,7 @@ func main() {

// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&c.Mailer.DBConfig, &c.Mailer.DatabaseConfig)
cmd.DefaultDBConfig(&c.Mailer.DBConfig, &c.Mailer.DeprecatedDBConfig)
// Configure DB
dbURL, err := c.Mailer.DBConfig.URL()
cmd.FailOnError(err, "Couldn't load DB URL")
Expand Down
4 changes: 2 additions & 2 deletions cmd/expired-authz-purger2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type config struct {
DBConfig cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DatabaseConfig
cmd.DeprecatedDBConfig
DebugAddr string
Syslog cmd.SyslogConfig
Features map[string]bool
Expand Down Expand Up @@ -81,7 +81,7 @@ func main() {

// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&c.ExpiredAuthzPurger2.DBConfig, &c.ExpiredAuthzPurger2.DatabaseConfig)
cmd.DefaultDBConfig(&c.ExpiredAuthzPurger2.DBConfig, &c.ExpiredAuthzPurger2.DeprecatedDBConfig)
dbURL, err := c.ExpiredAuthzPurger2.DBConfig.URL()
cmd.FailOnError(err, "Couldn't load DB URL")
dbSettings := sa.DbSettings{
Expand Down
4 changes: 2 additions & 2 deletions cmd/id-exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func main() {
DBConfig cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DatabaseConfig
cmd.DeprecatedDBConfig
cmd.PasswordConfig
Features map[string]bool
}
Expand Down Expand Up @@ -179,7 +179,7 @@ func main() {

// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&cfg.ContactExporter.DBConfig, &cfg.ContactExporter.DatabaseConfig)
cmd.DefaultDBConfig(&cfg.ContactExporter.DBConfig, &cfg.ContactExporter.DeprecatedDBConfig)
dbURL, err := cfg.ContactExporter.DBConfig.URL()
cmd.FailOnError(err, "Couldn't load DB URL")
dbSettings := sa.DbSettings{
Expand Down
4 changes: 2 additions & 2 deletions cmd/notify-mailer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ func main() {
DBConfig cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DatabaseConfig
cmd.DeprecatedDBConfig
cmd.PasswordConfig
cmd.SMTPConfig
Features map[string]bool
Expand Down Expand Up @@ -444,7 +444,7 @@ func main() {

// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&cfg.NotifyMailer.DBConfig, &cfg.NotifyMailer.DatabaseConfig)
cmd.DefaultDBConfig(&cfg.NotifyMailer.DBConfig, &cfg.NotifyMailer.DeprecatedDBConfig)
dbURL, err := cfg.NotifyMailer.DBConfig.URL()
cmd.FailOnError(err, "Couldn't load DB URL")
dbSettings := sa.DbSettings{
Expand Down
4 changes: 2 additions & 2 deletions cmd/ocsp-responder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ type config struct {

// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DatabaseConfig
cmd.DeprecatedDBConfig

// Source indicates the source of pre-signed OCSP responses to be used. It
// can be a DBConnect string or a file URL. The file URL style is used
Expand Down Expand Up @@ -277,7 +277,7 @@ as generated by Boulder's ceremony command.
} else {
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&config.DBConfig, &config.DatabaseConfig)
cmd.DefaultDBConfig(&config.DBConfig, &config.DeprecatedDBConfig)
// For databases, DBConfig takes precedence over Source, if present.
dbConnect, err := config.DBConfig.URL()
cmd.FailOnError(err, "Reading DB config")
Expand Down
4 changes: 2 additions & 2 deletions cmd/ocsp-updater/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ type OCSPUpdaterConfig struct {

// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DatabaseConfig
cmd.DeprecatedDBConfig

OldOCSPWindow cmd.ConfigDuration
OldOCSPBatchSize int
Expand Down Expand Up @@ -347,7 +347,7 @@ func main() {

// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&conf.DBConfig, &conf.DatabaseConfig)
cmd.DefaultDBConfig(&conf.DBConfig, &conf.DeprecatedDBConfig)
// Configure DB
dbURL, err := conf.DBConfig.URL()
cmd.FailOnError(err, "Couldn't load DB URL")
Expand Down
5 changes: 3 additions & 2 deletions test/authz-filler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import (

type fillerConfig struct {
Filler struct {
DBConfig cmd.DBConfig
// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DatabaseConfig
cmd.DeprecatedDBConfig
Parallelism uint
}
}
Expand All @@ -48,7 +49,7 @@ func main() {

// TODO(#5275): Remove once all configs in dev, staging and prod
// have been updated to contain the `dbconfig` field
cmd.DefaultDBConfig(&config.Filler.DBConfig, &config.Filler.DatabaseConfig)
cmd.DefaultDBConfig(&config.Filler.DBConfig, &config.Filler.DeprecatedDBConfig)
// Configure DB
dbURL, err := config.Filler.DBConfig.URL()
cmd.FailOnError(err, "Couldn't load DB URL")
Expand Down

0 comments on commit 4869161

Please sign in to comment.