github.com/rancher/types@v0.0.0-20220328215343-4370ff10ecd5/factory/schemas.go (about)

     1  package factory
     2  
     3  import (
     4  	"github.com/rancher/norman/types"
     5  	"github.com/rancher/norman/types/factory"
     6  	m "github.com/rancher/norman/types/mapper"
     7  	"github.com/rancher/types/mapper"
     8  )
     9  
    10  func Schemas(version *types.APIVersion) *types.Schemas {
    11  	schemas := factory.Schemas(version)
    12  	baseFunc := schemas.DefaultMappers
    13  	schemas.DefaultMappers = func() []types.Mapper {
    14  		mappers := append([]types.Mapper{
    15  			&mapper.Status{},
    16  		}, baseFunc()...)
    17  		mappers = append(mappers, &m.Scope{
    18  			If: types.NamespaceScope,
    19  			Mappers: []types.Mapper{
    20  				&mapper.NamespaceIDMapper{},
    21  			},
    22  		}, &mapper.NamespaceReference{
    23  			VersionPath: "/v3/project",
    24  		})
    25  		return mappers
    26  	}
    27  	basePostFunc := schemas.DefaultPostMappers
    28  	schemas.DefaultPostMappers = func() []types.Mapper {
    29  		return append(basePostFunc(), &mapper.Creator{})
    30  	}
    31  	return schemas
    32  }