From 496fb9f951e60d57042f0ffafb98d48e7eeb193c Mon Sep 17 00:00:00 2001 From: Daishan Peng Date: Fri, 2 Mar 2018 12:55:40 -0700 Subject: [PATCH] add desiredLabels and desiredAnnotations --- apis/management.cattle.io/v3/machine_types.go | 18 ++++++++++-------- apis/management.cattle.io/v3/schema/schema.go | 9 ++++++++- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/apis/management.cattle.io/v3/machine_types.go b/apis/management.cattle.io/v3/machine_types.go index 35b5817d..30d6cea1 100644 --- a/apis/management.cattle.io/v3/machine_types.go +++ b/apis/management.cattle.io/v3/machine_types.go @@ -154,14 +154,16 @@ type NodeSpec struct { Worker bool `json:"worker" norman:"noupdate"` NodeTemplateName string `json:"nodeTemplateName,omitempty" norman:"type=reference[nodeTemplate],noupdate"` - NodePoolName string `json:"nodePoolName" norman:"type=reference[nodePool],nocreate,noupdate"` - CustomConfig *CustomConfig `json:"customConfig"` - Imported bool `json:"imported"` - Description string `json:"description,omitempty"` - DisplayName string `json:"displayName"` - RequestedHostname string `json:"requestedHostname,omitempty" norman:"type=dnsLabel,nullable,noupdate,required"` - ClusterName string `json:"clusterName,omitempty" norman:"type=reference[cluster],noupdate,required"` - InternalNodeSpec v1.NodeSpec `json:"internalNodeSpec"` + NodePoolName string `json:"nodePoolName" norman:"type=reference[nodePool],nocreate,noupdate"` + CustomConfig *CustomConfig `json:"customConfig"` + Imported bool `json:"imported"` + Description string `json:"description,omitempty"` + DisplayName string `json:"displayName"` + RequestedHostname string `json:"requestedHostname,omitempty" norman:"type=dnsLabel,nullable,noupdate,required"` + ClusterName string `json:"clusterName,omitempty" norman:"type=reference[cluster],noupdate,required"` + InternalNodeSpec v1.NodeSpec `json:"internalNodeSpec"` + DesiredNodeLabels map[string]string `json:"desiredNodeLabels,omitempty"` + DesiredNodeAnnotations map[string]string `json:"desiredNodeAnnotations,omitempty"` } type NodeCommonParams struct { diff --git a/apis/management.cattle.io/v3/schema/schema.go b/apis/management.cattle.io/v3/schema/schema.go index 09fc57e9..38950da1 100644 --- a/apis/management.cattle.io/v3/schema/schema.go +++ b/apis/management.cattle.io/v3/schema/schema.go @@ -178,11 +178,18 @@ func nodeTypes(schemas *types.Schemas) *types.Schemas { &m.Drop{Field: "annotations"}, &m.Move{From: "nodeLabels", To: "labels"}, &m.Move{From: "nodeAnnotations", To: "annotations"}, + &m.Drop{Field: "desiredNodeLabels"}, + &m.Drop{Field: "desiredNodeAnnotations"}, m.DisplayName{}). AddMapperForType(&Version, v3.NodeDriver{}, m.DisplayName{}). AddMapperForType(&Version, v3.NodeTemplate{}, m.DisplayName{}). MustImport(&Version, v3.NodePool{}). - MustImport(&Version, v3.Node{}). + MustImportAndCustomize(&Version, v3.Node{}, func(schema *types.Schema) { + labelField := schema.ResourceFields["labels"] + labelField.Create = true + labelField.Update = true + schema.ResourceFields["labels"] = labelField + }). MustImportAndCustomize(&Version, v3.NodeDriver{}, func(schema *types.Schema) { schema.ResourceActions["activate"] = types.Action{ Output: "nodeDriver",