Derive artifact catalogs from the selected party without changing configuration
This commit is contained in:
@@ -54,7 +54,6 @@ func finalizeLoadedPipeline(cfg *PipelineConfig) (*PipelineConfig, error) {
|
||||
if err := finalizePipelineResolution(cfg); err != nil {
|
||||
return nil, fmt.Errorf("load pipeline config: %w", err)
|
||||
}
|
||||
retainArtifactFamilyDeclarations(cfg)
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
@@ -156,24 +155,31 @@ func LoadWithSessionOptions(pipelinePath, campaignPath, sessionPath string, sess
|
||||
// subsequent local or remote session resolution. It prevents a command from
|
||||
// reloading the root pipeline after campaign selection.
|
||||
type LoadedPipelineCampaign struct {
|
||||
PipelinePath string
|
||||
Pipeline *PipelineConfig
|
||||
CampaignPath string
|
||||
Campaign *CampaignConfig
|
||||
Party ResolvedParty
|
||||
PipelinePath string
|
||||
Pipeline *PipelineConfig
|
||||
CampaignPath string
|
||||
Campaign *CampaignConfig
|
||||
Party ResolvedParty
|
||||
ArtifactCatalog *ArtifactCatalog
|
||||
}
|
||||
|
||||
// LoadPipelineCampaign combines already loaded pipeline and campaign documents
|
||||
// with their campaign-owned party source. Callers that later resolve a session
|
||||
// retain this context rather than independently reimplementing party loading.
|
||||
func LoadPipelineCampaign(pipelinePath string, pipeline *PipelineConfig, campaignPath string, campaign *CampaignConfig) (LoadedPipelineCampaign, error) {
|
||||
return LoadPipelineCampaignWithPartyFile(pipelinePath, pipeline, campaignPath, campaign, nil)
|
||||
}
|
||||
|
||||
// LoadPipelineCampaignWithPartyFile derives domain context using an explicit
|
||||
// invocation-relative roster file or the campaign's default when omitted.
|
||||
func LoadPipelineCampaignWithPartyFile(pipelinePath string, pipeline *PipelineConfig, campaignPath string, campaign *CampaignConfig, partyFile *string) (LoadedPipelineCampaign, error) {
|
||||
if pipeline == nil {
|
||||
return LoadedPipelineCampaign{}, fmt.Errorf("pipeline config is required")
|
||||
}
|
||||
if campaign == nil {
|
||||
return LoadedPipelineCampaign{}, fmt.Errorf("campaign config is required")
|
||||
}
|
||||
party, err := resolveCampaignParty(campaignPath, campaign)
|
||||
party, err := ResolveParty(campaignPath, campaign, partyFile)
|
||||
if err != nil {
|
||||
return LoadedPipelineCampaign{}, err
|
||||
}
|
||||
@@ -181,9 +187,8 @@ func LoadPipelineCampaign(pipelinePath string, pipeline *PipelineConfig, campaig
|
||||
}
|
||||
|
||||
// LoadPipelineCampaignWithParty combines an already loaded pipeline and
|
||||
// campaign with one already resolved campaign-owned party. It is useful when
|
||||
// more than one independently resolved pipeline must be expanded against the
|
||||
// exact same party document.
|
||||
// campaign with one already resolved party. Independently loaded pipelines can
|
||||
// derive their catalogs against the same selected roster.
|
||||
func LoadPipelineCampaignWithParty(pipelinePath string, pipeline *PipelineConfig, campaignPath string, campaign *CampaignConfig, party ResolvedParty) (LoadedPipelineCampaign, error) {
|
||||
if pipeline == nil {
|
||||
return LoadedPipelineCampaign{}, fmt.Errorf("pipeline config is required")
|
||||
@@ -194,15 +199,24 @@ func LoadPipelineCampaignWithParty(pipelinePath string, pipeline *PipelineConfig
|
||||
if party.Canonical == nil {
|
||||
return LoadedPipelineCampaign{}, fmt.Errorf("resolved campaign party is required")
|
||||
}
|
||||
if err := expandPipelineArtifactFamilies(pipeline, party); err != nil {
|
||||
if party.Players == nil {
|
||||
players, err := party.Canonical.PlayersYAML()
|
||||
if err != nil {
|
||||
return LoadedPipelineCampaign{}, err
|
||||
}
|
||||
party.Players = players
|
||||
}
|
||||
catalog, err := DeriveArtifactCatalog(pipeline, party)
|
||||
if err != nil {
|
||||
return LoadedPipelineCampaign{}, err
|
||||
}
|
||||
return LoadedPipelineCampaign{
|
||||
PipelinePath: pipelinePath,
|
||||
Pipeline: pipeline,
|
||||
CampaignPath: campaignPath,
|
||||
Campaign: campaign,
|
||||
Party: party,
|
||||
PipelinePath: pipelinePath,
|
||||
Pipeline: pipeline,
|
||||
CampaignPath: campaignPath,
|
||||
Campaign: campaign,
|
||||
Party: party,
|
||||
ArtifactCatalog: catalog,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -240,14 +254,15 @@ func ResolveLoadedPipelineCampaign(loaded LoadedPipelineCampaign, sessionPath st
|
||||
loaded.Party = party
|
||||
}
|
||||
cfg := &Config{
|
||||
Pipeline: loaded.Pipeline,
|
||||
Campaign: loaded.Campaign,
|
||||
Session: sessionCfg,
|
||||
PipelinePath: loaded.PipelinePath,
|
||||
CampaignPath: loaded.CampaignPath,
|
||||
SessionPath: sessionPath,
|
||||
SessionSource: sessionSource,
|
||||
Party: loaded.Party,
|
||||
Pipeline: loaded.Pipeline,
|
||||
Campaign: loaded.Campaign,
|
||||
Session: sessionCfg,
|
||||
PipelinePath: loaded.PipelinePath,
|
||||
CampaignPath: loaded.CampaignPath,
|
||||
SessionPath: sessionPath,
|
||||
SessionSource: sessionSource,
|
||||
Party: loaded.Party,
|
||||
ArtifactCatalog: loaded.ArtifactCatalog,
|
||||
}
|
||||
cfg.CampaignDocument = loaded.Campaign
|
||||
cfg.SessionDocument = sessionCfg
|
||||
@@ -265,6 +280,7 @@ func ResolveLoadedPipelineCampaign(loaded LoadedPipelineCampaign, sessionPath st
|
||||
if strings.TrimSpace(cfg.SessionSource.LocalPath) == "" {
|
||||
cfg.SessionSource.LocalPath = sessionPath
|
||||
}
|
||||
stableInputs.PartyFile = ResolvedInputFile{Path: loaded.Party.Source.Path, ConfigPath: loaded.Party.Source.ConfigPath, Source: loaded.Party.Source.Source}
|
||||
cfg.StableInputs = stableInputs
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user