From f66f878803cfd41527b92c0908157773fd14affe Mon Sep 17 00:00:00 2001 From: xAt0mZ Date: Sat, 29 Jun 2019 03:38:13 +0200 Subject: [PATCH] feat(registry): dockerhub registry --- .../handler/registries/registry_create.go | 4 +- api/portainer.go | 4 +- .../registry-form-dockerhub.html | 48 +++++++++++++++++++ .../registry-form-dockerhub.js | 9 ++++ .../create/createRegistryController.js | 7 +++ .../registries/create/createregistry.html | 17 +++++++ 6 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 app/portainer/components/forms/registry-form-dockerhub/registry-form-dockerhub.html create mode 100644 app/portainer/components/forms/registry-form-dockerhub/registry-form-dockerhub.js diff --git a/api/http/handler/registries/registry_create.go b/api/http/handler/registries/registry_create.go index 1b6dbf638..1bcfe9bdd 100644 --- a/api/http/handler/registries/registry_create.go +++ b/api/http/handler/registries/registry_create.go @@ -29,8 +29,8 @@ func (payload *registryCreatePayload) Validate(r *http.Request) error { if payload.Authentication && (govalidator.IsNull(payload.Username) || govalidator.IsNull(payload.Password)) { return portainer.Error("Invalid credentials. Username and password must be specified when authentication is enabled") } - if payload.Type != 1 && payload.Type != 2 && payload.Type != 3 { - return portainer.Error("Invalid registry type. Valid values are: 1 (Quay.io), 2 (Azure container registry) or 3 (custom registry)") + if payload.Type != 1 && payload.Type != 2 && payload.Type != 3 && payload.Type != 4 { + return portainer.Error("Invalid registry type. Valid values are: 1 (Quay.io), 2 (Azure container registry), 3 (custom registry) or 4 (Docker Hub)") } return nil } diff --git a/api/portainer.go b/api/portainer.go index 1cb48f826..0821b4a20 100644 --- a/api/portainer.go +++ b/api/portainer.go @@ -877,7 +877,7 @@ const ( // SupportedDockerAPIVersion is the minimum Docker API version supported by Portainer SupportedDockerAPIVersion = "1.24" // ExtensionServer represents the server used by Portainer to communicate with extensions - ExtensionServer = "localhost" + ExtensionServer = "192.168.0.15" ) const ( @@ -1017,6 +1017,8 @@ const ( AzureRegistry // CustomRegistry represents a custom registry CustomRegistry + // DockerHubRegistry represents a DockerHub registry + DockerHubRegistry ) const ( diff --git a/app/portainer/components/forms/registry-form-dockerhub/registry-form-dockerhub.html b/app/portainer/components/forms/registry-form-dockerhub/registry-form-dockerhub.html new file mode 100644 index 000000000..94d78c59b --- /dev/null +++ b/app/portainer/components/forms/registry-form-dockerhub/registry-form-dockerhub.html @@ -0,0 +1,48 @@ +
+
+ Docker Hub registry details +
+ +
+ +
+ +
+
+
+
+
+

This field is required.

+
+
+
+ + +
+ +
+ +
+
+
+
+
+

This field is required.

+
+
+
+ + +
+ Actions +
+
+
+ +
+
+ +
diff --git a/app/portainer/components/forms/registry-form-dockerhub/registry-form-dockerhub.js b/app/portainer/components/forms/registry-form-dockerhub/registry-form-dockerhub.js new file mode 100644 index 000000000..83d62117b --- /dev/null +++ b/app/portainer/components/forms/registry-form-dockerhub/registry-form-dockerhub.js @@ -0,0 +1,9 @@ +angular.module('portainer.app').component('registryFormDockerhub', { + templateUrl: './registry-form-dockerhub.html', + bindings: { + model: '=', + formAction: '<', + formActionLabel: '@', + actionInProgress: '<' + } +}); diff --git a/app/portainer/views/registries/create/createRegistryController.js b/app/portainer/views/registries/create/createRegistryController.js index 404052515..8ddc4e1a7 100644 --- a/app/portainer/views/registries/create/createRegistryController.js +++ b/app/portainer/views/registries/create/createRegistryController.js @@ -5,6 +5,7 @@ angular.module('portainer.app') function ($scope, $state, RegistryService, Notifications) { $scope.selectQuayRegistry = selectQuayRegistry; + $scope.selectDockerHubRegistry = selectDockerHubRegistry; $scope.selectAzureRegistry = selectAzureRegistry; $scope.selectCustomRegistry = selectCustomRegistry; $scope.create = createRegistry; @@ -19,6 +20,12 @@ function ($scope, $state, RegistryService, Notifications) { $scope.model.Authentication = true; } + function selectDockerHubRegistry() { + $scope.model.Name = 'Docker Hub'; + $scope.model.URL = 'registry-1.docker.io'; + $scope.model.Authentication = true; + } + function selectAzureRegistry() { $scope.model.Name = ''; $scope.model.URL = ''; diff --git a/app/portainer/views/registries/create/createregistry.html b/app/portainer/views/registries/create/createregistry.html index fd6f33e43..9ecb62f14 100644 --- a/app/portainer/views/registries/create/createregistry.html +++ b/app/portainer/views/registries/create/createregistry.html @@ -48,6 +48,16 @@

Define your own registry

+
+ + +
@@ -72,6 +82,13 @@ action-in-progress="state.actionInProgress" > + +