Alexey Palazhchenko 0dbaeb9e65 chore: update tools, use new generators
To stay current.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
2021-03-16 11:17:15 -07:00

47 lines
1.1 KiB
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package internal
import (
"context"
"github.com/golang/protobuf/ptypes/empty"
"github.com/talos-systems/go-blockdevice/blockdevice/util"
"github.com/talos-systems/talos/pkg/machinery/api/storage"
)
// Server implements storage.StorageService.
// TODO: this is not a full blown service yet, it's used as the common base in the machine and the maintenance services.
type Server struct{}
// Disks implements storage.StorageService.
func (s *Server) Disks(ctx context.Context, in *empty.Empty) (reply *storage.DisksResponse, err error) {
disks, err := util.GetDisks()
if err != nil {
return nil, err
}
diskList := make([]*storage.Disk, len(disks))
for i, disk := range disks {
diskList[i] = &storage.Disk{
DeviceName: disk.DeviceName,
Model: disk.Model,
Size: disk.Size,
}
}
reply = &storage.DisksResponse{
Messages: []*storage.Disks{
{
Disks: diskList,
},
},
}
return reply, nil
}