3
0

Update envoy to not scope referenced workflows

This commit is contained in:
Tomaž Jerman
2023-03-27 17:53:50 +02:00
parent 9a80aef77d
commit 21e3710e8a
3 changed files with 36 additions and 0 deletions

View File

@@ -183,6 +183,12 @@ var scope envoyx.Scope
Identifiers: refs["{{(index .parents 0).refField}}"].Identifiers,
}
for k, ref := range refs {
// @todo temporary solution to not needlessly scope resources.
// Optimally, this would be selectively handled by codegen.
if !strings.HasPrefix(ref.ResourceType, "corteza::compose") {
continue
}
ref.Scope = scope
refs[k] = ref
}

View File

@@ -200,6 +200,12 @@ func ChartToEnvoyNode(r *types.Chart) (node *envoyx.Node, err error) {
Identifiers: refs["NamespaceID"].Identifiers,
}
for k, ref := range refs {
// @todo temporary solution to not needlessly scope resources.
// Optimally, this would be selectively handled by codegen.
if !strings.HasPrefix(ref.ResourceType, "corteza::compose") {
continue
}
ref.Scope = scope
refs[k] = ref
}
@@ -298,6 +304,12 @@ func ModuleToEnvoyNode(r *types.Module) (node *envoyx.Node, err error) {
Identifiers: refs["NamespaceID"].Identifiers,
}
for k, ref := range refs {
// @todo temporary solution to not needlessly scope resources.
// Optimally, this would be selectively handled by codegen.
if !strings.HasPrefix(ref.ResourceType, "corteza::compose") {
continue
}
ref.Scope = scope
refs[k] = ref
}
@@ -393,6 +405,12 @@ func ModuleFieldToEnvoyNode(r *types.ModuleField) (node *envoyx.Node, err error)
Identifiers: refs["NamespaceID"].Identifiers,
}
for k, ref := range refs {
// @todo temporary solution to not needlessly scope resources.
// Optimally, this would be selectively handled by codegen.
if !strings.HasPrefix(ref.ResourceType, "corteza::compose") {
continue
}
ref.Scope = scope
refs[k] = ref
}
@@ -550,6 +568,12 @@ func PageToEnvoyNode(r *types.Page) (node *envoyx.Node, err error) {
Identifiers: refs["NamespaceID"].Identifiers,
}
for k, ref := range refs {
// @todo temporary solution to not needlessly scope resources.
// Optimally, this would be selectively handled by codegen.
if !strings.HasPrefix(ref.ResourceType, "corteza::compose") {
continue
}
ref.Scope = scope
refs[k] = ref
}

View File

@@ -317,6 +317,12 @@ func (aa Identifiers) HasIntersection(bb Identifiers) bool {
return true
}
// If the second identifies are empty we can assume that anything has an intersection with them.
// This is useful when we want to remove any resource of some type.
if len(bb.Slice) == 0 {
return true
}
return len(aa.Intersection(bb)) > 0
}