1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-22 06:49:40 +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

@ -1,14 +1,15 @@
import moment from 'moment';
import { PorImageRegistryModel } from 'Docker/models/porImageRegistry';
angular.module('portainer.docker')
.controller('ContainerController', ['$q', '$scope', '$state','$transition$', '$filter', 'Commit', 'ContainerHelper', 'ContainerService', 'ImageHelper', 'NetworkService', 'Notifications', 'ModalService', 'ResourceControlService', 'RegistryService', 'ImageService', 'HttpRequestHelper', 'Authentication',
function ($q, $scope, $state, $transition$, $filter, Commit, ContainerHelper, ContainerService, ImageHelper, NetworkService, Notifications, ModalService, ResourceControlService, RegistryService, ImageService, HttpRequestHelper, Authentication) {
.controller('ContainerController', ['$q', '$scope', '$state','$transition$', '$filter', '$async', 'Commit', 'ContainerHelper', 'ContainerService', 'ImageHelper', 'NetworkService', 'Notifications', 'ModalService', 'ResourceControlService', 'RegistryService', 'ImageService', 'HttpRequestHelper', 'Authentication',
function ($q, $scope, $state, $transition$, $filter, $async, Commit, ContainerHelper, ContainerService, ImageHelper, NetworkService, Notifications, ModalService, ResourceControlService, RegistryService, ImageService, HttpRequestHelper, Authentication) {
$scope.activityTime = 0;
$scope.portBindings = [];
$scope.config = {
Image: '',
Registry: ''
RegistryModel: new PorImageRegistryModel(),
commitInProgress: false
};
$scope.state = {
@ -149,20 +150,23 @@ function ($q, $scope, $state, $transition$, $filter, Commit, ContainerHelper, Co
});
};
$scope.commit = function () {
var image = $scope.config.Image;
$scope.config.Image = '';
var registry = $scope.config.Registry;
var imageConfig = ImageHelper.createImageConfigForCommit(image, registry.URL);
Commit.commitContainer({id: $transition$.params().id, tag: imageConfig.tag, repo: imageConfig.repo}, function () {
update();
async function commitContainerAsync() {
$scope.config.commitInProgress = true;
const registryModel = $scope.config.RegistryModel;
const imageConfig = ImageHelper.createImageConfigForContainer(registryModel);
try {
await Commit.commitContainer({id: $transition$.params().id, repo: imageConfig.fromImage}).$promise;
Notifications.success('Image created', $transition$.params().id);
}, function (e) {
update();
Notifications.error('Failure', e, 'Unable to create image');
});
};
$state.reload();
} catch (err) {
Notifications.error('Failure', err, 'Unable to create image');
$scope.config.commitInProgress = false;
}
}
$scope.commit = function () {
return $async(commitContainerAsync);
};
$scope.confirmRemove = function () {
var title = 'You are about to remove a container.';
@ -225,15 +229,12 @@ function ($q, $scope, $state, $transition$, $filter, Commit, ContainerHelper, Co
if (!pullImage) {
return $q.when();
}
return getRegistry().then(function pullImage(containerRegistery) {
return ImageService.pullImage(container.Config.Image, containerRegistery, true);
return RegistryService.retrievePorRegistryModelFromRepository(container.Config.Image)
.then(function pullImage(registryModel) {
return ImageService.pullImage(registryModel, true);
});
}
function getRegistry() {
return RegistryService.retrieveRegistryFromRepository(container.Config.Image);
}
function setMainNetworkAndCreateContainer() {
var networks = config.NetworkingConfig.EndpointsConfig;
var networksNames = Object.keys(networks);