diff --git a/compose/commands/exporter.go b/compose/commands/exporter.go index 68c33cd72..4ec70e49b 100644 --- a/compose/commands/exporter.go +++ b/compose/commands/exporter.go @@ -87,6 +87,9 @@ func Exporter(ctx context.Context, c *cli.Config) *cobra.Command { return cmd } +// This is PoC for exporting compose resources +// + type ( Compose struct { Modules map[string]Module `yaml:",omitempty"` @@ -140,11 +143,19 @@ type ( Chart struct { Name string `yaml:",omitempty"` - Config types.ChartConfig `yaml:",omitempty"` + Config ChartConfig `yaml:",omitempty"` Allow map[string][]string `yaml:",omitempty"` Deny map[string][]string `yaml:",omitempty"` } + + ChartConfig struct { + Reports []*ChartConfigReport + } + ChartConfigReport struct { + types.ChartConfigReport + Module string `json:"module"` + } ) func expModules(mm types.ModuleSet) (o map[string]Module) { @@ -322,11 +333,26 @@ func expCharts(charts types.ChartSet, modules types.ModuleSet) (o map[string]Cha for _, c := range charts { chart := Chart{ Name: c.Name, - Config: c.Config, + Config: ChartConfig{Reports: make([]*ChartConfigReport, len(c.Config.Reports))}, Allow: expResourcePermissions(permissions.Allow, types.ChartPermissionResource), Deny: expResourcePermissions(permissions.Deny, types.ChartPermissionResource), } + + for i, r := range c.Config.Reports { + chart.Config.Reports[i] = &ChartConfigReport{ + ChartConfigReport: *r, + } + + if r.ModuleID > 0 { + module := modules.FindByID(r.ModuleID) + chart.Config.Reports[i].ModuleID = 0 + chart.Config.Reports[i].Module = + makeHandleFromName(module.Name, module.Handle, "module-%d", module.ID) + } + + } + // @todo moduleID => module Handle (CONFIG) handle := makeHandleFromName(c.Name, c.Handle, "chart-%d", c.ID) diff --git a/compose/types/chart.go b/compose/types/chart.go index 8a1ebfce6..6a3520f7a 100644 --- a/compose/types/chart.go +++ b/compose/types/chart.go @@ -29,10 +29,10 @@ type ( } ChartConfigReport struct { - Filter string `json:"filter" yaml:",omitempty"` - ModuleID uint64 `json:"moduleID,string" yaml:"moduleID"` - Metrics []map[string]interface{} `json:"metrics,omitempty" yaml:",omitempty"` - Dimensions []map[string]interface{} `json:"dimensions,omitempty" yaml:",omitempty"` + Filter string `json:"filter" yaml:",omitempty"` + ModuleID uint64 `json:"moduleID,string,omitempty" yaml:"moduleID,omitempty"` + Metrics []map[string]interface{} `json:"metrics,omitempty" yaml:",omitempty"` + Dimensions []map[string]interface{} `json:"dimensions,omitempty" yaml:",omitempty"` Renderer struct { Version string `json:"version,omitempty" yaml:",omitempty"` } `json:"renderer,omitempty" yaml:",omitempty"`