diff --git a/apis/management.cattle.io/v3/multi_cluster_app.go b/apis/management.cattle.io/v3/multi_cluster_app.go new file mode 100644 index 00000000..52fc12e5 --- /dev/null +++ b/apis/management.cattle.io/v3/multi_cluster_app.go @@ -0,0 +1,41 @@ +package v3 + +import ( + "github.com/rancher/norman/types" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type MultiClusterApp struct { + types.Namespaced + metav1.TypeMeta `json:",inline"` + // Standard object’s 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 MultiClusterAppSpec `json:"spec"` + Status MultiClusterAppStatus `json:"status"` +} + +type MultiClusterAppSpec struct { + TemplateVersionName string `json:"templateVersionName,omitempty" norman:"type=reference[templateVersion],required"` + Answers []Answer `json:"answers,omitempty"` + Targets []Target `json:"targets,omitempty" norman:"required"` +} + +type MultiClusterAppStatus struct { + Healthstate string `json:"healthState,omitempty"` +} + +type Target struct { + ProjectName string `json:"projectName,omitempty" norman:"type=reference[project],required"` + AppName string `json:"appName,omitempty" norman:"type=reference[v3/projects/schemas/app]"` + Healthstate string `json:"healthState,omitempty"` +} + +type Answer struct { + ProjectName string `json:"projectName,omitempty" norman:"type=reference[project]"` + ClusterName string `json:"clusterName,omitempty" norman:"type=reference[cluster]"` + Values map[string]string `json:"values,omitempty" norman:"required"` +} diff --git a/apis/management.cattle.io/v3/schema/schema.go b/apis/management.cattle.io/v3/schema/schema.go index dd488702..994a1146 100644 --- a/apis/management.cattle.io/v3/schema/schema.go +++ b/apis/management.cattle.io/v3/schema/schema.go @@ -36,7 +36,8 @@ var ( Init(alertTypes). Init(composeType). Init(projectCatalogTypes). - Init(clusterCatalogTypes) + Init(clusterCatalogTypes). + Init(multiClusterAppTypes) TokenSchemas = factory.Schemas(&Version). Init(tokens) @@ -578,3 +579,10 @@ func clusterCatalogTypes(schemas *types.Schemas) *types.Schemas { } }) } + +func multiClusterAppTypes(schemas *types.Schemas) *types.Schemas { + return schemas. + AddMapperForType(&Version, v3.MultiClusterApp{}, m.Drop{Field: "namespaceId"}). + MustImport(&Version, v3.MultiClusterApp{}). + MustImport(&Version, v3.Target{}) +} diff --git a/apis/project.cattle.io/v3/app_types.go b/apis/project.cattle.io/v3/app_types.go index 19fa1e0e..025e8262 100644 --- a/apis/project.cattle.io/v3/app_types.go +++ b/apis/project.cattle.io/v3/app_types.go @@ -17,14 +17,15 @@ type App struct { } type AppSpec struct { - ProjectName string `json:"projectName,omitempty" norman:"type=reference[/v3/schemas/project]"` - Description string `json:"description,omitempty"` - TargetNamespace string `json:"targetNamespace,omitempty"` - ExternalID string `json:"externalId,omitempty"` - Files map[string]string `json:"files,omitempty"` - Answers map[string]string `json:"answers,omitempty"` - AppRevisionName string `json:"appRevisionName,omitempty" norman:"type=reference[/v3/project/schemas/apprevision]"` - Prune bool `json:"prune,omitempty"` + ProjectName string `json:"projectName,omitempty" norman:"type=reference[/v3/schemas/project]"` + Description string `json:"description,omitempty"` + TargetNamespace string `json:"targetNamespace,omitempty"` + ExternalID string `json:"externalId,omitempty"` + Files map[string]string `json:"files,omitempty"` + Answers map[string]string `json:"answers,omitempty"` + AppRevisionName string `json:"appRevisionName,omitempty" norman:"type=reference[/v3/project/schemas/apprevision]"` + Prune bool `json:"prune,omitempty"` + MultiClusterAppName string `json:"multiClusterAppName,omitempty" norman:"type=reference[/v3/schemas/multiclusterapp]"` } var (