Document and verify published product imports
This commit is contained in:
@@ -30,7 +30,16 @@ func installInventoryBaseline(ctx context.Context, cfg *config.Config, plan *Res
|
||||
if err := artifacts.ValidateSuppliedProduct(paths, action.SourceID, action.LocalRelativePath, record); err != nil {
|
||||
return fmt.Errorf("validate imported product %q: %w", action.SourceID, err)
|
||||
}
|
||||
if priorSourceChecksum(plan.baseline, action.SourceID) == action.SHA256 {
|
||||
}
|
||||
if err := invalidateImportedDependencies(plan.candidate, plan.baseline, plan.Actions); err != nil {
|
||||
return err
|
||||
}
|
||||
return store.Save(ctx, paths.ManifestPath, plan.candidate)
|
||||
}
|
||||
|
||||
func invalidateImportedDependencies(candidate, baseline *manifest.Manifest, actions []RestoreAction) error {
|
||||
for _, action := range actions {
|
||||
if action.SourceID == "" || action.Kind == RestoreActionConflict || priorSourceChecksum(baseline, action.SourceID) == action.SHA256 {
|
||||
continue
|
||||
}
|
||||
producer := importedProductProducer(action.SourceID)
|
||||
@@ -38,14 +47,14 @@ func installInventoryBaseline(ctx context.Context, cfg *config.Config, plan *Res
|
||||
return fmt.Errorf("unknown imported product source %q", action.SourceID)
|
||||
}
|
||||
at := time.Now().UTC()
|
||||
if existing := plan.candidate.Stages[producer]; existing != nil && existing.Status == manifest.StatusSucceeded {
|
||||
plan.candidate.MarkStageStale(producer, at, staleReasonChangedResult)
|
||||
if existing := candidate.Stages[producer]; existing != nil && existing.Status == manifest.StatusSucceeded {
|
||||
candidate.MarkStageStale(producer, at, staleReasonChangedResult)
|
||||
}
|
||||
if _, err := invalidateDependentSucceededStagesWithReason(plan.candidate, producer, at, staleReasonChangedResult); err != nil {
|
||||
if _, err := invalidateDependentSucceededStagesWithReason(candidate, producer, at, staleReasonChangedResult); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return store.Save(ctx, paths.ManifestPath, plan.candidate)
|
||||
return nil
|
||||
}
|
||||
|
||||
func importedProductProducer(source string) string {
|
||||
|
||||
Reference in New Issue
Block a user