3
0

Migrate codegen for envoy to CUE

This commit is contained in:
Denis Arh
2021-12-29 14:01:16 +01:00
parent 3568d0841e
commit a437913f85
12 changed files with 425 additions and 200 deletions
+1
View File
@@ -13,4 +13,5 @@ platform: [...schema.#codegen] &
rbacAccessControl+
rbacTypes+
localeTypes+
envoyRBAC+
[] // placeholder
@@ -0,0 +1,32 @@
package {{ .package }}
{{ template "gocode/header-gentext.tpl" }}
import (
{{- range .imports }}
{{ . }}
{{- end }}
)
{{- range .resources }}
// {{ .rbacRefFunc }} generates RBAC references
//
// Resources with "envoy: false" are skipped
//
// This function is auto-generated
func {{ .rbacRefFunc }}({{- range .references }}{{ .param }} string, {{- end }}) (res *Ref, pp []*Ref, err error) {
{{- range .references }}
{{- if eq .refField "ID" }}
if {{ .param }} != "*" {
res = &Ref{ResourceType: types.{{ .expIdent }}ResourceType, Identifiers: MakeIdentifiers({{ .param }})}
}
{{- else }}
if {{ .param }} != "*" {
pp = append(pp, &Ref{ResourceType: types.{{ .expIdent }}ResourceType, Identifiers: MakeIdentifiers({{ .param }})})
}
{{- end }}
{{- end }}
return
}
{{- end }}
@@ -0,0 +1,69 @@
package {{ .package }}
{{ template "gocode/header-gentext.tpl" }}
import (
"fmt"
"strings"
{{- range .imports }}
{{ . }}
{{- end }}
)
// Parse generates resource setting logic for each resource
//
// Resources with "envoy: false" are skipped
//
// This function is auto-generated
func ParseRule(res string) (string, *Ref, []*Ref, error) {
if res == "" {
return "", nil, nil, fmt.Errorf("empty resource")
}
sp := "/"
res = strings.TrimSpace(res)
res = strings.TrimRight(res, sp)
rr := strings.Split(res, sp)
// only service defined (corteza::system, corteza::compose, ...)
if len(rr) == 1 {
return res, nil, nil, nil
}
// full thing
resourceType, path := rr[0], rr[1:]
for p := 1; p < len(path); p++ {
if path[p] != "*" && path[p-1] == "*" {
return "", nil, nil, fmt.Errorf("invalid path wildcard combination for '%s'", res)
}
}
// make the resource provide the slice of parent resources we should nest under
switch resourceType {
{{- range .resources }}
case {{ .typeConst }}:
if len(path) != {{ len .references }} {
return "", nil, nil, fmt.Errorf("expecting {{ len .references }} reference components in path, got %d", len(path))
}
{{- if gt (len .references) 0 }}
ref, pp, err := {{ .rbacRefFunc }}(
{{- range $i, $r := .references }}
path[{{ $i }}],
{{- end }}
)
return resourceType, ref, pp, err
{{ else }}
// Component resource, no path
return resourceType, nil, nil, nil
{{- end }}
{{- end}}
}
// return unhandled resource as-is
return resourceType, nil, nil, nil
}
@@ -0,0 +1,31 @@
package {{ .Package }}
{{ template "header-gentext.tpl" }}
{{ template "header-definitions.tpl" . }}
import (
systemTypes "github.com/cortezaproject/corteza-server/system/types"
{{- range .Imports }}
{{ . }}
{{- end }}
)
{{- range .Def }}
{{ $Component := .Component }}
{{ $Resource := .Resource }}
{{ $GoType := printf "types.%s" .Resource }}
func (r *{{if not (eq $Component "system")}}{{export $Component}}{{ end }}{{$Resource}}) EncodeTranslations() ([]*ResourceTranslation, error) {
out := make([]*ResourceTranslation, 0, 10)
rr := r.Res.EncodeTranslations()
rr.SetLanguage(defaultLanguage)
res, ref, pp := r.ResourceTranslationParts()
out = append(out, NewResourceTranslation(systemTypes.FromLocale(rr), res, ref, pp...))
{{ if .Locale.Extended }}
tmp, err := r.encodeTranslations()
return append(out, tmp...), err
{{ else }}
return out, nil
{{- end }}
}
{{- end }}
@@ -0,0 +1,73 @@
package {{ .Package }}
{{ template "header-gentext.tpl" }}
{{ template "header-definitions.tpl" . }}
import (
"fmt"
"strings"
{{- range .Imports }}
{{ . }}
{{- end }}
)
// Parse generates resource setting logic for each resource
//
// Resources with "envoy: false" are skipped
//
// This function is auto-generated
func ParseResourceTranslation(res string) (string, *Ref, []*Ref, error) {
if res == "" {
return "", nil, nil, fmt.Errorf("empty resource")
}
sp := "/"
if strings.Index(res, "corteza::") == 0 {
res = res[9:]
}
res = strings.TrimSpace(res)
res = strings.TrimRight(res, sp)
rr := strings.Split(res, sp)
// only service defined (corteza::system, corteza::compose, ...)
if len(rr) == 1 {
return "", nil, nil, fmt.Errorf("only service defined: %s", res)
}
// full thing
resourceType, path := rr[0], rr[1:]
for p := 1; p < len(path); p++ {
if path[p] == "*" {
return "", nil, nil, fmt.Errorf("path wildcard not allowed for locale resources: '%s'", res)
}
}
// make the resource provide the slice of parent resources we should nest under
switch resourceType {
{{- range .Def }}
case {{ unexport .Component "types" }}.{{ export .Resource }}ResourceTranslationType:
if len(path) != {{ len .Locale.Resource.References }} {
return "", nil, nil, fmt.Errorf("expecting {{ len .Locale.Resource.References }} reference components in path, got %d", len(path))
}
{{- if gt (len .Locale.Resource.References) 0 }}
ref, pp, err := {{ export .Component .Resource }}ResourceTranslationReferences(
{{- range $i, $r := .Locale.Resource.References }}
// {{ unexport $r.Resource }}
path[{{ $i }}],
{{ end }}
)
return {{ unexport .Component "types" }}.{{ export .Resource }}ResourceTranslationType, ref, pp, err
{{ else }}
// Component resource, no path
return {{ unexport .Component "types" }}.{{ export .Resource }}ResourceTranslationType, nil, nil, nil
{{- end }}
{{- end}}
}
// return unhandled resource as-is
return resourceType, nil, nil, nil
}
@@ -0,0 +1,33 @@
package {{ .Package }}
{{ template "header-gentext.tpl" }}
{{ template "header-definitions.tpl" . }}
import (
{{- range .Imports }}
{{ . }}
{{- end }}
)
{{- range .Def }}
{{- if .Locale }}
{{- if gt (len .Locale.Resource.References) 0 }}
// {{ export .Component .Resource }}ResourceTranslationReferences generates Locale references
//
// Resources with "envoy: false" are skipped
//
// This function is auto-generated
func {{ export .Component .Resource }}ResourceTranslationReferences({{- range .Locale.Resource.References }}{{ unexport .Resource }} string, {{- end }}) (res *Ref, pp []*Ref, err error) {
{{- range .Locale.Resource.References }}
{{- if eq .Field "ID" }}
res = &Ref{ResourceType: types.{{ export .Resource }}ResourceType, Identifiers: MakeIdentifiers({{ unexport .Resource }})}
{{- else }}
pp = append(pp, &Ref{ResourceType: types.{{ export .Resource }}ResourceType, Identifiers: MakeIdentifiers({{ unexport .Resource }})})
{{- end }}
{{- end }}
return
}
{{- end }}
{{- end }}
{{- end }}
+72
View File
@@ -0,0 +1,72 @@
package codegen
import (
"github.com/cortezaproject/corteza-server/app"
"github.com/cortezaproject/corteza-server/codegen/schema"
// "strings"
)
envoyRBAC:
[...schema.#codegen] &
[
for cmp in app.corteza.components {
template: "gocode/envoy/rbac-references.go.tpl"
output: "pkg/envoy/resource/rbac_references_\(cmp.ident).gen.go"
payload: {
package: "resource"
imports: [
"\"github.com/cortezaproject/corteza-server/\(cmp.ident)/types\"",
]
// cmpIdent: cmp.ident
// Operation/resource validators, grouped by resource
resources: [
for res in cmp.resources {
rbacRefFunc: "\(cmp.expIdent)\(res.expIdent)RbacReferences"
references: [
for p in res.parents {p},
{param: res.ident, refField: "ID", expIdent: res.expIdent},
]
},
]
}
},
]+
[
{
template: "gocode/envoy/rbac-rules-parse.go.tpl"
output: "pkg/envoy/resource/rbac_rules_parse.gen.go"
payload: {
package: "resource"
imports: [
for cmp in app.corteza.components {
"\(cmp.ident)Types \"github.com/cortezaproject/corteza-server/\(cmp.ident)/types\""
},
]
// cmpIdent: cmp.ident
// Operation/resource validators, grouped by resource
resources: [
for cmp in app.corteza.components for res in cmp.resources {
importAlias: "\(cmp.ident)Types"
expIdent: res.expIdent
typeConst: "\(importAlias).\(expIdent)ResourceType"
rbacRefFunc: "\(cmp.expIdent)\(res.expIdent)RbacReferences"
references: [
for p in res.parents {p},
{param: res.ident, refField: "ID", expIdent: res.expIdent},
]
},
for cmp in app.corteza.components {
importAlias: "\(cmp.ident)Types"
expIdent: cmp.expIdent
typeConst: "\(importAlias).ComponentResourceType"
references: []
},
]
}
},
]
+1 -1
View File
@@ -32,7 +32,7 @@ localeService:
keys: [ for key in res.locale.keys if key.handlerFunc == _|_ {
struct: key.struct
extended: extended
"extended": extended
customHandler: key.customHandler
if key.serviceFunc != _|_ {serviceFunc: key.serviceFunc}
}]
+1 -2
View File
@@ -9,12 +9,11 @@ package service
import (
"context"
"fmt"
"strings"
"github.com/cortezaproject/corteza-server/compose/types"
"github.com/cortezaproject/corteza-server/pkg/actionlog"
"github.com/cortezaproject/corteza-server/pkg/rbac"
"github.com/spf13/cast"
"strings"
)
type (
+33 -42
View File
@@ -6,15 +6,6 @@ package resource
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// - compose.chart.yaml
// - compose.module-field.yaml
// - compose.module.yaml
// - compose.namespace.yaml
// - compose.page.yaml
// - compose.record.yaml
// - compose.yaml
import (
"github.com/cortezaproject/corteza-server/compose/types"
)
@@ -24,9 +15,9 @@ import (
// Resources with "envoy: false" are skipped
//
// This function is auto-generated
func ComposeChartRbacReferences(namespace string, chart string) (res *Ref, pp []*Ref, err error) {
if namespace != "*" {
pp = append(pp, &Ref{ResourceType: types.NamespaceResourceType, Identifiers: MakeIdentifiers(namespace)})
func ComposeChartRbacReferences(namespaceID string, chart string) (res *Ref, pp []*Ref, err error) {
if namespaceID != "*" {
pp = append(pp, &Ref{ResourceType: types.NamespaceResourceType, Identifiers: MakeIdentifiers(namespaceID)})
}
if chart != "*" {
res = &Ref{ResourceType: types.ChartResourceType, Identifiers: MakeIdentifiers(chart)}
@@ -35,33 +26,14 @@ func ComposeChartRbacReferences(namespace string, chart string) (res *Ref, pp []
return
}
// ComposeModuleFieldRbacReferences generates RBAC references
//
// Resources with "envoy: false" are skipped
//
// This function is auto-generated
func ComposeModuleFieldRbacReferences(namespace string, module string, moduleField string) (res *Ref, pp []*Ref, err error) {
if namespace != "*" {
pp = append(pp, &Ref{ResourceType: types.NamespaceResourceType, Identifiers: MakeIdentifiers(namespace)})
}
if module != "*" {
pp = append(pp, &Ref{ResourceType: types.ModuleResourceType, Identifiers: MakeIdentifiers(module)})
}
if moduleField != "*" {
res = &Ref{ResourceType: types.ModuleFieldResourceType, Identifiers: MakeIdentifiers(moduleField)}
}
return
}
// ComposeModuleRbacReferences generates RBAC references
//
// Resources with "envoy: false" are skipped
//
// This function is auto-generated
func ComposeModuleRbacReferences(namespace string, module string) (res *Ref, pp []*Ref, err error) {
if namespace != "*" {
pp = append(pp, &Ref{ResourceType: types.NamespaceResourceType, Identifiers: MakeIdentifiers(namespace)})
func ComposeModuleRbacReferences(namespaceID string, module string) (res *Ref, pp []*Ref, err error) {
if namespaceID != "*" {
pp = append(pp, &Ref{ResourceType: types.NamespaceResourceType, Identifiers: MakeIdentifiers(namespaceID)})
}
if module != "*" {
res = &Ref{ResourceType: types.ModuleResourceType, Identifiers: MakeIdentifiers(module)}
@@ -70,6 +42,25 @@ func ComposeModuleRbacReferences(namespace string, module string) (res *Ref, pp
return
}
// ComposeModuleFieldRbacReferences generates RBAC references
//
// Resources with "envoy: false" are skipped
//
// This function is auto-generated
func ComposeModuleFieldRbacReferences(namespaceID string, moduleID string, moduleField string) (res *Ref, pp []*Ref, err error) {
if namespaceID != "*" {
pp = append(pp, &Ref{ResourceType: types.NamespaceResourceType, Identifiers: MakeIdentifiers(namespaceID)})
}
if moduleID != "*" {
pp = append(pp, &Ref{ResourceType: types.ModuleResourceType, Identifiers: MakeIdentifiers(moduleID)})
}
if moduleField != "*" {
res = &Ref{ResourceType: types.ModuleFieldResourceType, Identifiers: MakeIdentifiers(moduleField)}
}
return
}
// ComposeNamespaceRbacReferences generates RBAC references
//
// Resources with "envoy: false" are skipped
@@ -88,9 +79,9 @@ func ComposeNamespaceRbacReferences(namespace string) (res *Ref, pp []*Ref, err
// Resources with "envoy: false" are skipped
//
// This function is auto-generated
func ComposePageRbacReferences(namespace string, page string) (res *Ref, pp []*Ref, err error) {
if namespace != "*" {
pp = append(pp, &Ref{ResourceType: types.NamespaceResourceType, Identifiers: MakeIdentifiers(namespace)})
func ComposePageRbacReferences(namespaceID string, page string) (res *Ref, pp []*Ref, err error) {
if namespaceID != "*" {
pp = append(pp, &Ref{ResourceType: types.NamespaceResourceType, Identifiers: MakeIdentifiers(namespaceID)})
}
if page != "*" {
res = &Ref{ResourceType: types.PageResourceType, Identifiers: MakeIdentifiers(page)}
@@ -104,12 +95,12 @@ func ComposePageRbacReferences(namespace string, page string) (res *Ref, pp []*R
// Resources with "envoy: false" are skipped
//
// This function is auto-generated
func ComposeRecordRbacReferences(namespace string, module string, record string) (res *Ref, pp []*Ref, err error) {
if namespace != "*" {
pp = append(pp, &Ref{ResourceType: types.NamespaceResourceType, Identifiers: MakeIdentifiers(namespace)})
func ComposeRecordRbacReferences(namespaceID string, moduleID string, record string) (res *Ref, pp []*Ref, err error) {
if namespaceID != "*" {
pp = append(pp, &Ref{ResourceType: types.NamespaceResourceType, Identifiers: MakeIdentifiers(namespaceID)})
}
if module != "*" {
pp = append(pp, &Ref{ResourceType: types.ModuleResourceType, Identifiers: MakeIdentifiers(module)})
if moduleID != "*" {
pp = append(pp, &Ref{ResourceType: types.ModuleResourceType, Identifiers: MakeIdentifiers(moduleID)})
}
if record != "*" {
res = &Ref{ResourceType: types.RecordResourceType, Identifiers: MakeIdentifiers(record)}
-11
View File
@@ -6,17 +6,6 @@ package resource
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// - system.apigw-route.yaml
// - system.application.yaml
// - system.auth-client.yaml
// - system.queue.yaml
// - system.report.yaml
// - system.role.yaml
// - system.template.yaml
// - system.user.yaml
// - system.yaml
import (
"github.com/cortezaproject/corteza-server/system/types"
)
+79 -144
View File
@@ -6,32 +6,12 @@ package resource
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// - automation.workflow.yaml
// - automation.yaml
// - compose.chart.yaml
// - compose.module-field.yaml
// - compose.module.yaml
// - compose.namespace.yaml
// - compose.page.yaml
// - compose.record.yaml
// - compose.yaml
// - system.apigw-route.yaml
// - system.application.yaml
// - system.auth-client.yaml
// - system.queue.yaml
// - system.report.yaml
// - system.role.yaml
// - system.template.yaml
// - system.user.yaml
// - system.yaml
import (
"fmt"
automationTypes "github.com/cortezaproject/corteza-server/automation/types"
"strings"
composeTypes "github.com/cortezaproject/corteza-server/compose/types"
systemTypes "github.com/cortezaproject/corteza-server/system/types"
"strings"
)
// Parse generates resource setting logic for each resource
@@ -66,190 +46,138 @@ func ParseRule(res string) (string, *Ref, []*Ref, error) {
// make the resource provide the slice of parent resources we should nest under
switch resourceType {
case automationTypes.WorkflowResourceType:
if len(path) != 1 {
return "", nil, nil, fmt.Errorf("expecting 1 reference components in path, got %d", len(path))
}
ref, pp, err := AutomationWorkflowRbacReferences(
// workflow
path[0],
)
return automationTypes.WorkflowResourceType, ref, pp, err
case automationTypes.ComponentResourceType:
if len(path) != 0 {
return "", nil, nil, fmt.Errorf("expecting 0 reference components in path, got %d", len(path))
}
// Component resource, no path
return automationTypes.ComponentResourceType, nil, nil, nil
case composeTypes.ChartResourceType:
if len(path) != 2 {
return "", nil, nil, fmt.Errorf("expecting 2 reference components in path, got %d", len(path))
}
ref, pp, err := ComposeChartRbacReferences(
// namespace
path[0],
// chart
path[1],
)
return composeTypes.ChartResourceType, ref, pp, err
case composeTypes.ModuleFieldResourceType:
if len(path) != 3 {
return "", nil, nil, fmt.Errorf("expecting 3 reference components in path, got %d", len(path))
}
ref, pp, err := ComposeModuleFieldRbacReferences(
// namespace
path[0],
// module
path[1],
// moduleField
path[2],
)
return composeTypes.ModuleFieldResourceType, ref, pp, err
case composeTypes.ModuleResourceType:
if len(path) != 2 {
return "", nil, nil, fmt.Errorf("expecting 2 reference components in path, got %d", len(path))
}
ref, pp, err := ComposeModuleRbacReferences(
// namespace
path[0],
// module
path[1],
)
return composeTypes.ModuleResourceType, ref, pp, err
case composeTypes.NamespaceResourceType:
if len(path) != 1 {
return "", nil, nil, fmt.Errorf("expecting 1 reference components in path, got %d", len(path))
}
ref, pp, err := ComposeNamespaceRbacReferences(
// namespace
path[0],
)
return composeTypes.NamespaceResourceType, ref, pp, err
case composeTypes.PageResourceType:
if len(path) != 2 {
return "", nil, nil, fmt.Errorf("expecting 2 reference components in path, got %d", len(path))
}
ref, pp, err := ComposePageRbacReferences(
// namespace
path[0],
// page
path[1],
)
return composeTypes.PageResourceType, ref, pp, err
case composeTypes.RecordResourceType:
if len(path) != 3 {
return "", nil, nil, fmt.Errorf("expecting 3 reference components in path, got %d", len(path))
}
ref, pp, err := ComposeRecordRbacReferences(
// namespace
path[0],
// module
path[1],
// record
path[2],
)
return composeTypes.RecordResourceType, ref, pp, err
case composeTypes.ComponentResourceType:
if len(path) != 0 {
return "", nil, nil, fmt.Errorf("expecting 0 reference components in path, got %d", len(path))
}
// Component resource, no path
return composeTypes.ComponentResourceType, nil, nil, nil
case systemTypes.ApigwRouteResourceType:
if len(path) != 1 {
return "", nil, nil, fmt.Errorf("expecting 1 reference components in path, got %d", len(path))
}
ref, pp, err := SystemApigwRouteRbacReferences(
// apigwRoute
path[0],
)
return systemTypes.ApigwRouteResourceType, ref, pp, err
return resourceType, ref, pp, err
case systemTypes.ApplicationResourceType:
if len(path) != 1 {
return "", nil, nil, fmt.Errorf("expecting 1 reference components in path, got %d", len(path))
}
ref, pp, err := SystemApplicationRbacReferences(
// application
path[0],
)
return systemTypes.ApplicationResourceType, ref, pp, err
return resourceType, ref, pp, err
case systemTypes.AuthClientResourceType:
if len(path) != 1 {
return "", nil, nil, fmt.Errorf("expecting 1 reference components in path, got %d", len(path))
}
ref, pp, err := SystemAuthClientRbacReferences(
// authClient
path[0],
)
return systemTypes.AuthClientResourceType, ref, pp, err
return resourceType, ref, pp, err
case systemTypes.QueueResourceType:
if len(path) != 1 {
return "", nil, nil, fmt.Errorf("expecting 1 reference components in path, got %d", len(path))
}
ref, pp, err := SystemQueueRbacReferences(
// queue
path[0],
)
return systemTypes.QueueResourceType, ref, pp, err
return resourceType, ref, pp, err
case systemTypes.ReportResourceType:
if len(path) != 1 {
return "", nil, nil, fmt.Errorf("expecting 1 reference components in path, got %d", len(path))
}
ref, pp, err := SystemReportRbacReferences(
// report
path[0],
)
return systemTypes.ReportResourceType, ref, pp, err
return resourceType, ref, pp, err
case systemTypes.RoleResourceType:
if len(path) != 1 {
return "", nil, nil, fmt.Errorf("expecting 1 reference components in path, got %d", len(path))
}
ref, pp, err := SystemRoleRbacReferences(
// role
path[0],
)
return systemTypes.RoleResourceType, ref, pp, err
return resourceType, ref, pp, err
case systemTypes.TemplateResourceType:
if len(path) != 1 {
return "", nil, nil, fmt.Errorf("expecting 1 reference components in path, got %d", len(path))
}
ref, pp, err := SystemTemplateRbacReferences(
// template
path[0],
)
return systemTypes.TemplateResourceType, ref, pp, err
return resourceType, ref, pp, err
case systemTypes.UserResourceType:
if len(path) != 1 {
return "", nil, nil, fmt.Errorf("expecting 1 reference components in path, got %d", len(path))
}
ref, pp, err := SystemUserRbacReferences(
// user
path[0],
)
return systemTypes.UserResourceType, ref, pp, err
return resourceType, ref, pp, err
case composeTypes.ChartResourceType:
if len(path) != 2 {
return "", nil, nil, fmt.Errorf("expecting 2 reference components in path, got %d", len(path))
}
ref, pp, err := ComposeChartRbacReferences(
path[0],
path[1],
)
return resourceType, ref, pp, err
case composeTypes.ModuleResourceType:
if len(path) != 2 {
return "", nil, nil, fmt.Errorf("expecting 2 reference components in path, got %d", len(path))
}
ref, pp, err := ComposeModuleRbacReferences(
path[0],
path[1],
)
return resourceType, ref, pp, err
case composeTypes.ModuleFieldResourceType:
if len(path) != 3 {
return "", nil, nil, fmt.Errorf("expecting 3 reference components in path, got %d", len(path))
}
ref, pp, err := ComposeModuleFieldRbacReferences(
path[0],
path[1],
path[2],
)
return resourceType, ref, pp, err
case composeTypes.NamespaceResourceType:
if len(path) != 1 {
return "", nil, nil, fmt.Errorf("expecting 1 reference components in path, got %d", len(path))
}
ref, pp, err := ComposeNamespaceRbacReferences(
path[0],
)
return resourceType, ref, pp, err
case composeTypes.PageResourceType:
if len(path) != 2 {
return "", nil, nil, fmt.Errorf("expecting 2 reference components in path, got %d", len(path))
}
ref, pp, err := ComposePageRbacReferences(
path[0],
path[1],
)
return resourceType, ref, pp, err
case composeTypes.RecordResourceType:
if len(path) != 3 {
return "", nil, nil, fmt.Errorf("expecting 3 reference components in path, got %d", len(path))
}
ref, pp, err := ComposeRecordRbacReferences(
path[0],
path[1],
path[2],
)
return resourceType, ref, pp, err
case systemTypes.ComponentResourceType:
if len(path) != 0 {
@@ -257,7 +185,14 @@ func ParseRule(res string) (string, *Ref, []*Ref, error) {
}
// Component resource, no path
return systemTypes.ComponentResourceType, nil, nil, nil
return resourceType, nil, nil, nil
case composeTypes.ComponentResourceType:
if len(path) != 0 {
return "", nil, nil, fmt.Errorf("expecting 0 reference components in path, got %d", len(path))
}
// Component resource, no path
return resourceType, nil, nil, nil
}
// return unhandled resource as-is