The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/5467

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Modify the progress metadata to send stage, percent, speed in
a map keyed by 'progress'. Metadata format will now be:
* progress => {stage: <string>, percent: <string>, speed: <string>}
* <stage>_progress => <string>

Signed-off-by: Joel Hockey <[email protected]>
From a51401b0a42f1973db89db042a18c42177850bc9 Mon Sep 17 00:00:00 2001
From: Joel Hockey <[email protected]>
Date: Tue, 5 Feb 2019 13:38:06 -0800
Subject: [PATCH] shared: Progress metadata as a map

Modify the progress metadata to send stage, percent, speed in
a map keyed by 'progress'. Metadata format will now be:
* progress => {stage: <string>, percent: <string>, speed: <string>}
* <stage>_progress => <string>

Signed-off-by: Joel Hockey <[email protected]>
---
 lxd/containers_post.go |  2 +-
 lxd/images.go          |  4 ++--
 shared/util.go         | 10 ++++++----
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/lxd/containers_post.go b/lxd/containers_post.go
index d3dadacaa4..a39c04abe6 100644
--- a/lxd/containers_post.go
+++ b/lxd/containers_post.go
@@ -129,7 +129,7 @@ func createFromImage(d *Daemon, project string, req 
*api.ContainersPost) Respons
                        return err
                }
 
-               metadata := make(map[string]string)
+               metadata := make(map[string]interface{})
                _, err = containerCreateFromImage(d, args, info.Fingerprint, 
&ioprogress.ProgressTracker{
                        Handler: func(percent, speed int64) {
                                shared.SetProgressMetadata(metadata, 
"create_container_from_image_unpack", "Unpack", percent, speed)
diff --git a/lxd/images.go b/lxd/images.go
index 39311d7423..3a5f19239e 100644
--- a/lxd/images.go
+++ b/lxd/images.go
@@ -207,7 +207,7 @@ func imgPostContInfo(d *Daemon, r *http.Request, req 
api.ImagesPost, op *operati
        }
 
        // Track progress writing tarfile
-       metadata := make(map[string]string)
+       metadata := make(map[string]interface{})
        tarfileProgressWriter := &ioprogress.ProgressWriter{
                WriteCloser: tarfile,
                Tracker: &ioprogress.ProgressTracker{
@@ -262,7 +262,7 @@ func imgPostContInfo(d *Daemon, r *http.Request, req 
api.ImagesPost, op *operati
                }
 
                // Track progress writing gzipped file
-               metadata = make(map[string]string)
+               metadata = make(map[string]interface{})
                tarfileProgressReader := &ioprogress.ProgressReader{
                        ReadCloser: tarfile,
                        Tracker: &ioprogress.ProgressTracker{
diff --git a/shared/util.go b/shared/util.go
index 7aba6c3af7..792e49dd67 100644
--- a/shared/util.go
+++ b/shared/util.go
@@ -1008,11 +1008,13 @@ func EscapePathFstab(path string) string {
        return r.Replace(path)
 }
 
-func SetProgressMetadata(metadata map[string]string, stage, displayPrefix 
string, percent, speed int64) {
+func SetProgressMetadata(metadata map[string]interface{}, stage, displayPrefix 
string, percent, speed int64) {
+       progress := make(map[string]string)
        // stage, percent, speed sent for API callers.
-       metadata["progress_stage"] = stage
-       metadata["progress_percent"] = strconv.FormatInt(percent, 10)
-       metadata["progress_speed"] = strconv.FormatInt(speed, 10)
+       progress["stage"] = stage
+       progress["percent"] = strconv.FormatInt(percent, 10)
+       progress["speed"] = strconv.FormatInt(speed, 10)
+       metadata["progress"] = progress
        // <stage>_progress with formatted text sent for lxc cli.
        metadata[stage+"_progress"] = fmt.Sprintf("%s: %d%% (%s/s)", 
displayPrefix, percent, GetByteSizeString(speed, 2))
 }
_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to