1
0
mirror of https://github.com/rancher/types.git synced 2025-06-26 21:51:33 +00:00

Add catalog types

This commit is contained in:
Darren Shepherd 2017-12-05 14:20:57 -07:00
parent a6b44f25da
commit 1e8bcc7e8c
2 changed files with 123 additions and 1 deletions

View File

@ -0,0 +1,114 @@
package v3
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type Catalog struct {
metav1.TypeMeta `json:",inline"`
// Standard objects metadata. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
metav1.ObjectMeta `json:"metadata,omitempty"`
// Specification of the desired behavior of the the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Spec CatalogSpec `json:"spec"`
Status CatalogStatus `json:"status"`
}
type CatalogSpec struct {
URL string `json:"url,omitempty"`
Branch string `json:"branch,omitempty"`
CatalogKind string `json:"catalogKind,omitempty"`
}
type CatalogStatus struct {
Commit string `json:"commit,omitempty"`
}
type Template struct {
metav1.TypeMeta `json:",inline"`
// Standard objects metadata. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
metav1.ObjectMeta `json:"metadata,omitempty"`
// Specification of the desired behavior of the the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Spec TemplateSpec `json:"spec"`
Status TemplateStatus `json:"status"`
}
type TemplateSpec struct {
CatalogName string `json:"catalogName,omitempty"`
IsSystem string `json:"isSystem,omitempty"`
Description string `json:"description,omitempty"`
DefaultVersion string `json:"defaultVersion,omitempty" yaml:"default_version,omitempty"`
Path string `json:"path,omitempty"`
Maintainer string `json:"maintainer,omitempty"`
License string `json:"license,omitempty"`
ProjectURL string `json:"projectURL,omitempty" yaml:"project_url,omitempty"`
UpgradeFrom string `json:"upgradeFrom,omitempty"`
FolderName string `json:"folderName,omitempty"`
Catalog string `json:"catalogId,omitempty"`
Base string `json:"templateBase,omitempty"`
Icon string `json:"icon,omitempty"`
IconFilename string `json:"iconFilename,omitempty"`
Readme string `json:"readme,omitempty"`
Categories []string `json:"categories,omitempty"`
Versions []TemplateVersionSpec `json:"versions,omitempty"`
Category string `json:"category,omitempty"`
}
type TemplateStatus struct {
// todo:
}
type TemplateVersion struct {
metav1.TypeMeta `json:",inline"`
// Standard objects metadata. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
metav1.ObjectMeta `json:"metadata,omitempty"`
// Specification of the desired behavior of the the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Spec TemplateVersionSpec `json:"spec"`
Status TemplateVersionStatus `json:"status"`
}
type TemplateVersionSpec struct {
Revision *int `json:"revision,omitempty"`
Version string `json:"version,omitempty"`
MinimumRancherVersion string `json:"minimumRancherVersion,omitempty" yaml:"minimum_rancher_version,omitempty"`
MaximumRancherVersion string `json:"maximumRancherVersion,omitempty" yaml:"maximum_rancher_version,omitempty"`
UpgradeFrom string `json:"upgradeFrom,omitempty" yaml:"upgrade_from,omitempty"`
Readme string `json:"readme,omitempty"`
Files []File `json:"files,omitempty"`
Questions []Question `json:"questions,omitempty"`
}
type TemplateVersionStatus struct {
// todo
}
type File struct {
Name string `json:"name,omitempty"`
Contents string `json:"contents,omitempty"`
}
type Question struct {
Variable string `json:"variable,omitempty" yaml:"variable,omitempty"`
Label string `json:"label,omitempty" yaml:"label,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Required bool `json:"required,omitempty" yaml:"required,omitempty"`
Default string `json:"default,omitempty" yaml:"default,omitempty"`
Group string `json:"group,omitempty" yaml:"group,omitempty"`
MinLength int `json:"minLength,omitempty" yaml:"min_length,omitempty"`
MaxLength int `json:"maxLength,omitempty" yaml:"max_length,omitempty"`
Min int `json:"min,omitempty" yaml:"min,omitempty"`
Max int `json:"max,omitempty" yaml:"max,omitempty"`
Options []string `json:"options,omitempty" yaml:"options,omitempty"`
ValidChars string `json:"validChars,omitempty" yaml:"valid_chars,omitempty"`
InvalidChars string `json:"invalidChars,omitempty" yaml:"invalid_chars,omitempty"`
}

View File

@ -20,9 +20,17 @@ var (
Init(nodeTypes).
Init(machineTypes).
Init(authTypes).
Init(clusterTypes)
Init(clusterTypes).
Init(catalogTypes)
)
func catalogTypes(schemas *types.Schemas) *types.Schemas {
return schemas.
MustImport(&Version, v3.Catalog{}).
MustImport(&Version, v3.Template{}).
MustImport(&Version, v3.TemplateVersion{})
}
func nodeTypes(schemas *types.Schemas) *types.Schemas {
return schemas.
AddMapperForType(&Version, v1.NodeStatus{},