From 2511476f4cef5aa5343a55b2f08e3d8889c6894f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=C5=BE=20Jerman?= Date: Sat, 25 Sep 2021 09:34:52 +0200 Subject: [PATCH] Fix improper module field resource translation refs --- pkg/envoy/resource/resource_translation.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/envoy/resource/resource_translation.go b/pkg/envoy/resource/resource_translation.go index e06721ca2..3276c2a00 100644 --- a/pkg/envoy/resource/resource_translation.go +++ b/pkg/envoy/resource/resource_translation.go @@ -3,6 +3,7 @@ package resource import ( "fmt" + composeTypes "github.com/cortezaproject/corteza-server/compose/types" "github.com/cortezaproject/corteza-server/system/types" "golang.org/x/text/language" ) @@ -33,8 +34,15 @@ func NewResourceTranslation(res types.ResourceTranslationSet, refResource string r.RefRes = r.AddRef(refRes.ResourceType, refRes.Identifiers.StringSlice()...) // any additional constraints - for _, rp := range refPath { - r.RefPath = append(r.RefPath, r.AddRef(rp.ResourceType, rp.Identifiers.StringSlice()...)) + for i, rp := range refPath { + ref := MakeRef(rp.ResourceType, rp.Identifiers) + + // @todo generalize when needed; for now only module field resource translations require this + if i == 1 && refRes.ResourceType == composeTypes.ModuleFieldResourceType { + ref = ref.Constraint(r.RefPath[0]) + } + + r.RefPath = append(r.RefPath, r.addRef(ref)) } return r