mirror of
https://github.com/rancher/norman.git
synced 2025-09-25 14:46:57 +00:00
Fixes for subtypes
Change key method (used to find CRD that backs the schema) to use baseType of the schema when it differs from the schema ID. This will allow subtypes to use their base type's CRD store. When creating CRD stores, do not create one for a schema if it is a baseType.
This commit is contained in:
@@ -2,6 +2,7 @@ package crd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/rancher/norman/store/proxy"
|
||||
"github.com/rancher/norman/types"
|
||||
@@ -49,6 +50,10 @@ func NewCRDStoreFromClients(apiExtClientSet apiextclientset.Interface, k8sClient
|
||||
}
|
||||
|
||||
func key(schema *types.Schema) string {
|
||||
if !strings.EqualFold(schema.BaseType, schema.ID) {
|
||||
return schema.Version.Path + "/" + schema.BaseType
|
||||
}
|
||||
|
||||
return schema.Version.Path + "/" + schema.ID
|
||||
}
|
||||
|
||||
@@ -105,7 +110,7 @@ func (c *Store) AddSchemas(ctx context.Context, schemas ...*types.Schema) error
|
||||
var allSchemas []*types.Schema
|
||||
|
||||
for _, schema := range schemas {
|
||||
if schema.Store != nil || !schema.CanList(nil) {
|
||||
if schema.Store != nil || !schema.CanList(nil) || !strings.EqualFold(schema.BaseType, schema.ID) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user