Skip to content

Commit 2ef27b8

Browse files
committed
cli: switch cluster config to goconfig.MutableConfig
Migrate the loader, publish/show flows, and replicaset patch flows in cli/cluster and cli/replicaset to operate on goconfig.Config / MutableConfig + KeyPath instead of the in-tree libcluster.ClusterConfig hierarchy. The loader (cli/cluster.GetClusterConfig) is rewritten as a two-phase merge: env (TT_*_DEFAULT ignored) and file first, then a fill-only merge of remote storage (etcd/TCS, first reachable wins), then a fill-only merge of TT_*_DEFAULT. Storage I/O is plumbed through the gsconnect/go-storage abstraction (NewStorageConnection + NewRemoteStorage) and integrity is wired via GetStorageVerifiers / WithFileReadFunc / WithIntegrity. The new helpers in cli/cluster (scope, storage, BuildGoConfigFromBytes, BuildMutableFromBytes, FindInstance, FindGroupByReplicaset, InstanceConfig, Instances, LibclusterToConfig) replace the old typed wrappers and Instantiate path. Part of TNTP-7390
1 parent eae987b commit 2ef27b8

41 files changed

Lines changed: 1857 additions & 1092 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cli/aeon/cmd/connection.go

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package cmd
22

33
import (
4+
"context"
45
"errors"
56
"fmt"
67

78
"github.com/mitchellh/mapstructure"
9+
goconfig "github.com/tarantool/go-config"
10+
"github.com/tarantool/tt/cli/cluster"
811
"github.com/tarantool/tt/cli/util"
912
libcluster "github.com/tarantool/tt/lib/cluster"
1013
libconnect "github.com/tarantool/tt/lib/connect"
@@ -15,41 +18,42 @@ import (
1518
// It returns an error if fails to collect a configuration,
1619
// instantiate a cluster config or find an instance in the cluster.
1720
func FillConnectCtx(connectCtx *ConnectCtx, uriOpts libconnect.UriOpts,
18-
instanceName string, collectors libcluster.CollectorFactory,
21+
instanceName string, dataCollectors libcluster.DataCollectorFactory,
1922
) error {
2023
connOpts := libcluster.ConnectOpts{
2124
Username: connectCtx.Username,
2225
Password: connectCtx.Password,
2326
}
24-
collector, cancel, err := libcluster.CreateCollector(collectors,
27+
collector, cancel, err := libcluster.CreateDataCollector(dataCollectors,
2528
connOpts, uriOpts)
2629
if err != nil {
2730
return err
2831
}
2932
defer cancel()
3033

31-
config, err := collector.Collect()
34+
rawBytes, err := cluster.CollectDataBytes(context.Background(), collector)
3235
if err != nil {
3336
return fmt.Errorf("failed to collect a configuration: %w", err)
3437
}
3538

36-
clusterConfig, err := libcluster.MakeClusterConfig(config)
39+
goView, err := cluster.BuildGoConfigFromBytes(context.Background(), rawBytes)
3740
if err != nil {
38-
return err
41+
return fmt.Errorf("failed to parse cluster config: %w", err)
3942
}
4043

41-
result := libcluster.Instantiate(clusterConfig, instanceName)
42-
43-
dataSsl := []string{"roles_cfg", "aeon.grpc", "advertise"}
44-
data, err := result.Get(dataSsl)
44+
instCfg, err := cluster.InstanceConfig(goView, instanceName)
4545
if err != nil {
46-
return err
46+
return fmt.Errorf("instance %q not found: %w", instanceName, err)
47+
}
48+
49+
var rawAdvertise any
50+
if _, err = instCfg.Get(goconfig.NewKeyPath("roles_cfg/aeon.grpc/advertise"), &rawAdvertise); err != nil {
51+
return fmt.Errorf("failed to get aeon advertise: %w", err)
4752
}
4853

4954
var advertise Advertise
50-
err = mapstructure.Decode(data, &advertise)
51-
if err != nil {
52-
return err
55+
if err = mapstructure.Decode(rawAdvertise, &advertise); err != nil {
56+
return fmt.Errorf("failed to decode aeon advertise: %w", err)
5357
}
5458

5559
if advertise.Uri == "" {

0 commit comments

Comments
 (0)