Skip to content
This repository was archived by the owner on Aug 28, 2025. It is now read-only.

Commit 54b8d92

Browse files
committed
use map native methods
On-behalf-of: @SAP [email protected] Signed-off-by: Artem Shcherbatiuk <[email protected]>
1 parent a9a360c commit 54b8d92

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

listener/pkg/apischema/builder.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,9 @@ func (b *SchemaBuilder) WithScope(rm meta.RESTMapper) *SchemaBuilder {
125125
}
126126

127127
if namespaced {
128-
if schema.VendorExtensible.Extensions == nil {
129-
schema.VendorExtensible.Extensions = map[string]any{}
130-
}
131-
schema.VendorExtensible.Extensions[common.ScopeExtensionKey] = apiextensionsv1.NamespaceScoped
128+
schema.VendorExtensible.AddExtension(common.ScopeExtensionKey, apiextensionsv1.NamespaceScoped)
132129
} else {
133-
if schema.VendorExtensible.Extensions == nil {
134-
schema.VendorExtensible.Extensions = map[string]any{}
135-
}
136-
schema.VendorExtensible.Extensions[common.ScopeExtensionKey] = apiextensionsv1.ClusterScoped
130+
schema.VendorExtensible.AddExtension(common.ScopeExtensionKey, apiextensionsv1.ClusterScoped)
137131
}
138132
}
139133
return b
@@ -161,10 +155,7 @@ func (b *SchemaBuilder) WithCRDCategories(crd *apiextensionsv1.CustomResourceDef
161155
b.log.Debug().Str("resource", resourceKey).Msg("no categories provided for CRD kind")
162156
continue
163157
}
164-
if resourceSchema.VendorExtensible.Extensions == nil {
165-
resourceSchema.VendorExtensible.Extensions = map[string]any{}
166-
}
167-
resourceSchema.VendorExtensible.Extensions[common.CategoriesExtensionKey] = crd.Spec.Names.Categories
158+
resourceSchema.VendorExtensible.AddExtension(common.CategoriesExtensionKey, crd.Spec.Names.Categories)
168159
b.schemas[resourceKey] = resourceSchema
169160
}
170161
return b
@@ -191,10 +182,7 @@ func (b *SchemaBuilder) WithApiResourceCategories(list []*metav1.APIResourceList
191182
if !ok {
192183
continue
193184
}
194-
if resourceSchema.VendorExtensible.Extensions == nil {
195-
resourceSchema.VendorExtensible.Extensions = map[string]any{}
196-
}
197-
resourceSchema.VendorExtensible.Extensions[common.CategoriesExtensionKey] = apiResource.Categories
185+
resourceSchema.VendorExtensible.AddExtension(common.CategoriesExtensionKey, apiResource.Categories)
198186
b.schemas[resourceKey] = resourceSchema
199187
}
200188
}

0 commit comments

Comments
 (0)