Select a sane default tag.

This commit is contained in:
yackob03 2013-10-16 22:37:29 -04:00
parent f1746417b1
commit d6e89f76ad
3 changed files with 42 additions and 13 deletions

View file

@ -52,7 +52,8 @@ def create_subtree(repo, structure, parent):
create_subtree(repo, subtree, new_image)
def __generate_repository(user, name, description, is_public, permissions, structure):
def __generate_repository(user, name, description, is_public, permissions,
structure):
repo = model.create_repository(user.username, name, user)
if is_public:
@ -92,7 +93,7 @@ if __name__ == '__main__':
'Complex repository with many branches and tags.',
False, [(new_user_2, 'read')],
(2, [(3, [], 'v2.0'),
(1, [(1, [(1, [], ['latest', 'prod'])],
(1, [(1, [(1, [], ['prod'])],
'staging'),
(1, [], None)], None)], None))
@ -113,3 +114,7 @@ if __name__ == '__main__':
__generate_repository(new_user_1, 'shared',
'Shared repository, another user can write.', False,
[(new_user_2, 'write')], (5, [], 'latest'))
__generate_repository(new_user_1, 'empty',
'Empty repository with no images or tags.', False,
[], (0, [], None))

View file

@ -295,11 +295,23 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope) {
if (!string) { return ''; }
return getMarkedDown(string);
};
$scope.listImages = function() {
var getDefaultTag = function() {
if ($scope.repo === undefined) {
return undefined;
} else if ($scope.repo.tags.hasOwnProperty('latest')) {
return $scope.repo.tags['latest'];
} else {
for (key in $scope.repo.tags) {
return $scope.repo.tags[key];
}
}
};
var listImages = function() {
if ($scope.imageHistory) { return; }
var imageFetch = Restangular.one('repository/' + namespace + '/' + name + '/image');
var imageFetch = Restangular.one('repository/' + namespace + '/' + name + '/image/');
imageFetch.get().then(function(resp) {
$scope.imageHistory = resp.images;
$scope.tree = new ImageHistoryTree(namespace, name, resp.images, $scope.currentTag,
@ -324,10 +336,23 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope) {
$scope.setTag = function(tagName) {
var repo = $scope.repo;
$scope.currentTag = repo.tags[tagName] || repo.tags['latest'];
$scope.currentImage = $scope.currentTag.image;
if ($scope.tree) {
$scope.tree.setTag($scope.currentTag.name);
var proposedTag = repo.tags[tagName];
if (!proposedTag) {
// We must find a good default
for (tagName in repo.tags) {
if (!proposedTag || tagName == 'latest') {
proposedTag = repo.tags[tagName];
}
}
}
if (proposedTag) {
$scope.currentTag = repo.tags[tagName] || repo.tags['latest'];
$scope.currentImage = $scope.currentTag.image;
if ($scope.tree) {
$scope.tree.setTag($scope.currentTag.name);
}
}
};
@ -342,7 +367,6 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope) {
var namespace = $routeParams.namespace;
var name = $routeParams.name;
var tag = $routeParams.tag || 'latest';
$scope.loading = true;
@ -351,8 +375,8 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope) {
repositoryFetch.get().then(function(repo) {
$rootScope.title = namespace + '/' + name;
$scope.repo = repo;
$scope.currentTag = repo.tags[tag] || repo.tags['latest'];
$scope.setImage($scope.currentTag.image);
$scope.setTag($routeParams.tag);
var clip = new ZeroClipboard($('#copyClipboard'), { 'moviePath': 'static/lib/ZeroClipboard.swf' });
clip.on('complete', function() {
@ -374,7 +398,7 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope) {
});
// Fetch the image history.
$scope.listImages();
listImages();
}
function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {

BIN
test.db

Binary file not shown.