From 06c63899b2381f759f3455f521685775734c8b4e Mon Sep 17 00:00:00 2001 From: xAt0mZ Date: Mon, 25 Nov 2019 19:12:46 +0100 Subject: [PATCH] fix(app): refactor registry selector + registry auto select --- .../imageRegistry/por-image-registry.js | 1 + .../imageRegistry/porImageRegistry.html | 30 ++++++++++--------- .../porImageRegistryController.js | 2 +- .../containers/create/createcontainer.html | 11 +------ app/docker/views/images/images.html | 13 +------- .../views/services/edit/includes/image.html | 5 ---- app/portainer/models/dockerhub.js | 3 +- app/portainer/services/api/registryService.js | 8 ++--- app/portainer/services/api/templateService.js | 3 +- 9 files changed, 26 insertions(+), 50 deletions(-) diff --git a/app/docker/components/imageRegistry/por-image-registry.js b/app/docker/components/imageRegistry/por-image-registry.js index 13a75671e..39d6a5919 100644 --- a/app/docker/components/imageRegistry/por-image-registry.js +++ b/app/docker/components/imageRegistry/por-image-registry.js @@ -3,6 +3,7 @@ angular.module('portainer.docker').component('porImageRegistry', { controller: 'porImageRegistryController', bindings: { 'model': '=', // must be of type PorImageRegistryModel + 'pullWarning': '<', 'autoComplete': '<', 'labelClass': '@', 'inputClass': '@' diff --git a/app/docker/components/imageRegistry/porImageRegistry.html b/app/docker/components/imageRegistry/porImageRegistry.html index fe909247f..bcb280d96 100644 --- a/app/docker/components/imageRegistry/porImageRegistry.html +++ b/app/docker/components/imageRegistry/porImageRegistry.html @@ -1,20 +1,10 @@ -
-
- - -
-
- {{$ctrl.model.Registry.URL}} + {{$ctrl.model.Registry.URL || 'docker.io'}}
@@ -23,8 +13,8 @@ Registry
- +
@@ -45,8 +35,20 @@
-

Image name is required.

+

Image name is required. Tag must be specified otherwise Portainer will pull all tags associated to the image.

+ diff --git a/app/docker/components/imageRegistry/porImageRegistryController.js b/app/docker/components/imageRegistry/porImageRegistryController.js index 06b10c0b9..d6f6e5010 100644 --- a/app/docker/components/imageRegistry/porImageRegistryController.js +++ b/app/docker/components/imageRegistry/porImageRegistryController.js @@ -21,7 +21,7 @@ class porImageRegistryController { this.autoComplete ? this.ImageService.images() : [] ]); this.availableImages = this.ImageService.getUniqueTagListFromImages(availableImages); - this.availableRegistries = [dockerhub].concat(registries); + this.availableRegistries = _.concat(dockerhub, registries); const id = this.model.Registry.Id; if (!id) { diff --git a/app/docker/views/containers/create/createcontainer.html b/app/docker/views/containers/create/createcontainer.html index ec3e77e14..2d5d13b3c 100644 --- a/app/docker/views/containers/create/createcontainer.html +++ b/app/docker/views/containers/create/createcontainer.html @@ -29,20 +29,11 @@ -
-
- Note: if you don't specify the tag in the image name, latest will be used. -
-
-
-
- WARNING: if you don't specify the tag in the image name, all tags will be pulled for the image unless you don't ask Portainer to pull the image. -
-
diff --git a/app/docker/views/images/images.html b/app/docker/views/images/images.html index c71bc8cbf..6e883deff 100644 --- a/app/docker/views/images/images.html +++ b/app/docker/views/images/images.html @@ -17,21 +17,10 @@ - -
-
- Note: if you don't specify the tag in the image name, latest will be used. -
-
-
-
- WARNING: if you don't specify the tag in the image name, all tags will be pulled for the image. -
-
-
Deployment diff --git a/app/docker/views/services/edit/includes/image.html b/app/docker/views/services/edit/includes/image.html index f43353027..1b8a8754e 100644 --- a/app/docker/views/services/edit/includes/image.html +++ b/app/docker/views/services/edit/includes/image.html @@ -9,11 +9,6 @@ auto-complete="true" label-class="col-sm-1" input-class="col-sm-11 col-md-5" > -
-
- Note: if you don't specify the tag in the image name, latest will be used. -
-
diff --git a/app/portainer/models/dockerhub.js b/app/portainer/models/dockerhub.js index 81213cf41..880a89f5b 100644 --- a/app/portainer/models/dockerhub.js +++ b/app/portainer/models/dockerhub.js @@ -1,7 +1,6 @@ export function DockerHubViewModel(data) { this.Name = 'DockerHub'; - this.URL = 'docker.io'; - // this.URL = ''; + this.URL = ''; this.Authentication = data.Authentication; this.Username = data.Username; this.Password = data.Password; diff --git a/app/portainer/services/api/registryService.js b/app/portainer/services/api/registryService.js index 8b19cc3bd..d2c7704be 100644 --- a/app/portainer/services/api/registryService.js +++ b/app/portainer/services/api/registryService.js @@ -83,7 +83,7 @@ function RegistryServiceFactory($q, $async, Registries, DockerHubService, ImageH service.retrievePorRegistryModelFromRepositoryWithRegistries = retrievePorRegistryModelFromRepositoryWithRegistries; - function retrievePorRegistryModelFromRepositoryWithRegistries(repository, registries) { + function retrievePorRegistryModelFromRepositoryWithRegistries(repository, registries, dockerhub) { const model = new PorImageRegistryModel(); const registry = _.find(registries, (reg) => _.includes(repository, reg.URL)); if (registry) { @@ -93,6 +93,7 @@ function RegistryServiceFactory($q, $async, Registries, DockerHubService, ImageH model.Image = image; } else { model.UseRegistry = false; + model.Registry = dockerhub; model.Image = repository; } return model; @@ -100,12 +101,11 @@ function RegistryServiceFactory($q, $async, Registries, DockerHubService, ImageH async function retrievePorRegistryModelFromRepositoryAsync(repository) { try { - const [registries, dockerhub] = await Promise.all([ + let [registries, dockerhub] = await Promise.all([ service.registries(), DockerHubService.dockerhub() ]); - registries.concat([dockerhub]); - return retrievePorRegistryModelFromRepositoryWithRegistries(repository, registries); + return retrievePorRegistryModelFromRepositoryWithRegistries(repository, registries, dockerhub); } catch (err) { throw { msg: 'Unable to retrieve the registry associated to the repository', err: err } } diff --git a/app/portainer/services/api/templateService.js b/app/portainer/services/api/templateService.js index a94c46d82..ae328ce23 100644 --- a/app/portainer/services/api/templateService.js +++ b/app/portainer/services/api/templateService.js @@ -19,10 +19,9 @@ function TemplateServiceFactory($q, Templates, TemplateHelper, RegistryService, dockerhub: DockerHubService.dockerhub() }) .then(function success(data) { - data.registries.concat([data.dockerhub]); const templates = data.templates.map(function (item) { const res = new TemplateViewModel(item); - const registry = RegistryService.retrievePorRegistryModelFromRepositoryWithRegistries(res.RegistryModel.Registry, data.registries); + const registry = RegistryService.retrievePorRegistryModelFromRepositoryWithRegistries(res.RegistryModel.Registry, data.registries, data.dockerhub); registry.Image = res.RegistryModel.Image; res.RegistryModel = registry; return res;