Skip to content

Commit

Permalink
dev: streamline config generator
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsingerus committed Oct 3, 2024
1 parent 0ce604e commit 2d1f044
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/model/chk/config/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package config

import (
"bytes"
"fmt"

chi "github.com/altinity/clickhouse-operator/pkg/apis/clickhouse.altinity.com/v1"
"github.com/altinity/clickhouse-operator/pkg/interfaces"
"github.com/altinity/clickhouse-operator/pkg/util"
Expand Down Expand Up @@ -90,13 +90,12 @@ func (c *Generator) getSectionFromFiles(section chi.SettingsSection, includeUnsp
func (c *Generator) getHostRaft(host *chi.Host) string {
settings := chi.NewSettings()

serverId, _ := chi.NewSettingScalarFromAny(getServerId(host))
settings.Set("keeper_server/server_id", serverId)
settings.Set("keeper_server/server_id", chi.MustNewSettingScalarFromAny(getServerId(host)))

host.GetCR().WalkHosts(func(_host *chi.Host) error {
settings.Set("keeper_server/raft_configuration/server/id", chi.NewSettingScalar(fmt.Sprintf("%d", getServerId(_host))))
settings.Set("keeper_server/raft_configuration/server/id", chi.MustNewSettingScalarFromAny(getServerId(_host)))
settings.Set("keeper_server/raft_configuration/server/hostname", chi.NewSettingScalar(c.namer.Name(interfaces.NameInstanceHostname, _host)))
settings.Set("keeper_server/raft_configuration/server/port", chi.NewSettingScalar(fmt.Sprintf("%d", _host.RaftPort.Value())))
settings.Set("keeper_server/raft_configuration/server/port", chi.MustNewSettingScalarFromAny(_host.RaftPort.Value()))
return nil
})

Expand Down

0 comments on commit 2d1f044

Please sign in to comment.