From 338344e37bc5d40d33e6aeb48b93a46c5fc3f4c4 Mon Sep 17 00:00:00 2001 From: Nandor Kracser Date: Mon, 14 May 2018 11:07:39 +0200 Subject: [PATCH] Add the possibility to delete a full table from values --- pkg/chartutil/values.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/chartutil/values.go b/pkg/chartutil/values.go index 66a2658d5..2db15c7bd 100644 --- a/pkg/chartutil/values.go +++ b/pkg/chartutil/values.go @@ -316,6 +316,8 @@ func coalesceTables(dst, src map[string]interface{}) map[string]interface{} { dst[key] = val } else if istable(innerdst) { coalesceTables(innerdst.(map[string]interface{}), val.(map[string]interface{})) + } else if isnull(innerdst) { + delete(dst, key) } else { log.Printf("warning: cannot overwrite table with non table for %s (%v)", key, val) } @@ -388,6 +390,11 @@ func istable(v interface{}) bool { return ok } +// isnull is a special-purpose function to see if the present thing matches the definition of a YAML null. +func isnull(v interface{}) bool { + return v == "null" || v == "Null" || v == "NULL" || v == "~" +} + // PathValue takes a path that traverses a YAML structure and returns the value at the end of that path. // The path starts at the root of the YAML structure and is comprised of YAML keys separated by periods. // Given the following YAML data the value at path "chapter.one.title" is "Loomings".