feat(app): push pull image push

pull/3393/head
xAt0mZ 2019-11-21 17:08:35 +01:00
parent b549b8207a
commit d27d5c216a
3 changed files with 16 additions and 12 deletions

View File

@ -15,17 +15,15 @@ function ImageFactory($resource, API_ENDPOINT_ENDPOINTS, EndpointProvider, HttpR
search: {method: 'GET', params: {action: 'search'}}, search: {method: 'GET', params: {action: 'search'}},
history: {method: 'GET', params: {action: 'history'}, isArray: true}, history: {method: 'GET', params: {action: 'history'}, isArray: true},
insert: {method: 'POST', params: {id: '@id', action: 'insert'}}, insert: {method: 'POST', params: {id: '@id', action: 'insert'}},
// tag: {method: 'POST', params: {id: '@id', action: 'tag', force: 0, repo: '@repo', tag: '@tag'}, ignoreLoadingBar: true},
tag: {method: 'POST', params: {id: '@id', action: 'tag', force: 0, repo: '@repo'}, ignoreLoadingBar: true}, tag: {method: 'POST', params: {id: '@id', action: 'tag', force: 0, repo: '@repo'}, ignoreLoadingBar: true},
inspect: {method: 'GET', params: {id: '@id', action: 'json'}}, inspect: {method: 'GET', params: {id: '@id', action: 'json'}},
push: { push: {
method: 'POST', params: {action: 'push', id: '@tag'}, method: 'POST', params: {action: 'push', id: '@imageName'},
isArray: true, transformResponse: jsonObjectsToArrayHandler, isArray: true, transformResponse: jsonObjectsToArrayHandler,
headers: { 'X-Registry-Auth': HttpRequestHelper.registryAuthenticationHeader }, headers: { 'X-Registry-Auth': HttpRequestHelper.registryAuthenticationHeader },
ignoreLoadingBar: true ignoreLoadingBar: true
}, },
create: { create: {
// method: 'POST', params: {action: 'create', fromImage: '@fromImage', tag: '@tag'},
method: 'POST', params: {action: 'create', fromImage: '@fromImage'}, method: 'POST', params: {action: 'create', fromImage: '@fromImage'},
isArray: true, transformResponse: jsonObjectsToArrayHandler, isArray: true, transformResponse: jsonObjectsToArrayHandler,
headers: { 'X-Registry-Auth': HttpRequestHelper.registryAuthenticationHeader }, headers: { 'X-Registry-Auth': HttpRequestHelper.registryAuthenticationHeader },

View File

@ -77,12 +77,20 @@ angular.module('portainer.docker')
return deferred.promise; return deferred.promise;
}; };
service.pushImage = function(tag, registry) { service.pushImage = pushImage;
/**
*
* @param {PorImageRegistryModel} registryModel
*/
function pushImage(registryModel) {
var deferred = $q.defer(); var deferred = $q.defer();
var authenticationDetails = registry.Authentication ? RegistryService.encodedCredentials(registry) : ''; var authenticationDetails = registryModel.Registry.Authentication ? RegistryService.encodedCredentials(registryModel.Registry) : '';
HttpRequestHelper.setRegistryAuthenticationHeader(authenticationDetails); HttpRequestHelper.setRegistryAuthenticationHeader(authenticationDetails);
Image.push({tag: tag}).$promise
const imageConfiguration = ImageHelper.createImageConfigForContainer(registryModel);
Image.push({imageName: imageConfiguration.fromImage}).$promise
.then(function success(data) { .then(function success(data) {
if (data[data.length - 1].error) { if (data[data.length - 1].error) {
deferred.reject({ msg: data[data.length - 1].error }); deferred.reject({ msg: data[data.length - 1].error });
@ -94,7 +102,7 @@ angular.module('portainer.docker')
deferred.reject({ msg: 'Unable to push image tag', err: err }); deferred.reject({ msg: 'Unable to push image tag', err: err });
}); });
return deferred.promise; return deferred.promise;
}; }
/** /**
* PULL IMAGE * PULL IMAGE

View File

@ -41,13 +41,11 @@ function ($q, $scope, $transition$, $state, $timeout, ImageService, ImageHelper,
}); });
}; };
// TODO CHANGE
$scope.pushTag = function(repository) { $scope.pushTag = function(repository) {
$('#uploadResourceHint').show(); $('#uploadResourceHint').show();
RegistryService.retrieveRegistryFromRepository(repository) RegistryService.retrievePorRegistryModelFromRepository(repository)
.then(function success(data) { .then(function success(registryModel) {
var registry = data; return ImageService.pushImage(registryModel);
return ImageService.pushImage(repository, registry);
}) })
.then(function success() { .then(function success() {
Notifications.success('Image successfully pushed', repository); Notifications.success('Image successfully pushed', repository);