Make typed module spec lookup artifact-aware
This commit is contained in:
@@ -99,16 +99,28 @@ func (r *NormalizerRegistry) validateOptions(key string, kind contracts.Artifact
|
||||
}
|
||||
|
||||
func (r *NormalizerRegistry) 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 normalizer spec registered for an exact artifact kind.
|
||||
func (r *NormalizerRegistry) 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
|
||||
// normalizer key.
|
||||
func (r *NormalizerRegistry) RegisteredArtifactKinds(key string) []contracts.ArtifactKind {
|
||||
return r.registeredKinds(key)
|
||||
}
|
||||
|
||||
func (r *NormalizerRegistry) typedEntry(key string, kind contracts.ArtifactKind) (typedNormalizerEntry, bool) {
|
||||
|
||||
Reference in New Issue
Block a user