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'}},
history: {method: 'GET', params: {action: 'history'}, isArray: true},
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},
inspect: {method: 'GET', params: {id: '@id', action: 'json'}},
push: {
method: 'POST', params: {action: 'push', id: '@tag'},
method: 'POST', params: {action: 'push', id: '@imageName'},
isArray: true, transformResponse: jsonObjectsToArrayHandler,
headers: { 'X-Registry-Auth': HttpRequestHelper.registryAuthenticationHeader },
ignoreLoadingBar: true
},
create: {
// method: 'POST', params: {action: 'create', fromImage: '@fromImage', tag: '@tag'},
method: 'POST', params: {action: 'create', fromImage: '@fromImage'},
isArray: true, transformResponse: jsonObjectsToArrayHandler,
headers: { 'X-Registry-Auth': HttpRequestHelper.registryAuthenticationHeader },

View File

@ -77,12 +77,20 @@ angular.module('portainer.docker')
return deferred.promise;
};
service.pushImage = function(tag, registry) {
service.pushImage = pushImage;
/**
*
* @param {PorImageRegistryModel} registryModel
*/
function pushImage(registryModel) {
var deferred = $q.defer();
var authenticationDetails = registry.Authentication ? RegistryService.encodedCredentials(registry) : '';
var authenticationDetails = registryModel.Registry.Authentication ? RegistryService.encodedCredentials(registryModel.Registry) : '';
HttpRequestHelper.setRegistryAuthenticationHeader(authenticationDetails);
Image.push({tag: tag}).$promise
const imageConfiguration = ImageHelper.createImageConfigForContainer(registryModel);
Image.push({imageName: imageConfiguration.fromImage}).$promise
.then(function success(data) {
if (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 });
});
return deferred.promise;
};
}
/**
* PULL IMAGE

View File

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