diff --git a/app/platform/config.go b/app/platform/config.go index 9fab59450e..5b0218dcd6 100644 --- a/app/platform/config.go +++ b/app/platform/config.go @@ -36,15 +36,6 @@ type ServiceConfig struct { Cluster einterfaces.ClusterInterface } -func (c *ServiceConfig) validate() error { - // Mandatory fields need to be checked here - if c.ConfigStore == nil { - return errors.New("ConfigStore is required") - } - - return nil -} - // ensure the config wrapper implements `product.ConfigService` var _ product.ConfigService = (*PlatformService)(nil) diff --git a/app/platform/service.go b/app/platform/service.go index 261297b2fc..b5a506ae50 100644 --- a/app/platform/service.go +++ b/app/platform/service.go @@ -97,10 +97,6 @@ type PlatformService struct { // New creates a new PlatformService. func New(sc ServiceConfig, options ...Option) (*PlatformService, error) { - if err := sc.validate(); err != nil { - return nil, err - } - // Step 0: Create the PlatformService. // ConfigStore is and should be handled on a upper level. ps := &PlatformService{ @@ -138,6 +134,21 @@ func New(sc ServiceConfig, options ...Option) (*PlatformService, error) { } } + // the config store is not set, we need to create a new one + if ps.configStore == nil { + innerStore, err := config.NewFileStore("config.json", true) + if err != nil { + return nil, fmt.Errorf("failed to load config from file: %w", err) + } + + configStore, err := config.NewStoreFromBacking(innerStore, nil, false) + if err != nil { + return nil, fmt.Errorf("failed to load config from file: %w", err) + } + + ps.configStore = configStore + } + // Step 2: Start logging. if err := ps.initLogging(); err != nil { return nil, fmt.Errorf("failed to initialize logging: %w", err) diff --git a/app/server.go b/app/server.go index 591b5751b1..a4688c8b43 100644 --- a/app/server.go +++ b/app/server.go @@ -201,20 +201,7 @@ func NewServer(options ...Option) (*Server, error) { // // Step 1: Platform. if s.platform == nil { - innerStore, err := config.NewFileStore("config.json", true) - if err != nil { - return nil, errors.Wrap(err, "failed to load config") - } - configStore, err := config.NewStoreFromBacking(innerStore, nil, false) - if err != nil { - return nil, errors.Wrap(err, "failed to load config") - } - - platformCfg := platform.ServiceConfig{ - ConfigStore: configStore, - } - - ps, sErr := platform.New(platformCfg, s.platformOptions...) + ps, sErr := platform.New(platform.ServiceConfig{}, s.platformOptions...) if sErr != nil { return nil, errors.Wrap(sErr, "failed to initialize platform") }