Make typed module spec lookup artifact-aware
This commit is contained in:
@@ -108,16 +108,28 @@ func (r *MergerRegistry) validateOptions(key string, kind contracts.ArtifactKind
|
||||
}
|
||||
|
||||
func (r *MergerRegistry) Spec(key string) (ModuleSpec, bool) {
|
||||
if r == nil {
|
||||
// Spec is for kind-neutral catalog inspection. Behavior-sensitive callers
|
||||
// must use SpecForArtifact so they select the lane's exact typed variant.
|
||||
kinds := r.registeredKinds(key)
|
||||
if len(kinds) == 0 {
|
||||
return ModuleSpec{}, false
|
||||
}
|
||||
module := strings.TrimSpace(key)
|
||||
for variant, entry := range r.typedEntries {
|
||||
if variant.module == module {
|
||||
return cloneModuleSpec(entry.spec), true
|
||||
}
|
||||
return r.SpecForArtifact(key, kinds[0])
|
||||
}
|
||||
|
||||
// SpecForArtifact returns the merger spec registered for an exact artifact kind.
|
||||
func (r *MergerRegistry) SpecForArtifact(key string, kind contracts.ArtifactKind) (ModuleSpec, bool) {
|
||||
entry, ok := r.typedEntry(key, kind)
|
||||
if !ok {
|
||||
return ModuleSpec{}, false
|
||||
}
|
||||
return ModuleSpec{}, false
|
||||
return cloneModuleSpec(entry.spec), true
|
||||
}
|
||||
|
||||
// RegisteredArtifactKinds returns the sorted artifact kinds registered for a
|
||||
// merger key.
|
||||
func (r *MergerRegistry) RegisteredArtifactKinds(key string) []contracts.ArtifactKind {
|
||||
return r.registeredKinds(key)
|
||||
}
|
||||
|
||||
func (r *MergerRegistry) typedEntry(key string, kind contracts.ArtifactKind) (typedMergerEntry, bool) {
|
||||
|
||||
Reference in New Issue
Block a user