1
0
mirror of https://github.com/rancher/types.git synced 2025-08-02 05:11:59 +00:00

Add project and cluster level catalog #13444

Add cluster level catalog
This commit is contained in:
rajashree 2018-08-06 17:49:38 -07:00 committed by Alena Prokharchyk
parent a4584e3855
commit 4e7e6915ae
2 changed files with 57 additions and 1 deletions

View File

@ -2,6 +2,8 @@ package v3
import (
"github.com/rancher/norman/condition"
"github.com/rancher/norman/types"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
@ -69,7 +71,11 @@ type Template struct {
type TemplateSpec struct {
DisplayName string `json:"displayName"`
CatalogID string `json:"catalogId,omitempty" norman:"type=reference[catalog]"`
ProjectCatalogID string `json:"projectCatalogId,omitempty" norman:"type=reference[projectCatalog]"`
ClusterCatalogID string `json:"clusterCatalogId,omitempty" norman:"type=reference[clusterCatalog]"`
DefaultTemplateVersionID string `json:"defaultTemplateVersionId,omitempty" norman:"type=reference[templateVersion]"`
ProjectID string `json:"projectId,omitempty" norman:"required,type=reference[project]"`
ClusterID string `json:"clusterId,omitempty" norman:"required,type=reference[cluster]"`
Description string `json:"description,omitempty"`
DefaultVersion string `json:"defaultVersion,omitempty" yaml:"default_version,omitempty"`
@ -172,3 +178,17 @@ type TemplateContent struct {
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Data string `json:"data,omitempty"`
}
type ProjectCatalog struct {
types.Namespaced
Catalog `json:",inline" mapstructure:",squash"`
ProjectName string `json:"projectName,omitempty" norman:"type=reference[project]"`
}
type ClusterCatalog struct {
types.Namespaced
Catalog `json:",inline" mapstructure:",squash"`
ClusterName string `json:"clusterName,omitempty" norman:"required,type=reference[cluster]"`
}

View File

@ -34,7 +34,9 @@ var (
Init(globalTypes).
Init(rkeTypes).
Init(alertTypes).
Init(composeType)
Init(composeType).
Init(projectCatalogTypes).
Init(clusterCatalogTypes)
TokenSchemas = factory.Schemas(&Version).
Init(tokens)
@ -544,3 +546,37 @@ func alertTypes(schema *types.Schemas) *types.Schemas {
func composeType(schemas *types.Schemas) *types.Schemas {
return schemas.MustImport(&Version, v3.ComposeConfig{})
}
func projectCatalogTypes(schemas *types.Schemas) *types.Schemas {
return schemas.
AddMapperForType(&Version, v3.ProjectCatalog{},
&m.Move{From: "catalogKind", To: "kind"},
&m.Embed{Field: "status"},
&m.Drop{Field: "helmVersionCommits"},
&mapper.NamespaceIDMapper{}).
MustImportAndCustomize(&Version, v3.ProjectCatalog{}, func(schema *types.Schema) {
schema.ResourceActions = map[string]types.Action{
"refresh": {},
}
schema.CollectionActions = map[string]types.Action{
"refresh": {},
}
})
}
func clusterCatalogTypes(schemas *types.Schemas) *types.Schemas {
return schemas.
AddMapperForType(&Version, v3.ClusterCatalog{},
&m.Move{From: "catalogKind", To: "kind"},
&m.Embed{Field: "status"},
&m.Drop{Field: "helmVersionCommits"},
&mapper.NamespaceIDMapper{}).
MustImportAndCustomize(&Version, v3.ClusterCatalog{}, func(schema *types.Schema) {
schema.ResourceActions = map[string]types.Action{
"refresh": {},
}
schema.CollectionActions = map[string]types.Action{
"refresh": {},
}
})
}