Fixup envoy codegen
This commit is contained in:
parent
16f789bdb4
commit
3ba9c61986
1
automation/service/locale.gen.go
generated
1
automation/service/locale.gen.go
generated
@ -11,7 +11,6 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/automation/types"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/pkg/actionlog"
|
||||
|
||||
1
compose/service/locale.gen.go
generated
1
compose/service/locale.gen.go
generated
@ -14,7 +14,6 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/compose/types"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/pkg/actionlog"
|
||||
|
||||
@ -14,7 +14,7 @@ import (
|
||||
{{ $Component := .Component }}
|
||||
{{ $Resource := .Resource }}
|
||||
{{ $GoType := printf "types.%s" .Resource }}
|
||||
func (r *{{export $Component}}{{$Resource}}) EncodeTranslations() ([]*ResourceTranslation, error) {
|
||||
func (r *{{if not (eq $Component "system")}}{{export $Component}}{{ end }}{{$Resource}}) EncodeTranslations() ([]*ResourceTranslation, error) {
|
||||
out := make([]*ResourceTranslation, 0, 10)
|
||||
|
||||
rr := r.Res.EncodeTranslations()
|
||||
|
||||
109
pkg/envoy/resource/report.go
Normal file
109
pkg/envoy/resource/report.go
Normal file
@ -0,0 +1,109 @@
|
||||
package resource
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/system/types"
|
||||
)
|
||||
|
||||
type (
|
||||
Report struct {
|
||||
*base
|
||||
Res *types.Report
|
||||
|
||||
Sources []*ReportSource
|
||||
Projections []*ReportProjection
|
||||
}
|
||||
|
||||
ReportSource struct {
|
||||
*base
|
||||
Res *types.ReportDataSource
|
||||
}
|
||||
|
||||
ReportProjection struct {
|
||||
*base
|
||||
Res *types.ReportProjection
|
||||
}
|
||||
)
|
||||
|
||||
func NewReport(res *types.Report) *Report {
|
||||
r := &Report{
|
||||
base: &base{},
|
||||
}
|
||||
r.SetResourceType(types.ReportResourceType)
|
||||
r.Res = res
|
||||
|
||||
r.AddIdentifier(identifiers(res.Handle, res.ID)...)
|
||||
|
||||
// Initial stamps
|
||||
r.SetTimestamps(MakeTimestampsCUDA(&res.CreatedAt, res.UpdatedAt, res.DeletedAt, nil))
|
||||
r.SetUserstamps(MakeUserstampsCUDO(res.CreatedBy, res.UpdatedBy, res.DeletedBy, res.OwnedBy))
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *Report) AddReportSource(res *types.ReportDataSource) *ReportSource {
|
||||
s := &ReportSource{
|
||||
base: &base{},
|
||||
}
|
||||
|
||||
s.Res = res
|
||||
r.Sources = append(r.Sources, s)
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
func (r *Report) ResourceTranslationParts() (resource string, ref *Ref, path []*Ref) {
|
||||
ref = r.Ref()
|
||||
path = nil
|
||||
resource = fmt.Sprintf(types.ReportResourceTranslationTpl(), types.ReportResourceTranslationType, firstOkString(strconv.FormatUint(r.Res.ID, 10), r.Res.Handle))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (r *Report) AddReportProjection(res *types.ReportProjection) *ReportProjection {
|
||||
p := &ReportProjection{
|
||||
base: &base{},
|
||||
}
|
||||
|
||||
p.Res = res
|
||||
r.Projections = append(r.Projections, p)
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (r *Report) SysID() uint64 {
|
||||
return r.Res.ID
|
||||
}
|
||||
|
||||
func (r *Report) encodeTranslations() ([]*ResourceTranslation, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// FindReport looks for the workflow in the resource set
|
||||
func FindReport(rr InterfaceSet, ii Identifiers) (ns *types.Report) {
|
||||
var wfRes *Report
|
||||
|
||||
rr.Walk(func(r Interface) error {
|
||||
wr, ok := r.(*Report)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
if wr.Identifiers().HasAny(ii) {
|
||||
wfRes = wr
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
// Found it
|
||||
if wfRes != nil {
|
||||
return wfRes.Res
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ReportErrUnresolved(ii Identifiers) error {
|
||||
return fmt.Errorf("report unresolved %v", ii.StringSlice())
|
||||
}
|
||||
14
pkg/envoy/resource/resource_translation.gen.go
generated
14
pkg/envoy/resource/resource_translation.gen.go
generated
@ -13,6 +13,7 @@ package resource
|
||||
// - compose.module.yaml
|
||||
// - compose.namespace.yaml
|
||||
// - compose.page.yaml
|
||||
// - system.report.yaml
|
||||
|
||||
import (
|
||||
systemTypes "github.com/cortezaproject/corteza-server/system/types"
|
||||
@ -87,3 +88,16 @@ func (r *ComposePage) EncodeTranslations() ([]*ResourceTranslation, error) {
|
||||
return append(out, tmp...), err
|
||||
|
||||
}
|
||||
|
||||
func (r *Report) 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...))
|
||||
|
||||
tmp, err := r.encodeTranslations()
|
||||
return append(out, tmp...), err
|
||||
|
||||
}
|
||||
|
||||
12
pkg/envoy/resource/resource_translation_parse.gen.go
generated
12
pkg/envoy/resource/resource_translation_parse.gen.go
generated
@ -13,11 +13,13 @@ package resource
|
||||
// - compose.module.yaml
|
||||
// - compose.namespace.yaml
|
||||
// - compose.page.yaml
|
||||
// - system.report.yaml
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
automationTypes "github.com/cortezaproject/corteza-server/automation/types"
|
||||
composeTypes "github.com/cortezaproject/corteza-server/compose/types"
|
||||
systemTypes "github.com/cortezaproject/corteza-server/system/types"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -131,6 +133,16 @@ func ParseResourceTranslation(res string) (string, *Ref, []*Ref, error) {
|
||||
)
|
||||
return composeTypes.PageResourceTranslationType, ref, pp, err
|
||||
|
||||
case systemTypes.ReportResourceTranslationType:
|
||||
if len(path) != 1 {
|
||||
return "", nil, nil, fmt.Errorf("expecting 1 reference components in path, got %d", len(path))
|
||||
}
|
||||
ref, pp, err := SystemReportResourceTranslationReferences(
|
||||
// report
|
||||
path[0],
|
||||
)
|
||||
return systemTypes.ReportResourceTranslationType, ref, pp, err
|
||||
|
||||
}
|
||||
|
||||
// return unhandled resource as-is
|
||||
|
||||
25
pkg/envoy/resource/resource_translation_references_system.gen.go
generated
Normal file
25
pkg/envoy/resource/resource_translation_references_system.gen.go
generated
Normal file
@ -0,0 +1,25 @@
|
||||
package resource
|
||||
|
||||
// This file is auto-generated.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
//
|
||||
|
||||
// Definitions file that controls how this file is generated:
|
||||
// - system.report.yaml
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/system/types"
|
||||
)
|
||||
|
||||
// SystemReportResourceTranslationReferences generates Locale references
|
||||
//
|
||||
// Resources with "envoy: false" are skipped
|
||||
//
|
||||
// This function is auto-generated
|
||||
func SystemReportResourceTranslationReferences(report string) (res *Ref, pp []*Ref, err error) {
|
||||
res = &Ref{ResourceType: types.ReportResourceType, Identifiers: MakeIdentifiers(report)}
|
||||
|
||||
return
|
||||
}
|
||||
1
system/service/locale.gen.go
generated
1
system/service/locale.gen.go
generated
@ -11,7 +11,6 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/system/types"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/pkg/actionlog"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user