From 536d36c706969a7d9f5cfc84b2582158dd4663a5 Mon Sep 17 00:00:00 2001 From: Craig Jellick Date: Wed, 31 Jan 2018 10:42:59 -0700 Subject: [PATCH] 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. --- store/crd/crd_store.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/store/crd/crd_store.go b/store/crd/crd_store.go index dc6f2673..9a251035 100644 --- a/store/crd/crd_store.go +++ b/store/crd/crd_store.go @@ -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 }