Add catalog destination state schema

This commit is contained in:
2026-06-19 15:28:03 +00:00
parent a95662226f
commit 20129bfff5
9 changed files with 834 additions and 36 deletions

View File

@@ -233,7 +233,7 @@ func removePrunedStateRecords(ctx context.Context, backend storage.Backend, stat
}
return true, writeRepairedState(ctx, backend, statePath, next)
}
return false, fmt.Errorf("destination state document is empty")
return false, unsupportedStateDocumentError(document)
}
func PlanPrune(document state.StateDocument, policy config.PrunePolicy, options PrunePlanOptions) (PrunePlanReport, error) {
@@ -276,7 +276,17 @@ func pruneCandidatesForDocument(document state.StateDocument, scope state.OwnerS
if document.SharedRoot != nil {
return state.SharedRootPruneCandidates(*document.SharedRoot, scope), nil
}
return nil, fmt.Errorf("destination state document is empty")
return nil, unsupportedStateDocumentError(document)
}
func unsupportedStateDocumentError(document state.StateDocument) error {
if document.SupersededLegacy != nil {
return fmt.Errorf("destination state schema_version %d is superseded legacy state", document.SupersededLegacy.SchemaVersion)
}
if document.Catalog != nil {
return fmt.Errorf("catalog destination state is not supported by this command")
}
return fmt.Errorf("destination state document is empty")
}
func pruneOlderThan(policy config.PrunePolicy) *time.Duration {