From 75085b213a2bd1fef2d229ad13244418620475e1 Mon Sep 17 00:00:00 2001 From: Kevan Ahlquist Date: Sun, 13 Dec 2015 23:28:28 -0600 Subject: [PATCH] Support RepoTags for versions of the Docker API older than 1.21. --- app/components/image/imageController.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/app/components/image/imageController.js b/app/components/image/imageController.js index 2bae9d39b..6a903206a 100644 --- a/app/components/image/imageController.js +++ b/app/components/image/imageController.js @@ -63,10 +63,29 @@ angular.module('image', []) return defer.promise; } + /** + * Get RepoTags from the /images/query endpoint instead of /image/json, + * for backwards compatibility with Docker API versions older than 1.21 + * @param {string} imageId + */ + function getRepoTags(imageId) { + Image.query({}, function (d) { + d.forEach(function(image) { + if (image.Id === imageId && image.RepoTags[0] !== ':') { + $scope.RepoTags = image.RepoTags; + } + }); + }); + } + Image.get({id: $routeParams.id}, function (d) { $scope.image = d; $scope.id = d.Id; - $scope.RepoTags = d.RepoTags; + if (d.RepoTags) { + $scope.RepoTags = d.RepoTags; + } else { + getRepoTags($scope.id); + } getContainersFromImage($q, Container, $scope.id).then(function (containers) { LineChart.build('#containers-started-chart', containers, function (c) {