grim/port-authority

Parents 9d4ebf964c18
Children 0d2c9c684964
support registry.hub.docker.com as well as private repository tag lookups
  • +23 -12
    js/app.js
  • --- a/js/app.js Mon Dec 08 01:28:37 2014 -0600
    +++ b/js/app.js Mon Dec 08 02:12:46 2014 -0600
    @@ -65,23 +65,34 @@
    $scope.select_repo = function(repo) {
    $scope.repo = repo;
    -
    - // manifestREST.images($scope.registry, repo.name)
    - // .success(function(data, status, headers, config) {
    - // repo.images = data;
    - // })
    - // .error(function(data, status, headers, config) {
    - // console.log("Failed to get the image list: " + status);
    - // });
    + $scope.tags = null;
    manifestREST.tags($scope.registry, repo.name)
    .success(function(data, status, headers, config) {
    + /* the docker registry returns a list of objects like
    + * [{"layer", "deadb33f", "name": "latest"}]
    + * and the private registry returns a dictionary of tag
    + * names to images. Like:
    + * {"latest", "deadb33f"}
    + * This function will normalize them into an object like
    + * {"deadb33f", ["latest"]}
    + */
    $scope.tags = {};
    - for(var ntag in data) {
    - var tag = data[ntag];
    - $scope.tags[tag.layer] = $scope.tags[tag.layer] || [];
    +
    + if(data.constructor === Array) { /* registry.hub.docker.com */
    + for(var ntag in data) {
    + var tag = data[ntag];
    + $scope.tags[tag.layer] = $scope.tags[tag.layer] || [];
    - $scope.tags[tag.layer].push(tag.name);
    + $scope.tags[tag.layer].push(tag.name);
    + }
    + } else if(data !== null && typeof data === 'object') { /* private registries */
    + for(var tag in data) {
    + var layer = data[tag];
    +
    + $scope.tags[layer] = $scope.tags[layer] || [];
    + $scope.tags[layer].push(tag);
    + }
    }
    })
    .error(function(data, status, headers, config) {