Fix missing method NameNormalized panic

Closes #12795
This commit is contained in:
Bjørn Erik Pedersen 2024-08-25 22:51:38 +02:00
parent e1becf1dfe
commit 5f667f8796
2 changed files with 9 additions and 1 deletions

View file

@ -560,7 +560,7 @@ func (m *pageMap) getOrCreateResourcesForPage(ps *pageState) resource.Resources
for _, r := range res2 { for _, r := range res2 {
var found bool var found bool
for _, r2 := range res { for _, r2 := range res {
if r2.(resource.NameNormalizedProvider).NameNormalized() == r.(resource.NameNormalizedProvider).NameNormalized() { if resource.NameNormalizedOrName(r2) == resource.NameNormalizedOrName(r) {
found = true found = true
break break
} }

View file

@ -298,3 +298,11 @@ func (r resourceTypesHolder) ResourceType() string {
func NewResourceTypesProvider(mediaType media.Type, resourceType string) ResourceTypesProvider { func NewResourceTypesProvider(mediaType media.Type, resourceType string) ResourceTypesProvider {
return resourceTypesHolder{mediaType: mediaType, resourceType: resourceType} return resourceTypesHolder{mediaType: mediaType, resourceType: resourceType}
} }
// NameNormalizedOrName returns the normalized name if available, otherwise the name.
func NameNormalizedOrName(r Resource) string {
if nn, ok := r.(NameNormalizedProvider); ok {
return nn.NameNormalized()
}
return r.Name()
}