Plan imports from published product inventories
This commit is contained in:
@@ -29,9 +29,12 @@ type restoreCommandReport struct {
|
||||
Downloaded int `json:"downloaded"`
|
||||
Conflicts int `json:"conflicts"`
|
||||
Actions []restoreCommandAction `json:"actions"`
|
||||
Satisfied []string `json:"projected_satisfied,omitempty"`
|
||||
Remaining []string `json:"projected_remaining,omitempty"`
|
||||
}
|
||||
type restoreCommandAction struct {
|
||||
Kind string `json:"kind"`
|
||||
SourceID string `json:"source_id,omitempty"`
|
||||
LocalPath string `json:"local_path"`
|
||||
RemoteKey string `json:"remote_key"`
|
||||
Status string `json:"status"`
|
||||
@@ -45,8 +48,9 @@ func restoreSession(ctx context.Context, cfg *config.Config, opts RestorePlanOpt
|
||||
return nil, resultErr
|
||||
}
|
||||
public = &restoreCommandReport{Campaign: diagnostic.Campaign, SessionID: diagnostic.SessionID, RunID: diagnostic.RunID, DryRun: opts.DryRun, Complete: !opts.DryRun && resultErr == nil && diagnostic.Status == "succeeded", Status: diagnostic.Status, Downloaded: diagnostic.Execution.Downloaded, Conflicts: diagnostic.Plan.Conflicts, Actions: []restoreCommandAction{}}
|
||||
public.Satisfied, public.Remaining = diagnostic.Satisfied, diagnostic.Remaining
|
||||
for _, action := range diagnostic.Actions {
|
||||
public.Actions = append(public.Actions, restoreCommandAction{Kind: action.Kind, LocalPath: action.LocalRelativePath, RemoteKey: action.RemoteKey, Status: action.Status, Reason: action.Reason, Error: action.Error})
|
||||
public.Actions = append(public.Actions, restoreCommandAction{Kind: action.Kind, SourceID: action.SourceID, LocalPath: action.LocalRelativePath, RemoteKey: action.RemoteKey, Status: action.Status, Reason: action.Reason, Error: action.Error})
|
||||
}
|
||||
return public, resultErr
|
||||
}
|
||||
@@ -59,6 +63,21 @@ func restoreSessionState(ctx context.Context, cfg *config.Config, opts RestorePl
|
||||
if err != nil {
|
||||
return diagnostic, fmt.Errorf("restore: %w", err)
|
||||
}
|
||||
if opts.DryRun {
|
||||
current, err := deps.discoverRemotePublication(ctx, cfg, objectStore)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("restore: %w", err)
|
||||
}
|
||||
plan, err := deps.buildInventoryRestorePlan(ctx, cfg, current, objectStore, opts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("restore: %w", err)
|
||||
}
|
||||
report, err := newRestoreReport(current, plan, opts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("restore: %w", err)
|
||||
}
|
||||
return report, nil
|
||||
}
|
||||
current, err := deps.discoverRemoteCurrentState(ctx, cfg, objectStore)
|
||||
if err != nil {
|
||||
return diagnostic, fmt.Errorf("restore: %w", err)
|
||||
@@ -74,27 +93,6 @@ func restoreSessionState(ctx context.Context, cfg *config.Config, opts RestorePl
|
||||
if _, _, err := loadManifestAtPathIfPresent(ctx, &manifest.LocalStore{}, manifestPath); err != nil {
|
||||
return diagnostic, fmt.Errorf("restore: %w", err)
|
||||
}
|
||||
if opts.DryRun {
|
||||
plan, err := deps.buildRestorePlan(ctx, cfg, current, objectStore, RestorePlanOptions{
|
||||
IncludeAudio: opts.IncludeAudio,
|
||||
Force: opts.Force,
|
||||
DryRun: true,
|
||||
})
|
||||
if err != nil {
|
||||
return diagnostic, fmt.Errorf("restore: %w", err)
|
||||
}
|
||||
report, err := newRestoreReport(current, plan, RestorePlanOptions{
|
||||
IncludeAudio: opts.IncludeAudio,
|
||||
Force: opts.Force,
|
||||
DryRun: true,
|
||||
})
|
||||
if err != nil {
|
||||
return diagnostic, fmt.Errorf("restore: %w", err)
|
||||
}
|
||||
diagnostic = report
|
||||
return diagnostic, nil
|
||||
}
|
||||
|
||||
artifactStore := artifacts.NewLocalStore(cfg.Pipeline.Workspace.Root)
|
||||
lock, err := acquireWorkspaceLock(ctx, artifactStore, cfg.Pipeline.Workspace.Root, deps.reporter)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user