Merge imported products into local session state
This commit is contained in:
@@ -8,20 +8,16 @@ import (
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/adapters/storage"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/config"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
|
||||
)
|
||||
|
||||
// RemoteCurrentState captures discovered committed remote published current state for one session.
|
||||
type RemoteCurrentState struct {
|
||||
Bucket string
|
||||
SessionPrefix string
|
||||
CurrentManifestKey string
|
||||
RunID string
|
||||
SessionID string
|
||||
Campaign string
|
||||
Manifest *manifest.Manifest
|
||||
ManifestData []byte
|
||||
Commit *artifacts.RemoteCommitManifest
|
||||
Bucket string
|
||||
SessionPrefix string
|
||||
RunID string
|
||||
SessionID string
|
||||
Campaign string
|
||||
Commit *artifacts.RemoteCommitManifest
|
||||
}
|
||||
|
||||
func discoverRemotePublication(ctx context.Context, cfg *config.Config, store storage.ObjectStore) (*RemoteCurrentState, error) {
|
||||
@@ -42,43 +38,3 @@ func discoverRemotePublication(ctx context.Context, cfg *config.Config, store st
|
||||
}
|
||||
return &RemoteCurrentState{Bucket: bucket, SessionPrefix: prefix, RunID: current.Commit.RunID, SessionID: current.Commit.SessionID, Campaign: current.Commit.Campaign, Commit: current.Commit}, nil
|
||||
}
|
||||
|
||||
func discoverRemoteCurrentState(ctx context.Context, cfg *config.Config, store storage.ObjectStore) (*RemoteCurrentState, error) {
|
||||
if cfg == nil || cfg.Pipeline == nil || cfg.Session == nil {
|
||||
return nil, fmt.Errorf("resolved config with pipeline/session is required")
|
||||
}
|
||||
if store == nil {
|
||||
return nil, fmt.Errorf("remote object store is required")
|
||||
}
|
||||
|
||||
bucket := artifacts.ResolvePublishBucket(cfg, nil)
|
||||
if strings.TrimSpace(bucket) == "" {
|
||||
return nil, fmt.Errorf("publish bucket is required")
|
||||
}
|
||||
sessionPrefix, err := artifacts.ResolvePublishSessionPrefix(cfg, nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("resolve publish session prefix: %w", err)
|
||||
}
|
||||
requestedSession := strings.TrimSpace(cfg.Session.SessionID)
|
||||
requestedCampaign := strings.TrimSpace(cfg.Session.Campaign)
|
||||
current, err := artifacts.LoadCurrentState(ctx, store, sessionPrefix, artifacts.CurrentStateValidation{
|
||||
ExpectedSessionID: requestedSession,
|
||||
ExpectedCampaign: requestedCampaign,
|
||||
ValidateRunID: true,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("remote %w", err)
|
||||
}
|
||||
|
||||
return &RemoteCurrentState{
|
||||
Bucket: bucket,
|
||||
SessionPrefix: sessionPrefix,
|
||||
CurrentManifestKey: current.CurrentManifestKey,
|
||||
RunID: current.RunID,
|
||||
SessionID: strings.TrimSpace(current.Manifest.SessionID),
|
||||
Campaign: strings.TrimSpace(current.Manifest.Campaign),
|
||||
Manifest: current.Manifest,
|
||||
ManifestData: append([]byte(nil), current.ManifestData...),
|
||||
Commit: current.Commit,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user