[lxc-devel] [lxd/master] lxc/monitor: Fix rendering
stgraber on Github
lxc-bot at linuxcontainers.org
Fri Dec 21 21:47:37 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181221/62c9f5eb/attachment.bin>
-------------- next part --------------
From a95ba72a9ca421efb6585587ddb3b88a5abeeef9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 21 Dec 2018 16:47:19 -0500
Subject: [PATCH] lxc/monitor: Fix rendering
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
lxc/monitor.go | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/lxc/monitor.go b/lxc/monitor.go
index cd9b5684ef..e5efed007a 100644
--- a/lxc/monitor.go
+++ b/lxc/monitor.go
@@ -131,7 +131,23 @@ func (c *cmdMonitor) Run(cmd *cobra.Command, args []string) error {
return
}
- render, err := yaml.Marshal(&event)
+ // Render as JSON (to expand RawMessage)
+ jsonRender, err := json.Marshal(&event)
+ if err != nil {
+ fmt.Printf("error: %s\n", err)
+ os.Exit(1)
+ }
+
+ // Read back to a clean interface
+ var rawEvent interface{}
+ err = json.Unmarshal(jsonRender, &rawEvent)
+ if err != nil {
+ fmt.Printf("error: %s\n", err)
+ os.Exit(1)
+ }
+
+ // And now print as YAML
+ render, err := yaml.Marshal(&rawEvent)
if err != nil {
fmt.Printf("error: %s\n", err)
os.Exit(1)
More information about the lxc-devel
mailing list