From e2fa956b64e7d3d6d92e4c74085c04fac8ca05f3 Mon Sep 17 00:00:00 2001 From: Nathan Jenan Date: Tue, 21 Aug 2018 13:30:34 -0700 Subject: [PATCH] Add dynamic field to field struct This change adds a dynamic field indicator to the field struct. This is so we can remove the dynamic fields from an existing schema before merging the dynamic schema and actual schema to prevent removed dynamic fields form being incorrectly left behind on the schema. Issue: https://github.com/rancher/rancher/issues/12698 --- types/schemas.go | 7 ++++++- types/types.go | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/types/schemas.go b/types/schemas.go index f724c997..5d2d7d67 100644 --- a/types/schemas.go +++ b/types/schemas.go @@ -170,7 +170,12 @@ func (s *Schemas) embed(schema *Schema) { newSchema.ResourceFields = map[string]Field{} for k, v := range target.ResourceFields { - newSchema.ResourceFields[k] = v + // We remove the dynamic fields off the existing schema in case + // they've been removed from the dynamic schema so they won't + // be accidentally left over + if !v.DynamicField { + newSchema.ResourceFields[k] = v + } } for k, v := range schema.ResourceFields { newSchema.ResourceFields[k] = v diff --git a/types/types.go b/types/types.go index 88dfad3e..4951c70b 100644 --- a/types/types.go +++ b/types/types.go @@ -136,6 +136,7 @@ type Field struct { InvalidChars string `json:"invalidChars,omitempty"` Description string `json:"description,omitempty"` CodeName string `json:"-"` + DynamicField bool `json:"dynamicField,omitempty"` } type Action struct {