1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-29 18:29:44 +02:00

fix(app): registry push-pull features overhaul (#3393)

* feat(registry): registry or direct url selector

* feat(app): push pull container creation

* feat(app): push pull container duplicate

* feat(app): push pull container details recreate

* feat(app): push pull container details commit

* feat(app): push pull images

* feat(app): push pull image tag

* feat(app): push pull image push

* feat(app): push pull image pull

* feat(app): push pull service creation

* feat(app): push pull templates create container

* feat(app): push pull templates create stacks

* feat(app): push pull template edit

* feat(app): push pull service details update

* fix(app): refactor registry selector + registry auto select

* feat(app): remove autocomplete on registry selector

* style(image-registry): reword simple/advanced mode

* Revert "feat(app): remove autocomplete on registry selector"

This reverts commit 97ec2ddd62.

* refactor(registry-selector): reverse registry and image fields

* feat(app): autocomplete on registry selector

* feat(registry-selector): change gitlab registry autocomplete

* feat(registry-selector): autocomplete for dockerhub

* feat(registry-selector): gitlab url based on locked value instead of name

* fix(registry-selector): gitlab registries URL are not modified anymore

* fix(registry-selector): change gitlab image autofill on duplicate

* fix(registry-selector): gitlab registries now only suggest their own images and not all from gitlab

* fix(registry-selector): psuh pull issues with gitlab registries

* fix(registry-selector): dockerhub registry selection on duplicate for dockerhub images

* fix(templates): registry retrieval for template

* feat(images): add autocomplete on image pull panel

* fix(registry-selector): add latest tag when no tag is specified

* fix(registry-selector): latest tag now applied for non gitlab registries
This commit is contained in:
xAt0mZ 2019-11-27 23:36:39 +01:00 committed by Anthony Lapenna
parent 61c38534a7
commit e19bc8abc7
32 changed files with 525 additions and 349 deletions

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,11 @@ angular.module('portainer.docker')
deferred.reject({ msg: 'Unable to push image tag', err: err });
});
return deferred.promise;
};
}
/**
* PULL IMAGE
*/
function pullImageAndIgnoreErrors(imageConfiguration) {
var deferred = $q.defer();
@ -127,21 +139,31 @@ angular.module('portainer.docker')
return deferred.promise;
}
service.pullImage = function(image, registry, ignoreErrors) {
var imageDetails = ImageHelper.extractImageAndRegistryFromRepository(image);
var imageConfiguration = ImageHelper.createImageConfigForContainer(imageDetails.image, registry.URL);
var authenticationDetails = registry.Authentication ? RegistryService.encodedCredentials(registry) : '';
service.pullImage = pullImage;
/**
*
* @param {PorImageRegistryModel} registry
* @param {bool} ignoreErrors
*/
function pullImage(registry, ignoreErrors) {
var authenticationDetails = registry.Registry.Authentication ? RegistryService.encodedCredentials(registry.Registry) : '';
HttpRequestHelper.setRegistryAuthenticationHeader(authenticationDetails);
var imageConfiguration = ImageHelper.createImageConfigForContainer(registry);
if (ignoreErrors) {
return pullImageAndIgnoreErrors(imageConfiguration);
}
return pullImageAndAcknowledgeErrors(imageConfiguration);
};
}
service.tagImage = function(id, image, registry) {
var imageConfig = ImageHelper.createImageConfigForCommit(image, registry);
return Image.tag({id: id, tag: imageConfig.tag, repo: imageConfig.repo}).$promise;
/**
* ! PULL IMAGE
*/
service.tagImage = function(id, image) {
return Image.tag({id: id, repo: image}).$promise;
};
service.downloadImages = function(images) {