mirror of
https://github.com/portainer/portainer.git
synced 2025-07-22 23:09:41 +02:00
* 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
89 lines
3.1 KiB
JavaScript
89 lines
3.1 KiB
JavaScript
import angular from 'angular';
|
|
import _ from 'lodash-es';
|
|
import { DockerHubViewModel } from 'Portainer/models/dockerhub';
|
|
import { RegistryTypes } from 'Extensions/registry-management/models/registryTypes';
|
|
|
|
class porImageRegistryController {
|
|
/* @ngInject */
|
|
constructor($async, $scope, ImageHelper, RegistryService, DockerHubService, ImageService, Notifications) {
|
|
this.$async = $async;
|
|
this.$scope = $scope;
|
|
this.ImageHelper = ImageHelper;
|
|
this.RegistryService = RegistryService;
|
|
this.DockerHubService = DockerHubService;
|
|
this.ImageService = ImageService;
|
|
this.Notifications = Notifications;
|
|
|
|
this.onInit = this.onInit.bind(this);
|
|
this.onRegistryChange = this.onRegistryChange.bind(this);
|
|
|
|
this.$scope.$watch(() => this.model.Registry, this.onRegistryChange);
|
|
}
|
|
|
|
isKnownRegistry(registry) {
|
|
return !(registry instanceof DockerHubViewModel) && registry.URL;
|
|
}
|
|
|
|
getRegistryURL(registry) {
|
|
let url = registry.URL;
|
|
if (registry.Type === RegistryTypes.GITLAB) {
|
|
url = registry.URL + '/' + registry.Gitlab.ProjectPath;
|
|
}
|
|
return url;
|
|
}
|
|
|
|
prepareAutocomplete() {
|
|
let images = [];
|
|
const registry = this.model.Registry;
|
|
if (this.isKnownRegistry(registry)) {
|
|
const url = this.getRegistryURL(registry);
|
|
const registryImages = _.filter(this.images, (image) => _.includes(image, url));
|
|
images = _.map(registryImages, (image) => _.replace(image, new RegExp(url + '\/?'), ''));
|
|
} else {
|
|
const registries = _.filter(this.availableRegistries, (reg) => this.isKnownRegistry(reg));
|
|
const registryImages = _.flatMap(registries, (registry) => _.filter(this.images, (image) => _.includes(image, registry.URL)));
|
|
const imagesWithoutKnown = _.difference(this.images, registryImages);
|
|
images = _.filter(imagesWithoutKnown, (image) => !this.ImageHelper.imageContainsURL(image));
|
|
}
|
|
this.availableImages = images;
|
|
}
|
|
|
|
onRegistryChange() {
|
|
this.prepareAutocomplete();
|
|
if (this.model.Registry.Type === RegistryTypes.GITLAB && this.model.Image) {
|
|
this.model.Image = _.replace(this.model.Image, this.model.Registry.Gitlab.ProjectPath, '');
|
|
}
|
|
}
|
|
|
|
displayedRegistryURL() {
|
|
return this.getRegistryURL(this.model.Registry) || 'docker.io';
|
|
}
|
|
|
|
async onInit() {
|
|
try {
|
|
const [registries, dockerhub, images] = await Promise.all([
|
|
this.RegistryService.registries(),
|
|
this.DockerHubService.dockerhub(),
|
|
this.autoComplete ? this.ImageService.images() : []
|
|
]);
|
|
this.images = this.ImageService.getUniqueTagListFromImages(images);
|
|
this.availableRegistries = _.concat(dockerhub, registries);
|
|
|
|
const id = this.model.Registry.Id;
|
|
if (!id) {
|
|
this.model.Registry = dockerhub;
|
|
} else {
|
|
this.model.Registry = _.find(this.availableRegistries, { 'Id': id });
|
|
}
|
|
} catch (err) {
|
|
this.Notifications.error('Failure', err, 'Unable to retrieve registries');
|
|
}
|
|
}
|
|
|
|
$onInit() {
|
|
return this.$async(this.onInit);
|
|
}
|
|
}
|
|
|
|
export default porImageRegistryController;
|
|
angular.module('portainer.docker').controller('porImageRegistryController', porImageRegistryController);
|