Skip to content

Commit 2960f93

Browse files
committed
feat: add readonly information to the disks API response
Forward device readonly info from `go-blockdevice` library. Signed-off-by: Artem Chernyshev <artem.chernyshev@talos-systems.com>
1 parent 735bf9e commit 2960f93

File tree

6 files changed

+80
-24
lines changed

6 files changed

+80
-24
lines changed

api/storage/storage.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ message Disk {
4545
bool system_disk = 11;
4646
// Subsystem is the symlink path in the `/sys/block/<dev>/subsystem`.
4747
string subsystem = 12;
48+
// Readonly specifies if the disk is read only.
49+
bool readonly = 13;
4850
}
4951

5052
// DisksResponse represents the response of the `Disks` RPC.

cmd/talosctl/cmd/talos/disks.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func printDisks(ctx context.Context, c *client.Client) error {
6262
"SIZE",
6363
"BUS_PATH",
6464
"SUBSYSTEM",
65+
"READ_ONLY",
6566
"SYSTEM_DISK",
6667
}, "\t")
6768

@@ -97,6 +98,12 @@ func printDisks(ctx context.Context, c *client.Client) error {
9798
args = append(args, node)
9899
}
99100

101+
isReadonly := ""
102+
103+
if disk.Readonly {
104+
isReadonly = "*"
105+
}
106+
100107
isSystemDisk := ""
101108

102109
if disk.SystemDisk {
@@ -115,6 +122,7 @@ func printDisks(ctx context.Context, c *client.Client) error {
115122
humanize.Bytes(disk.Size),
116123
getWithPlaceholder(disk.BusPath),
117124
getWithPlaceholder(disk.Subsystem),
125+
isReadonly,
118126
isSystemDisk,
119127
}...)
120128

internal/app/storaged/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func (s *Server) Disks(ctx context.Context, in *emptypb.Empty) (reply *storage.D
4444
BusPath: d.BusPath,
4545
SystemDisk: systemDisk != nil && d.DeviceName == systemDisk.Device().Name(),
4646
Subsystem: d.SubSystem,
47+
Readonly: d.ReadOnly,
4748
}
4849
}
4950

pkg/machinery/api/storage/storage.pb.go

Lines changed: 35 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/machinery/api/storage/storage_vtproto.pb.go

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/content/v1.6/reference/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7357,6 +7357,7 @@ Disk represents a disk.
73577357
| bus_path | [string](#string) | | BusPath is the bus path of the disk. |
73587358
| system_disk | [bool](#bool) | | SystemDisk indicates that the disk is used as Talos system disk. |
73597359
| subsystem | [string](#string) | | Subsystem is the symlink path in the `/sys/block/<dev>/subsystem`. |
7360+
| readonly | [bool](#bool) | | Readonly specifies if the disk is read only. |
73607361

73617362

73627363

0 commit comments

Comments
 (0)