Merge imported products into local session state
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -78,17 +77,10 @@ func restoreSessionState(ctx context.Context, cfg *config.Config, opts RestorePl
|
||||
}
|
||||
return report, nil
|
||||
}
|
||||
current, err := deps.discoverRemoteCurrentState(ctx, cfg, objectStore)
|
||||
current, err := deps.discoverRemotePublication(ctx, cfg, objectStore)
|
||||
if err != nil {
|
||||
return diagnostic, fmt.Errorf("restore: %w", err)
|
||||
}
|
||||
if current == nil || len(current.ManifestData) == 0 {
|
||||
return diagnostic, fmt.Errorf("restore: verified remote session manifest is required")
|
||||
}
|
||||
destinationRoot := artifacts.SessionWorkDirForCampaign(cfg.Pipeline.Workspace.Root, cfg.Session.Campaign, cfg.Session.SessionID)
|
||||
if _, err := prepareRestoredManifest(ctx, cfg, current, bytes.NewReader(current.ManifestData), destinationRoot, true); err != nil {
|
||||
return diagnostic, fmt.Errorf("restore: validate remote session manifest: %w", err)
|
||||
}
|
||||
manifestPath := artifacts.SessionManifestPathForCampaign(cfg.Pipeline.Workspace.Root, cfg.Session.Campaign, cfg.Session.SessionID)
|
||||
if _, _, err := loadManifestAtPathIfPresent(ctx, &manifest.LocalStore{}, manifestPath); err != nil {
|
||||
return diagnostic, fmt.Errorf("restore: %w", err)
|
||||
@@ -117,7 +109,7 @@ func restoreSessionState(ctx context.Context, cfg *config.Config, opts RestorePl
|
||||
// Classification and installation share the same transition lock as a
|
||||
// runner. This prevents a runner from making reuse decisions against state
|
||||
// that restore is about to replace.
|
||||
plan, err := deps.buildRestorePlan(ctx, cfg, current, objectStore, RestorePlanOptions{
|
||||
plan, err := deps.buildInventoryRestorePlan(ctx, cfg, current, objectStore, RestorePlanOptions{
|
||||
IncludeAudio: opts.IncludeAudio,
|
||||
Force: opts.Force,
|
||||
})
|
||||
@@ -167,6 +159,9 @@ func restoreSessionState(ctx context.Context, cfg *config.Config, opts RestorePl
|
||||
if result == nil {
|
||||
return diagnostic, fmt.Errorf("restore execution returned no result")
|
||||
}
|
||||
if err := installInventoryBaseline(ctx, cfg, plan, &manifest.LocalStore{}); err != nil {
|
||||
return diagnostic, fmt.Errorf("restore: install local baseline: %w", err)
|
||||
}
|
||||
report.Execution.Downloaded = result.DownloadedCount
|
||||
report.setSucceeded()
|
||||
if err := clearRestoreMarker(artifactStore.SessionPathsFor(cfg.Session.Campaign, cfg.Session.SessionID)); err != nil {
|
||||
@@ -181,7 +176,7 @@ func restoreSessionState(ctx context.Context, cfg *config.Config, opts RestorePl
|
||||
|
||||
func restoreCommand(deps commandDependencies) commandkit.Command {
|
||||
common := newConfigurationFlags(func(input **restoreCommandInput) *configurationSelection { return &(*input).Selection })
|
||||
return commandkit.NewCommand(commandkit.CommandSpec[*restoreCommandInput]{Name: "restore", Summary: "Restore the committed remote session snapshot.", NewInput: func() *restoreCommandInput { return &restoreCommandInput{} },
|
||||
return commandkit.NewCommand(commandkit.CommandSpec[*restoreCommandInput]{Name: "restore", Summary: "Import products from the current remote publication.", NewInput: func() *restoreCommandInput { return &restoreCommandInput{} },
|
||||
Flags: []commandkit.Flag[*restoreCommandInput]{common.Config, common.Overlay, common.Campaign, common.CampaignFile, common.SessionFile, common.PartyFile,
|
||||
commandkit.ValueFlag(commandkit.FlagMeta{Name: "previous-session-id", Usage: "Assert the previous session identity."}, nil, stringValue, func(input **restoreCommandInput, value commandkit.Supplied[string]) {
|
||||
(*input).PreviousSession = value.Value
|
||||
|
||||
Reference in New Issue
Block a user