From 54d3ea0e7bce0a97db63c9cfa7b54794743b42a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Wed, 2 Jun 2021 23:05:49 +0200 Subject: Change handling of NULL nodes to new yaml.v3 semantics --- pkg/config/yaml.go | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/pkg/config/yaml.go b/pkg/config/yaml.go index c82a57e..48269ba 100644 --- a/pkg/config/yaml.go +++ b/pkg/config/yaml.go @@ -13,9 +13,8 @@ import ( ) const ( - strTag = "!!str" - nullTag = "!!null" - emptyTag = "" + strTag = "!!str" + nullTag = "!!null" ) type config struct { @@ -51,19 +50,13 @@ func (grpFeed *configGroupFeed) isFeed() bool { } func (grpFeed *configGroupFeed) target(autoTarget bool) string { - tag := grpFeed.Target.ShortTag() - switch tag { - case strTag: - return grpFeed.Target.Value - case nullTag: - return "" - case emptyTag: - if !autoTarget { + if !autoTarget || !grpFeed.Target.IsZero() { + if grpFeed.Target.ShortTag() == nullTag { + // null may be represented by ~ or NULL or ... + // Value would hold this representation, which we do not want return "" } - // tag not set and autoTarget is on: continue on - default: - panic("unexpected tag " + tag + " for target node") + return grpFeed.Target.Value } if grpFeed.Feed.Name != "" { -- cgit v1.2.3