[systemd-devel] [PATCH v2 4/5] import/pull: Tag replaced with reference

Pavel Odvody podvody at redhat.com
Tue May 19 07:30:04 PDT 2015


Default pull version set to V2
---
 src/import/pull.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/src/import/pull.c b/src/import/pull.c
index ef7b035..0f2ad92 100644
--- a/src/import/pull.c
+++ b/src/import/pull.c
@@ -227,7 +227,7 @@ static void on_dkr_finished(DkrPull *pull, int error, void *userdata) {
 static int pull_dkr(int argc, char *argv[], void *userdata) {
         _cleanup_(dkr_pull_unrefp) DkrPull *pull = NULL;
         _cleanup_event_unref_ sd_event *event = NULL;
-        const char *name, *tag, *local;
+        const char *name, *reference, *local, *digest;
         int r;
 
         if (!arg_dkr_index_url) {
@@ -240,13 +240,19 @@ static int pull_dkr(int argc, char *argv[], void *userdata) {
                 return -EINVAL;
         }
 
-        tag = strchr(argv[1], ':');
-        if (tag) {
-                name = strndupa(argv[1], tag - argv[1]);
-                tag++;
+        digest = strchr(argv[1], '@');
+        if (digest) {
+                reference = digest + 1;
+                name = strndupa(argv[1], digest - argv[1]);
+        }
+
+        reference = strchr(argv[1], ':');
+        if (reference) {
+                name = strndupa(argv[1], reference - argv[1]);
+                reference++;
         } else {
                 name = argv[1];
-                tag = "latest";
+                reference = "latest";
         }
 
         if (!dkr_name_is_valid(name)) {
@@ -254,8 +260,8 @@ static int pull_dkr(int argc, char *argv[], void *userdata) {
                 return -EINVAL;
         }
 
-        if (!dkr_tag_is_valid(tag)) {
-                log_error("Tag name '%s' is not valid.", tag);
+        if (!dkr_ref_is_valid(reference)) {
+                log_error("Tag name '%s' is not valid.", reference);
                 return -EINVAL;
         }
 
@@ -288,9 +294,9 @@ static int pull_dkr(int argc, char *argv[], void *userdata) {
                         }
                 }
 
-                log_info("Pulling '%s' with tag '%s', saving as '%s'.", name, tag, local);
+                log_info("Pulling '%s' with reference '%s', saving as '%s'.", name, reference, local);
         } else
-                log_info("Pulling '%s' with tag '%s'.", name, tag);
+                log_info("Pulling '%s' with reference '%s'.", name, reference);
 
         r = sd_event_default(&event);
         if (r < 0)
@@ -304,7 +310,7 @@ static int pull_dkr(int argc, char *argv[], void *userdata) {
         if (r < 0)
                 return log_error_errno(r, "Failed to allocate puller: %m");
 
-        r = dkr_pull_start(pull, name, tag, local, arg_force);
+        r = dkr_pull_start(pull, name, reference, local, arg_force, DKR_PULL_V2);
         if (r < 0)
                 return log_error_errno(r, "Failed to pull image: %m");
 
-- 
2.1.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20150519/fcbda662/attachment.sig>


More information about the systemd-devel mailing list