Tweak envoy to better handle nested parent refs
* Don't overwrite parent refs if they are already set * Allow page layout's pageID to be referenced as selfID
This commit is contained in:
committed by
Jože Fortun
parent
802e94724d
commit
2196dd9ea4
+12
-8
@@ -430,10 +430,12 @@ func (d *auxYamlDoc) unmarshalWorkflowNode(dctx documentContext, n *yaml.Node, m
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["WorkflowID"] = envoyx.Ref{
|
||||
ResourceType: types.WorkflowResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["WorkflowID"]; !ok {
|
||||
a.References["WorkflowID"] = envoyx.Ref{
|
||||
ResourceType: types.WorkflowResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
@@ -766,10 +768,12 @@ func (d *auxYamlDoc) unmarshalTriggerNode(dctx documentContext, n *yaml.Node, me
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["TriggerID"] = envoyx.Ref{
|
||||
ResourceType: types.TriggerResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["TriggerID"]; !ok {
|
||||
a.References["TriggerID"] = envoyx.Ref{
|
||||
ResourceType: types.TriggerResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
|
||||
@@ -559,10 +559,12 @@ func (d *auxYamlDoc) unmarshal{{ .expIdent }}Node(dctx documentContext, n *yaml.
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["{{if .envoy.yaml.extendedResourceRefIdent}}{{.envoy.yaml.extendedResourceRefIdent}}{{else}}{{.expIdent}}ID{{end}}"] = envoyx.Ref{
|
||||
ResourceType: types.{{ .expIdent }}ResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["{{if .envoy.yaml.extendedResourceRefIdent}}{{.envoy.yaml.extendedResourceRefIdent}}{{else}}{{.expIdent}}ID{{end}}"]; !ok {
|
||||
a.References["{{if .envoy.yaml.extendedResourceRefIdent}}{{.envoy.yaml.extendedResourceRefIdent}}{{else}}{{.expIdent}}ID{{end}}"] = envoyx.Ref{
|
||||
ResourceType: types.{{ .expIdent }}ResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
|
||||
Generated
+36
-24
@@ -435,10 +435,12 @@ func (d *auxYamlDoc) unmarshalChartNode(dctx documentContext, n *yaml.Node, meta
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["ChartID"] = envoyx.Ref{
|
||||
ResourceType: types.ChartResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["ChartID"]; !ok {
|
||||
a.References["ChartID"] = envoyx.Ref{
|
||||
ResourceType: types.ChartResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
@@ -770,10 +772,12 @@ func (d *auxYamlDoc) unmarshalModuleNode(dctx documentContext, n *yaml.Node, met
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["ModuleID"] = envoyx.Ref{
|
||||
ResourceType: types.ModuleResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["ModuleID"]; !ok {
|
||||
a.References["ModuleID"] = envoyx.Ref{
|
||||
ResourceType: types.ModuleResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
@@ -1129,10 +1133,12 @@ func (d *auxYamlDoc) unmarshalModuleFieldNode(dctx documentContext, n *yaml.Node
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["ModuleFieldID"] = envoyx.Ref{
|
||||
ResourceType: types.ModuleFieldResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["ModuleFieldID"]; !ok {
|
||||
a.References["ModuleFieldID"] = envoyx.Ref{
|
||||
ResourceType: types.ModuleFieldResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
@@ -1477,10 +1483,12 @@ func (d *auxYamlDoc) unmarshalNamespaceNode(dctx documentContext, n *yaml.Node,
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["NamespaceID"] = envoyx.Ref{
|
||||
ResourceType: types.NamespaceResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["NamespaceID"]; !ok {
|
||||
a.References["NamespaceID"] = envoyx.Ref{
|
||||
ResourceType: types.NamespaceResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
@@ -1904,10 +1912,12 @@ func (d *auxYamlDoc) unmarshalPageNode(dctx documentContext, n *yaml.Node, meta
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["SelfID"] = envoyx.Ref{
|
||||
ResourceType: types.PageResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["SelfID"]; !ok {
|
||||
a.References["SelfID"] = envoyx.Ref{
|
||||
ResourceType: types.PageResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
@@ -2258,10 +2268,12 @@ func (d *auxYamlDoc) unmarshalPageLayoutNode(dctx documentContext, n *yaml.Node,
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["PageLayoutID"] = envoyx.Ref{
|
||||
ResourceType: types.PageLayoutResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["PageLayoutID"]; !ok {
|
||||
a.References["PageLayoutID"] = envoyx.Ref{
|
||||
ResourceType: types.PageLayoutResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
|
||||
@@ -12,6 +12,10 @@ pageLayout: {
|
||||
|
||||
model: {
|
||||
ident: "compose_page_layout"
|
||||
|
||||
defaultGetter: true
|
||||
defaultSetter: true
|
||||
|
||||
attributes: {
|
||||
id: schema.IdField
|
||||
handle: schema.HandleField
|
||||
|
||||
+6
@@ -356,6 +356,9 @@ func (r *PageLayout) GetValue(name string, pos uint) (any, error) {
|
||||
case "weight", "Weight":
|
||||
return r.Weight, nil
|
||||
|
||||
default:
|
||||
return r.getValue(name, pos)
|
||||
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
@@ -383,6 +386,9 @@ func (r *PageLayout) SetValue(name string, pos uint, value any) (err error) {
|
||||
case "weight", "Weight":
|
||||
return cast2.Int(value, &r.Weight)
|
||||
|
||||
default:
|
||||
return r.setValue(name, pos, value)
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/cortezaproject/corteza/server/pkg/cast2"
|
||||
"github.com/cortezaproject/corteza/server/pkg/locale"
|
||||
"github.com/cortezaproject/corteza/server/pkg/sql"
|
||||
|
||||
@@ -41,8 +42,8 @@ type (
|
||||
PageLayoutBlocks []PageLayoutBlock
|
||||
|
||||
PageLayoutBlock struct {
|
||||
BlockID uint64 `json:"blockID,string,omitempty"`
|
||||
XYWH [4]int `json:"xywh"` // x,y,w,h
|
||||
BlockID uint64 `json:"blockID,string,omitempty" yaml:"blockID"`
|
||||
XYWH [4]int `json:"xywh" yaml:"xywh"`
|
||||
Meta map[string]any `json:"meta,omitempty"`
|
||||
}
|
||||
|
||||
@@ -209,6 +210,22 @@ func (set PageLayoutSet) FindByHandle(handle string) *PageLayout {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *PageLayout) getValue(name string, pos uint) (any, error) {
|
||||
switch name {
|
||||
case "selfD", "SelfD":
|
||||
return r.PageID, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
func (r *PageLayout) setValue(name string, pos uint, value any) (err error) {
|
||||
switch name {
|
||||
case "selfID", "SelfID":
|
||||
return cast2.Uint64(value, &r.PageID)
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (bb *PageLayoutConfig) Scan(src any) error { return sql.ParseJSON(src, &bb) }
|
||||
func (bb PageLayoutConfig) Value() (driver.Value, error) { return json.Marshal(bb) }
|
||||
|
||||
|
||||
Generated
+66
-44
@@ -480,10 +480,12 @@ func (d *auxYamlDoc) unmarshalApplicationNode(dctx documentContext, n *yaml.Node
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["ApplicationID"] = envoyx.Ref{
|
||||
ResourceType: types.ApplicationResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["ApplicationID"]; !ok {
|
||||
a.References["ApplicationID"] = envoyx.Ref{
|
||||
ResourceType: types.ApplicationResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
@@ -824,10 +826,12 @@ func (d *auxYamlDoc) unmarshalApigwRouteNode(dctx documentContext, n *yaml.Node,
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["ApigwRouteID"] = envoyx.Ref{
|
||||
ResourceType: types.ApigwRouteResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["ApigwRouteID"]; !ok {
|
||||
a.References["ApigwRouteID"] = envoyx.Ref{
|
||||
ResourceType: types.ApigwRouteResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
@@ -1108,10 +1112,12 @@ func (d *auxYamlDoc) unmarshalApigwFilterNode(dctx documentContext, n *yaml.Node
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["ApigwFilterID"] = envoyx.Ref{
|
||||
ResourceType: types.ApigwFilterResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["ApigwFilterID"]; !ok {
|
||||
a.References["ApigwFilterID"] = envoyx.Ref{
|
||||
ResourceType: types.ApigwFilterResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
@@ -1425,10 +1431,12 @@ func (d *auxYamlDoc) unmarshalAuthClientNode(dctx documentContext, n *yaml.Node,
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["AuthClientID"] = envoyx.Ref{
|
||||
ResourceType: types.AuthClientResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["AuthClientID"]; !ok {
|
||||
a.References["AuthClientID"] = envoyx.Ref{
|
||||
ResourceType: types.AuthClientResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
@@ -1736,10 +1744,12 @@ func (d *auxYamlDoc) unmarshalQueueNode(dctx documentContext, n *yaml.Node, meta
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["QueueID"] = envoyx.Ref{
|
||||
ResourceType: types.QueueResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["QueueID"]; !ok {
|
||||
a.References["QueueID"] = envoyx.Ref{
|
||||
ResourceType: types.QueueResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
@@ -2066,10 +2076,12 @@ func (d *auxYamlDoc) unmarshalReportNode(dctx documentContext, n *yaml.Node, met
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["ReportID"] = envoyx.Ref{
|
||||
ResourceType: types.ReportResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["ReportID"]; !ok {
|
||||
a.References["ReportID"] = envoyx.Ref{
|
||||
ResourceType: types.ReportResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
@@ -2320,10 +2332,12 @@ func (d *auxYamlDoc) unmarshalRoleNode(dctx documentContext, n *yaml.Node, meta
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["RoleID"] = envoyx.Ref{
|
||||
ResourceType: types.RoleResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["RoleID"]; !ok {
|
||||
a.References["RoleID"] = envoyx.Ref{
|
||||
ResourceType: types.RoleResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
@@ -2593,10 +2607,12 @@ func (d *auxYamlDoc) unmarshalTemplateNode(dctx documentContext, n *yaml.Node, m
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["TemplateID"] = envoyx.Ref{
|
||||
ResourceType: types.TemplateResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["TemplateID"]; !ok {
|
||||
a.References["TemplateID"] = envoyx.Ref{
|
||||
ResourceType: types.TemplateResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
@@ -2866,10 +2882,12 @@ func (d *auxYamlDoc) unmarshalUserNode(dctx documentContext, n *yaml.Node, meta
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["UserID"] = envoyx.Ref{
|
||||
ResourceType: types.UserResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["UserID"]; !ok {
|
||||
a.References["UserID"] = envoyx.Ref{
|
||||
ResourceType: types.UserResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
@@ -3177,10 +3195,12 @@ func (d *auxYamlDoc) unmarshalDalConnectionNode(dctx documentContext, n *yaml.No
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["DalConnectionID"] = envoyx.Ref{
|
||||
ResourceType: types.DalConnectionResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["DalConnectionID"]; !ok {
|
||||
a.References["DalConnectionID"] = envoyx.Ref{
|
||||
ResourceType: types.DalConnectionResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
@@ -3471,10 +3491,12 @@ func (d *auxYamlDoc) unmarshalDalSensitivityLevelNode(dctx documentContext, n *y
|
||||
a.References = make(map[string]envoyx.Ref)
|
||||
}
|
||||
|
||||
a.References["DalSensitivityLevelID"] = envoyx.Ref{
|
||||
ResourceType: types.DalSensitivityLevelResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
if _, ok := a.References["DalSensitivityLevelID"]; !ok {
|
||||
a.References["DalSensitivityLevelID"] = envoyx.Ref{
|
||||
ResourceType: types.DalSensitivityLevelResourceType,
|
||||
Identifiers: ii,
|
||||
Scope: scope,
|
||||
}
|
||||
}
|
||||
|
||||
for f, ref := range a.References {
|
||||
|
||||
Reference in New Issue
Block a user