diff --git a/compose/service/locale.gen.go b/compose/service/locale.gen.go index e4fd7ce62..0b278a32e 100644 --- a/compose/service/locale.gen.go +++ b/compose/service/locale.gen.go @@ -7,7 +7,6 @@ package service // // Definitions file that controls how this file is generated: -// - compose.chart.yaml // - compose.module.yaml // - compose.namespace.yaml // - compose.page.yaml @@ -37,7 +36,6 @@ type ( } ResourceTranslationsManagerService interface { - Chart(ctx context.Context, namespaceID uint64, ID uint64) (locale.ResourceTranslationSet, error) Module(ctx context.Context, namespaceID uint64, ID uint64) (locale.ResourceTranslationSet, error) Namespace(ctx context.Context, ID uint64) (locale.ResourceTranslationSet, error) Page(ctx context.Context, namespaceID uint64, ID uint64) (locale.ResourceTranslationSet, error) @@ -125,32 +123,6 @@ func (svc resourceTranslationsManager) Locale() locale.Resource { return svc.locale } -func (svc resourceTranslationsManager) Chart(ctx context.Context, namespaceID uint64, ID uint64) (locale.ResourceTranslationSet, error) { - var ( - err error - out locale.ResourceTranslationSet - res *types.Chart - k types.LocaleKey - ) - - res, err = svc.loadChart(ctx, svc.store, namespaceID, ID) - if err != nil { - return nil, err - } - - for _, tag := range svc.locale.Tags() { - k = types.LocaleKeyChartName - out = append(out, &locale.ResourceTranslation{ - Resource: res.ResourceTranslation(), - Lang: tag.String(), - Key: k.Path, - Msg: svc.locale.TResourceFor(tag, res.ResourceTranslation(), k.Path), - }) - - } - return out, nil -} - func (svc resourceTranslationsManager) Module(ctx context.Context, namespaceID uint64, ID uint64) (locale.ResourceTranslationSet, error) { var ( err error diff --git a/compose/types/locale.gen.go b/compose/types/locale.gen.go index ee94e8acc..a061d52ff 100644 --- a/compose/types/locale.gen.go +++ b/compose/types/locale.gen.go @@ -7,7 +7,6 @@ package types // // Definitions file that controls how this file is generated: -// - compose.chart.yaml // - compose.module-field.yaml // - compose.module.yaml // - compose.namespace.yaml @@ -30,7 +29,6 @@ type ( // Types and stuff const ( - ChartResourceTranslationType = "compose:chart" ModuleFieldResourceTranslationType = "compose:module-field" ModuleResourceTranslationType = "compose:module" NamespaceResourceTranslationType = "compose:namespace" @@ -38,11 +36,6 @@ const ( ) var ( - LocaleKeyChartName = LocaleKey{ - Name: "name", - Resource: ChartResourceTranslationType, - Path: "name", - } LocaleKeyModuleFieldLabel = LocaleKey{ Name: "label", Resource: ModuleFieldResourceTranslationType, @@ -125,52 +118,6 @@ var ( } ) -// ResourceTranslation returns string representation of Locale resource for Chart by calling ChartResourceTranslation fn -// -// Locale resource is in the compose:chart/... format -// -// This function is auto-generated -func (r Chart) ResourceTranslation() string { - return ChartResourceTranslation(r.NamespaceID, r.ID) -} - -// ChartResourceTranslation returns string representation of Locale resource for Chart -// -// Locale resource is in the compose:chart/... format -// -// This function is auto-generated -func ChartResourceTranslation(namespaceID uint64, id uint64) string { - cpts := []interface{}{ChartResourceTranslationType} - cpts = append(cpts, strconv.FormatUint(namespaceID, 10), strconv.FormatUint(id, 10)) - - return fmt.Sprintf(ChartResourceTranslationTpl(), cpts...) -} - -// @todo template -func ChartResourceTranslationTpl() string { - return "%s/%s/%s" -} - -func (r *Chart) DecodeTranslations(tt locale.ResourceTranslationIndex) { - var aux *locale.ResourceTranslation - if aux = tt.FindByKey(LocaleKeyChartName.Path); aux != nil { - r.Name = aux.Msg - } -} - -func (r *Chart) EncodeTranslations() (out locale.ResourceTranslationSet) { - out = locale.ResourceTranslationSet{} - if r.Name != "" { - out = append(out, &locale.ResourceTranslation{ - Resource: r.ResourceTranslation(), - Key: LocaleKeyChartName.Path, - Msg: r.Name, - }) - } - - return out -} - // ResourceTranslation returns string representation of Locale resource for ModuleField by calling ModuleFieldResourceTranslation fn // // Locale resource is in the compose:module-field/... format diff --git a/def/automation.workflow.yaml b/def/automation.workflow.yaml index 0738d0f49..83cb29328 100644 --- a/def/automation.workflow.yaml +++ b/def/automation.workflow.yaml @@ -15,9 +15,9 @@ rbac: sessions.manage: description: Manage workflow sessions -locale: - resource: - references: [ ID ] - keys: - - { path: name, field: "Meta.Name" } - - { path: description, field: "Meta.Description" } +# locale: +# resource: +# references: [ ID ] +# keys: +# - { path: name, field: "Meta.Name" } +# - { path: description, field: "Meta.Description" } diff --git a/def/compose.chart.yaml b/def/compose.chart.yaml index 200d8cd82..19ec3882f 100644 --- a/def/compose.chart.yaml +++ b/def/compose.chart.yaml @@ -10,8 +10,8 @@ rbac: delete: description: Delete chart -locale: - resource: - references: [ namespace, ID ] - keys: - - name +# locale: +# resource: +# references: [ namespace, ID ] +# keys: +# - name diff --git a/def/system.report.yaml b/def/system.report.yaml index 79824b25d..94d23c1ae 100644 --- a/def/system.report.yaml +++ b/def/system.report.yaml @@ -9,10 +9,10 @@ rbac: run: description: Run report -locale: - extended: true - keys: - - { path: name, field: "Meta.Name" } - - { path: description, field: "Meta.Description" } - - { name: projection title, path: "projection.{{projectionID}}.title", custom: true } - - { name: projection description, path: "projection.{{projectionID}}.description", custom: true } +# locale: +# extended: true +# keys: +# - { path: name, field: "Meta.Name" } +# - { path: description, field: "Meta.Description" } +# - { name: projection title, path: "projection.{{projectionID}}.title", custom: true } +# - { name: projection description, path: "projection.{{projectionID}}.description", custom: true } diff --git a/pkg/envoy/resource/compose_chart.go b/pkg/envoy/resource/compose_chart.go index fd9db1cec..7642793d7 100644 --- a/pkg/envoy/resource/compose_chart.go +++ b/pkg/envoy/resource/compose_chart.go @@ -2,7 +2,6 @@ package resource import ( "fmt" - "strconv" "github.com/cortezaproject/corteza-server/compose/types" ) @@ -48,13 +47,13 @@ func (r *ComposeChart) RBACPath() []*Ref { return []*Ref{r.RefNs} } -func (r *ComposeChart) ResourceTranslationParts() (resource string, ref *Ref, path []*Ref) { - ref = r.Ref() - path = []*Ref{r.RefNs} - resource = fmt.Sprintf(types.ChartResourceTranslationTpl(), types.ChartResourceTranslationType, r.RefNs.Identifiers.First(), firstOkString(strconv.FormatUint(r.Res.ID, 10), r.Res.Handle)) +// func (r *ComposeChart) ResourceTranslationParts() (resource string, ref *Ref, path []*Ref) { +// ref = r.Ref() +// path = []*Ref{r.RefNs} +// resource = fmt.Sprintf(types.ChartResourceTranslationTpl(), types.ChartResourceTranslationType, r.RefNs.Identifiers.First(), firstOkString(strconv.FormatUint(r.Res.ID, 10), r.Res.Handle)) - return -} +// return +// } // FindComposeChart looks for the chart in the resources func FindComposeChart(rr InterfaceSet, ii Identifiers) (ch *types.Chart) { diff --git a/pkg/envoy/resource/resource_translation.gen.go b/pkg/envoy/resource/resource_translation.gen.go index 11bac24bf..b206aae87 100644 --- a/pkg/envoy/resource/resource_translation.gen.go +++ b/pkg/envoy/resource/resource_translation.gen.go @@ -7,40 +7,15 @@ package resource // // Definitions file that controls how this file is generated: -// - automation.workflow.yaml -// - compose.chart.yaml // - compose.module-field.yaml // - compose.module.yaml // - compose.namespace.yaml // - compose.page.yaml -// - system.report.yaml import ( systemTypes "github.com/cortezaproject/corteza-server/system/types" ) -func (r *AutomationWorkflow) 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...)) - - return out, nil -} - -func (r *ComposeChart) 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...)) - - return out, nil -} - func (r *ComposeModuleField) EncodeTranslations() ([]*ResourceTranslation, error) { out := make([]*ResourceTranslation, 0, 10) @@ -88,16 +63,3 @@ 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 - -} diff --git a/pkg/envoy/resource/resource_translation_parse.gen.go b/pkg/envoy/resource/resource_translation_parse.gen.go index eb6c3f232..522786c4a 100644 --- a/pkg/envoy/resource/resource_translation_parse.gen.go +++ b/pkg/envoy/resource/resource_translation_parse.gen.go @@ -7,19 +7,14 @@ package resource // // Definitions file that controls how this file is generated: -// - automation.workflow.yaml -// - compose.chart.yaml // - compose.module-field.yaml // - 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" ) @@ -58,29 +53,6 @@ func ParseResourceTranslation(res string) (string, *Ref, []*Ref, error) { // make the resource provide the slice of parent resources we should nest under switch resourceType { - case automationTypes.WorkflowResourceTranslationType: - if len(path) != 1 { - return "", nil, nil, fmt.Errorf("expecting 1 reference components in path, got %d", len(path)) - } - ref, pp, err := AutomationWorkflowResourceTranslationReferences( - // workflow - path[0], - ) - return automationTypes.WorkflowResourceTranslationType, ref, pp, err - - case composeTypes.ChartResourceTranslationType: - if len(path) != 2 { - return "", nil, nil, fmt.Errorf("expecting 2 reference components in path, got %d", len(path)) - } - ref, pp, err := ComposeChartResourceTranslationReferences( - // namespace - path[0], - - // chart - path[1], - ) - return composeTypes.ChartResourceTranslationType, ref, pp, err - case composeTypes.ModuleFieldResourceTranslationType: if len(path) != 3 { return "", nil, nil, fmt.Errorf("expecting 3 reference components in path, got %d", len(path)) @@ -133,16 +105,6 @@ 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 diff --git a/pkg/envoy/resource/resource_translation_references_compose.gen.go b/pkg/envoy/resource/resource_translation_references_compose.gen.go index 28cf8a820..d5361607e 100644 --- a/pkg/envoy/resource/resource_translation_references_compose.gen.go +++ b/pkg/envoy/resource/resource_translation_references_compose.gen.go @@ -7,7 +7,6 @@ package resource // // Definitions file that controls how this file is generated: -// - compose.chart.yaml // - compose.module-field.yaml // - compose.module.yaml // - compose.namespace.yaml @@ -17,18 +16,6 @@ import ( "github.com/cortezaproject/corteza-server/compose/types" ) -// ComposeChartResourceTranslationReferences generates Locale references -// -// Resources with "envoy: false" are skipped -// -// This function is auto-generated -func ComposeChartResourceTranslationReferences(namespace string, chart string) (res *Ref, pp []*Ref, err error) { - pp = append(pp, &Ref{ResourceType: types.NamespaceResourceType, Identifiers: MakeIdentifiers(namespace)}) - res = &Ref{ResourceType: types.ChartResourceType, Identifiers: MakeIdentifiers(chart)} - - return -} - // ComposeModuleFieldResourceTranslationReferences generates Locale references // // Resources with "envoy: false" are skipped diff --git a/pkg/envoy/store/resource_translation_marshal.go b/pkg/envoy/store/resource_translation_marshal.go index f75244221..69088b449 100644 --- a/pkg/envoy/store/resource_translation_marshal.go +++ b/pkg/envoy/store/resource_translation_marshal.go @@ -4,7 +4,6 @@ import ( "context" "fmt" - automationTypes "github.com/cortezaproject/corteza-server/automation/types" composeTypes "github.com/cortezaproject/corteza-server/compose/types" "github.com/cortezaproject/corteza-server/pkg/envoy/resource" "github.com/cortezaproject/corteza-server/store" @@ -125,14 +124,14 @@ func (n *resourceTranslation) makeResourceTranslation(pl *payload) (string, erro _ = localeRes switch n.refLocaleRes.ResourceType { - case automationTypes.WorkflowResourceType: - p1 := resource.FindAutomationWorkflow(pl.state.ParentResources, n.refLocaleRes.Identifiers) - if p1 == nil { - return "", resource.AutomationWorkflowErrUnresolved(n.refLocaleRes.Identifiers) - } - p1ID = p1.ID + // case automationTypes.WorkflowResourceType: + // p1 := resource.FindAutomationWorkflow(pl.state.ParentResources, n.refLocaleRes.Identifiers) + // if p1 == nil { + // return "", resource.AutomationWorkflowErrUnresolved(n.refLocaleRes.Identifiers) + // } + // p1ID = p1.ID - return automationTypes.WorkflowResourceTranslation(p1ID), nil + // return automationTypes.WorkflowResourceTranslation(p1ID), nil case composeTypes.NamespaceResourceType: p1 := resource.FindComposeNamespace(pl.state.ParentResources, n.refLocaleRes.Identifiers) @@ -173,20 +172,20 @@ func (n *resourceTranslation) makeResourceTranslation(pl *payload) (string, erro return composeTypes.PageResourceTranslation(p0ID, p1ID), nil - case composeTypes.ChartResourceType: - p0 := resource.FindComposeNamespace(pl.state.ParentResources, n.refPathRes[0].Identifiers) - if p0 == nil { - return "", resource.ComposeNamespaceErrUnresolved(n.refPathRes[0].Identifiers) - } - p0ID = p0.ID + // case composeTypes.ChartResourceType: + // p0 := resource.FindComposeNamespace(pl.state.ParentResources, n.refPathRes[0].Identifiers) + // if p0 == nil { + // return "", resource.ComposeNamespaceErrUnresolved(n.refPathRes[0].Identifiers) + // } + // p0ID = p0.ID - p1 := resource.FindComposeChart(pl.state.ParentResources, n.refLocaleRes.Identifiers) - if p1 == nil { - return "", resource.ComposeChartErrUnresolved(n.refLocaleRes.Identifiers) - } - p1ID = p1.ID + // p1 := resource.FindComposeChart(pl.state.ParentResources, n.refLocaleRes.Identifiers) + // if p1 == nil { + // return "", resource.ComposeChartErrUnresolved(n.refLocaleRes.Identifiers) + // } + // p1ID = p1.ID - return composeTypes.ChartResourceTranslation(p0ID, p1ID), nil + // return composeTypes.ChartResourceTranslation(p0ID, p1ID), nil case composeTypes.ModuleFieldResourceType: p0 := resource.FindComposeNamespace(pl.state.ParentResources, n.refPathRes[0].Identifiers) diff --git a/pkg/envoy/yaml/resource_translation_marshal.go b/pkg/envoy/yaml/resource_translation_marshal.go index 4d7b502f8..981c5bc1e 100644 --- a/pkg/envoy/yaml/resource_translation_marshal.go +++ b/pkg/envoy/yaml/resource_translation_marshal.go @@ -7,7 +7,6 @@ import ( "strconv" "strings" - automationTypes "github.com/cortezaproject/corteza-server/automation/types" composeTypes "github.com/cortezaproject/corteza-server/compose/types" "github.com/cortezaproject/corteza-server/pkg/envoy" "github.com/cortezaproject/corteza-server/pkg/envoy/resource" @@ -163,35 +162,35 @@ func (r *resourceTranslation) makeResourceTranslationResource(state *envoy.Resou return fmt.Sprintf(composeTypes.ModuleFieldResourceTranslationTpl(), composeTypes.ModuleFieldResourceTranslationType, p0ID, p1ID, p2ID), nil - case composeTypes.ChartResourceType: - if len(res.RefPath) > 0 { - p0 := resource.FindComposeNamespace(state.ParentResources, res.RefPath[0].Identifiers) - if p0 == nil { - return "", resource.ComposeNamespaceErrUnresolved(res.RefPath[0].Identifiers) - } - p0ID = p0.Slug - } + // case composeTypes.ChartResourceType: + // if len(res.RefPath) > 0 { + // p0 := resource.FindComposeNamespace(state.ParentResources, res.RefPath[0].Identifiers) + // if p0 == nil { + // return "", resource.ComposeNamespaceErrUnresolved(res.RefPath[0].Identifiers) + // } + // p0ID = p0.Slug + // } - if res.RefRes != nil { - p1 := resource.FindComposeChart(state.ParentResources, res.RefRes.Identifiers) - if p1 == nil { - return "", resource.ComposeChartErrUnresolved(res.RefRes.Identifiers) - } - p1ID = p1.Handle - } + // if res.RefRes != nil { + // p1 := resource.FindComposeChart(state.ParentResources, res.RefRes.Identifiers) + // if p1 == nil { + // return "", resource.ComposeChartErrUnresolved(res.RefRes.Identifiers) + // } + // p1ID = p1.Handle + // } - return fmt.Sprintf(composeTypes.ChartResourceTranslationTpl(), composeTypes.ChartResourceTranslationType, p0ID, p1ID), nil + // return fmt.Sprintf(composeTypes.ChartResourceTranslationTpl(), composeTypes.ChartResourceTranslationType, p0ID, p1ID), nil - case automationTypes.WorkflowResourceType: - if res.RefRes != nil { - p0 := resource.FindAutomationWorkflow(state.ParentResources, res.RefRes.Identifiers) - if p0 == nil { - return "", resource.AutomationWorkflowErrUnresolved(res.RefRes.Identifiers) - } - p0ID = p0.Handle - } + // case automationTypes.WorkflowResourceType: + // if res.RefRes != nil { + // p0 := resource.FindAutomationWorkflow(state.ParentResources, res.RefRes.Identifiers) + // if p0 == nil { + // return "", resource.AutomationWorkflowErrUnresolved(res.RefRes.Identifiers) + // } + // p0ID = p0.Handle + // } - return fmt.Sprintf(automationTypes.WorkflowResourceTranslationTpl(), automationTypes.WorkflowResourceTranslationType, p0ID), nil + // return fmt.Sprintf(automationTypes.WorkflowResourceTranslationTpl(), automationTypes.WorkflowResourceTranslationType, p0ID), nil default: return "", fmt.Errorf("unsupported resource type '%s' for locale resource YAML encode", r.refLocaleRes.ResourceType)