POC/Provisioning: Fail read/write when we can not find a valid GVR (#97020)

GRV
This commit is contained in:
Ryan McKinley
2024-11-26 09:44:20 +01:00
committed by GitHub
parent d937ec237e
commit 8a2e233dcd
+14
View File
@@ -158,6 +158,15 @@ func (s *filesConnector) doRead(ctx context.Context, logger *slog.Logger, repo r
return 0, nil, err
}
// GVR will exist for anything we can actually save (dashboard/playlist for now)
if parsed.gvr == nil {
if parsed.gvk != nil {
parsed.errors = append(parsed.errors, fmt.Errorf("unknown resource for Kind: "+parsed.gvk.Kind))
} else {
parsed.errors = append(parsed.errors, fmt.Errorf("unknown resource"))
}
}
code := http.StatusOK
if len(parsed.errors) > 0 {
code = http.StatusNotAcceptable
@@ -198,6 +207,11 @@ func (s *filesConnector) doWrite(ctx context.Context, logger *slog.Logger, updat
return nil, err
}
// GVR will exist for anything we can actually save (dashboard/playlist for now)
if parsed.gvr == nil {
return nil, apierrors.NewBadRequest("The payload does not map to a known resource")
}
data, err = parsed.ToSaveBytes()
if err != nil {
return nil, err