mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-27 19:43:34 +00:00
validate machine info before returning in ListMachine
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"google.golang.org/protobuf/encoding/protojson"
|
"google.golang.org/protobuf/encoding/protojson"
|
||||||
|
"log/slog"
|
||||||
"uncloud/internal/corrosion"
|
"uncloud/internal/corrosion"
|
||||||
"uncloud/internal/machine/api/pb"
|
"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 {
|
if err = protojson.Unmarshal([]byte(mJSON), &m); err != nil {
|
||||||
return nil, fmt.Errorf("unmarshal machine info: %w", err)
|
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)
|
machines = append(machines, &m)
|
||||||
}
|
}
|
||||||
return machines, nil
|
return machines, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user