mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
validate machine info before returning in ListMachine
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"log/slog"
|
||||
"uncloud/internal/corrosion"
|
||||
"uncloud/internal/machine/api/pb"
|
||||
)
|
||||
@@ -77,6 +78,10 @@ func (s *Store) ListMachines(ctx context.Context) ([]*pb.MachineInfo, error) {
|
||||
if err = protojson.Unmarshal([]byte(mJSON), &m); err != nil {
|
||||
return nil, fmt.Errorf("unmarshal machine info: %w", err)
|
||||
}
|
||||
if err = m.Network.Validate(); err != nil {
|
||||
slog.Error("Invalid network configuration for machine in store", "id", m.Id, "error", err)
|
||||
continue
|
||||
}
|
||||
machines = append(machines, &m)
|
||||
}
|
||||
return machines, nil
|
||||
|
||||
Reference in New Issue
Block a user