From 77808c7b4181ad8e223662af43ba868bb24684ad Mon Sep 17 00:00:00 2001
From: Pavel Karpy <carpawell@nspcc.ru>
Date: Mon, 27 Dec 2021 21:08:01 +0300
Subject: [PATCH] [#1059] control: Provide shard's real mode

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
---
 pkg/services/control/server/list_shards.go | 26 +++++++++++++++-------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/pkg/services/control/server/list_shards.go b/pkg/services/control/server/list_shards.go
index 8e5ddae6c..45e39712e 100644
--- a/pkg/services/control/server/list_shards.go
+++ b/pkg/services/control/server/list_shards.go
@@ -3,6 +3,7 @@ package control
 import (
 	"context"
 
+	"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
 	"github.com/nspcc-dev/neofs-node/pkg/services/control"
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/status"
@@ -24,17 +25,26 @@ func (s *Server) ListShards(_ context.Context, req *control.ListShardsRequest) (
 
 	shardInfos := make([]*control.ShardInfo, 0, len(info.Shards))
 
-	for _, shard := range info.Shards {
+	for _, sh := range info.Shards {
 		si := new(control.ShardInfo)
 
-		si.SetID(*shard.ID)
-		si.SetMetabasePath(shard.MetaBaseInfo.Path)
-		si.SetBlobstorPath(shard.BlobStorInfo.RootPath)
-		si.SetWriteCachePath(shard.WriteCacheInfo.Path)
+		si.SetID(*sh.ID)
+		si.SetMetabasePath(sh.MetaBaseInfo.Path)
+		si.SetBlobstorPath(sh.BlobStorInfo.RootPath)
+		si.SetWriteCachePath(sh.WriteCacheInfo.Path)
 
-		// FIXME: use real shard mode when there are more than just `read-write`
-		// after https://github.com/nspcc-dev/neofs-node/issues/1044
-		si.SetMode(control.ShardMode_READ_WRITE)
+		var mode control.ShardMode
+
+		switch sh.Mode {
+		case shard.ModeReadWrite:
+			mode = control.ShardMode_READ_WRITE
+		case shard.ModeReadOnly:
+			mode = control.ShardMode_READ_ONLY
+		default:
+			mode = control.ShardMode_SHARD_MODE_UNDEFINED
+		}
+
+		si.SetMode(mode)
 
 		shardInfos = append(shardInfos, si)
 	}