Skip to content

Commit

Permalink
Initialize service configuration with default values (#278)
Browse files Browse the repository at this point in the history
use configWithDefaultValues
  • Loading branch information
korotkov-aerospike authored Dec 2, 2024
1 parent 259ce16 commit 8eaff63
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/server/configuration/configuration_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func readConfig(reader io.Reader, nsValidator service.NamespaceValidator) (*mode
}
slog.Info("Service configuration:\n" + string(configBytes))

config := &dto.Config{}
config := dto.NewConfigWithDefaultValues()
if err := yaml.Unmarshal(configBytes, config); err != nil {
return nil, fmt.Errorf("failed to unmarshal configuration: %w", err)
}
Expand Down
11 changes: 11 additions & 0 deletions pkg/dto/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,17 @@ func (c *Config) validate() error {
return nil
}

// NewConfigWithDefaultValues returns a new Config with default values.
func NewConfigWithDefaultValues() *Config {
return &Config{
ServiceConfig: NewBackupServiceConfigWithDefaultValues(),
Storage: map[string]*Storage{},
BackupRoutines: map[string]*BackupRoutine{},
BackupPolicies: map[string]*BackupPolicy{},
AerospikeClusters: map[string]*AerospikeCluster{},
}
}

func (c *Config) ToModel(nsValidator service.NamespaceValidator) (*model.Config, error) {
if err := c.validate(); err != nil {
return nil, fmt.Errorf("configuration validation failed: %w", err)
Expand Down

0 comments on commit 8eaff63

Please sign in to comment.