1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-25 06:26:50 +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:
Craig Jellick
2018-01-31 10:42:59 -07:00
parent d2d5892f3f
commit 536d36c706

View File

@@ -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
}