From 8e53d04d3cb13c998ef09239d402432f6e14514d Mon Sep 17 00:00:00 2001 From: Daishan Peng Date: Wed, 23 May 2018 10:21:49 -0700 Subject: [PATCH] rancher up --- apis/management.cattle.io/v3/cluster_types.go | 4 ++ apis/management.cattle.io/v3/compose_types.go | 20 +------- apis/management.cattle.io/v3/schema/schema.go | 7 ++- .../v3/namespace_compose_types.go | 49 ------------------- apis/project.cattle.io/v3/schema/schema.go | 7 +-- 5 files changed, 11 insertions(+), 76 deletions(-) delete mode 100644 apis/project.cattle.io/v3/namespace_compose_types.go diff --git a/apis/management.cattle.io/v3/cluster_types.go b/apis/management.cattle.io/v3/cluster_types.go index 84f89cb2..fc1e0f57 100644 --- a/apis/management.cattle.io/v3/cluster_types.go +++ b/apis/management.cattle.io/v3/cluster_types.go @@ -240,6 +240,10 @@ type GenerateKubeConfigOutput struct { Config string `json:"config"` } +type ExportOutput struct { + YAMLOutput string `json:"yamlOutput"` +} + type ImportClusterYamlInput struct { YAML string `json:"yaml,omitempty"` DefaultNamespace string `json:"defaultNamespace,omitempty"` diff --git a/apis/management.cattle.io/v3/compose_types.go b/apis/management.cattle.io/v3/compose_types.go index d5bd034c..b60dc233 100644 --- a/apis/management.cattle.io/v3/compose_types.go +++ b/apis/management.cattle.io/v3/compose_types.go @@ -2,12 +2,11 @@ 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" ) -type GlobalComposeConfig struct { +type ComposeConfig struct { metav1.TypeMeta `json:",inline"` // Standard object’s metadata. More info: // https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata @@ -44,20 +43,3 @@ type ComposeCondition struct { // Human-readable message indicating details about last transition Message string `json:"message,omitempty"` } - -type ClusterComposeConfig 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 ClusterComposeSpec `json:"spec,omitempty"` - Status ComposeStatus `json:"status,omitempty"` -} - -type ClusterComposeSpec struct { - ClusterName string `json:"clusterName" norman:"type=reference[cluster]"` - RancherCompose string `json:"rancherCompose,omitempty"` -} diff --git a/apis/management.cattle.io/v3/schema/schema.go b/apis/management.cattle.io/v3/schema/schema.go index 7ef42d4b..9cfc1dd5 100644 --- a/apis/management.cattle.io/v3/schema/schema.go +++ b/apis/management.cattle.io/v3/schema/schema.go @@ -157,6 +157,9 @@ func clusterTypes(schemas *types.Schemas) *types.Schemas { Input: "importClusterYamlInput", Output: "importYamlOutput", } + schema.ResourceActions["exportYaml"] = types.Action{ + Output: "exportOutput", + } }) } @@ -181,6 +184,7 @@ func authzTypes(schemas *types.Schemas) *types.Schemas { Input: "setPodSecurityPolicyTemplateInput", Output: "project", }, + "exportYaml": {}, } }). MustImport(&Version, v3.GlobalRole{}). @@ -482,6 +486,5 @@ func pipelineTypes(schema *types.Schemas) *types.Schemas { } func composeType(schemas *types.Schemas) *types.Schemas { - return schemas.MustImport(&Version, v3.GlobalComposeConfig{}). - MustImport(&Version, v3.ClusterComposeConfig{}) + return schemas.MustImport(&Version, v3.ComposeConfig{}) } diff --git a/apis/project.cattle.io/v3/namespace_compose_types.go b/apis/project.cattle.io/v3/namespace_compose_types.go deleted file mode 100644 index 6b06d699..00000000 --- a/apis/project.cattle.io/v3/namespace_compose_types.go +++ /dev/null @@ -1,49 +0,0 @@ -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" -) - -type NamespaceComposeConfig 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 NamespaceComposeSpec `json:"spec,omitempty"` - Status ComposeStatus `json:"status,omitempty"` -} - -type NamespaceComposeSpec struct { - RancherCompose string `json:"rancherCompose,omitempty"` - ProjectName string `json:"projectName" norman:"type=reference[project]"` - InstallNamespace string `json:"installNamespace,omitempty"` -} - -type ComposeStatus struct { - Conditions []ComposeCondition `json:"conditions,omitempty"` -} - -var ( - ComposeConditionExecuted condition.Cond = "Executed" -) - -type ComposeCondition struct { - // Type of cluster condition. - Type string `json:"type"` - // Status of the condition, one of True, False, Unknown. - Status v1.ConditionStatus `json:"status"` - // The last time this condition was updated. - LastUpdateTime string `json:"lastUpdateTime,omitempty"` - // Last time the condition transitioned from one status to another. - LastTransitionTime string `json:"lastTransitionTime,omitempty"` - // The reason for the condition's last transition. - Reason string `json:"reason,omitempty"` - // Human-readable message indicating details about last transition - Message string `json:"message,omitempty"` -} diff --git a/apis/project.cattle.io/v3/schema/schema.go b/apis/project.cattle.io/v3/schema/schema.go index 8b24d678..3f38bed0 100644 --- a/apis/project.cattle.io/v3/schema/schema.go +++ b/apis/project.cattle.io/v3/schema/schema.go @@ -41,8 +41,7 @@ var ( Init(cronJobTypes). Init(podTemplateSpecTypes). Init(workloadTypes). - Init(appTypes). - Init(namespaceComposeType) + Init(appTypes) ) func configMapTypes(schemas *types.Schemas) *types.Schemas { @@ -734,7 +733,3 @@ func NewWorkloadTypeMapper() types.Mapper { &m.AnnotationField{Field: "publicEndpoints", List: true}, } } - -func namespaceComposeType(schemas *types.Schemas) *types.Schemas { - return schemas.MustImport(&Version, v3.NamespaceComposeConfig{}) -}