diff --git a/apis/management.cattle.io/v3/schema/schema.go b/apis/management.cattle.io/v3/schema/schema.go index 69158c32..d90d7dfc 100644 --- a/apis/management.cattle.io/v3/schema/schema.go +++ b/apis/management.cattle.io/v3/schema/schema.go @@ -26,7 +26,8 @@ var ( Init(clusterTypes). Init(catalogTypes). Init(authnTypes). - Init(schemaTypes) + Init(schemaTypes). + Init(stackTypes) ) func schemaTypes(schemas *types.Schemas) *types.Schemas { @@ -200,3 +201,17 @@ func authnTypes(schemas *types.Schemas) *types.Schemas { } }) } + +func stackTypes(schema *types.Schemas) *types.Schemas { + return schema. + MustImportAndCustomize(&Version, v3.Stack{}, func(schema *types.Schema) { + schema.ResourceActions = map[string]types.Action{ + "upgrade": { + Input: "templateVersionId", + }, + "rollback": { + Input: "revision", + }, + } + }) +} diff --git a/apis/management.cattle.io/v3/stack_types.go b/apis/management.cattle.io/v3/stack_types.go new file mode 100644 index 00000000..5d573490 --- /dev/null +++ b/apis/management.cattle.io/v3/stack_types.go @@ -0,0 +1,40 @@ +package v3 + +import ( + "github.com/rancher/norman/types" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type Stack struct { + types.Namespaced + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec StackSpec `json:"spec,omitempty"` + Status StackStatus `json:"status,omitempty"` +} + +type StackSpec struct { + ProjectName string `json:"projectName,omitempty" norman:"type=reference[project]"` + Description string `json:"description,omitempty"` + InstallNamespace string `json:"installNamespace,omitempty"` + TemplateVersionID string `json:"templateVersionId,omitempty"` + Templates map[string]string `json:"templates,omitempty"` + Answers map[string]string `json:"answers,omitempty"` + Prune bool `json:"prune,omitempty"` + Tag map[string]string `json:"tag,omitempty"` + User string `json:"user,omitempty"` + Groups []string `json:"groups,omitempty"` +} + +type StackStatus struct { + Releases []ReleaseInfo `json:"releases,omitempty"` +} + +type ReleaseInfo struct { + Name string `json:"name"` + Version string `json:"version"` + CreateTimestamp string `json:"createTimestamp"` + ModifiedAt string `json:"modifiedAt"` + TemplateVersionID string `json:"templateVersionId"` +} diff --git a/apis/project.cattle.io/v3/schema/schema.go b/apis/project.cattle.io/v3/schema/schema.go index 4b3ecc66..0ea85ede 100644 --- a/apis/project.cattle.io/v3/schema/schema.go +++ b/apis/project.cattle.io/v3/schema/schema.go @@ -35,9 +35,18 @@ var ( Init(replicaSet). Init(replicationController). Init(daemonSet). - Init(workloadTypes) + Init(workloadTypes). + Init(configMapTypes) ) +func configMapTypes(schemas *types.Schemas) *types.Schemas { + return ConfigMapTypes(&Version, schemas) +} + +func ConfigMapTypes(version *types.APIVersion, schemas *types.Schemas) *types.Schemas { + return schemas.MustImport(version, v1.ConfigMap{}) +} + func namespaceTypes(schemas *types.Schemas) *types.Schemas { return NamespaceTypes(&Version, schemas) }