1
0
mirror of https://github.com/rancher/types.git synced 2025-08-01 13:07:05 +00:00

Copy namespace to cluster schemas

This commit is contained in:
Darren Shepherd 2017-12-05 14:20:44 -07:00
parent 8873bb7c6b
commit a6b44f25da

View File

@ -3,6 +3,7 @@ package schema
import (
"github.com/rancher/norman/types"
m "github.com/rancher/norman/types/mapper"
"github.com/rancher/types/apis/project.cattle.io/v3/schema"
"github.com/rancher/types/factory"
"github.com/rancher/types/mapper"
"k8s.io/api/core/v1"
@ -16,9 +17,23 @@ var (
}
Schemas = factory.Schemas(&Version).
Init(nodeTypes)
Init(nodeTypes).
Init(copyNamespace)
)
func copyNamespace(schemas *types.Schemas) *types.Schemas {
cloneProjectSchema("namespaceStatus", schemas)
cloneProjectSchema("namespace", schemas)
return schemas
}
func cloneProjectSchema(name string, schemas *types.Schemas) {
schema := schema.Schemas.Schema(&schema.Version, name)
copy := *schema
copy.Version = Version
schemas.AddSchema(&copy)
}
func nodeTypes(schemas *types.Schemas) *types.Schemas {
return schemas.
AddMapperForType(&Version, v1.NodeStatus{},