feat(registry): dockerhub registry

pull/2987/head
xAt0mZ 2019-06-29 03:38:13 +02:00
parent 6591498ab9
commit f66f878803
6 changed files with 86 additions and 3 deletions

View File

@ -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
}

View File

@ -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 (

View File

@ -0,0 +1,48 @@
<form class="form-horizontal" name="registryFormDockerhub" ng-submit="$ctrl.formAction()">
<div class="col-sm-12 form-section-title">
Docker Hub registry details
</div>
<!-- credentials-user -->
<div class="form-group">
<label for="registry_username" class="col-sm-3 col-lg-2 control-label text-left">Username</label>
<div class="col-sm-9 col-lg-10">
<input type="text" class="form-control" id="registry_username" name="registry_username" ng-model="$ctrl.model.Username" required>
</div>
</div>
<div class="form-group" ng-show="registryFormDockerhub.registry_username.$invalid">
<div class="col-sm-12 small text-warning">
<div ng-messages="registryFormDockerhub.registry_username.$error">
<p ng-message="required"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> This field is required.</p>
</div>
</div>
</div>
<!-- !credentials-user -->
<!-- credentials-password -->
<div class="form-group">
<label for="registry_password" class="col-sm-3 col-lg-2 control-label text-left">Password</label>
<div class="col-sm-9 col-lg-10">
<input type="password" class="form-control" id="registry_password" name="registry_password" ng-model="$ctrl.model.Password" required>
</div>
</div>
<div class="form-group" ng-show="registryFormDockerhub.registry_password.$invalid">
<div class="col-sm-12 small text-warning">
<div ng-messages="registryFormDockerhub.registry_password.$error">
<p ng-message="required"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> This field is required.</p>
</div>
</div>
</div>
<!-- !credentials-password -->
<!-- actions -->
<div class="col-sm-12 form-section-title">
Actions
</div>
<div class="form-group">
<div class="col-sm-12">
<button type="submit" class="btn btn-primary btn-sm" ng-disabled="$ctrl.actionInProgress || !registryFormDockerhub.$valid" button-spinner="$ctrl.actionInProgress">
<span ng-hide="$ctrl.actionInProgress">{{ $ctrl.formActionLabel }}</span>
<span ng-show="$ctrl.actionInProgress">In progress...</span>
</button>
</div>
</div>
<!-- !actions -->
</form>

View File

@ -0,0 +1,9 @@
angular.module('portainer.app').component('registryFormDockerhub', {
templateUrl: './registry-form-dockerhub.html',
bindings: {
model: '=',
formAction: '<',
formActionLabel: '@',
actionInProgress: '<'
}
});

View File

@ -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 = '';

View File

@ -48,6 +48,16 @@
<p>Define your own registry</p>
</label>
</div>
<div ng-click="selectDockerHubRegistry()">
<input type="radio" id="registry-dockerhub" ng-model="model.Type" ng-value="4">
<label for="registry-dockerhub">
<div class="boxselector_header">
<i class="fab fa-docker" aria-hidden="true" style="margin-right: 2px;"></i>
Docker Hub
</div>
<p>Docker Hub registry</p>
</label>
</div>
</div>
</div>
@ -72,6 +82,13 @@
action-in-progress="state.actionInProgress"
></registry-form-custom>
<registry-form-dockerhub ng-if="model.Type === 4"
model="model"
form-action="create"
form-action-label="Add registry"
action-in-progress="state.actionInProgress"
></registry-form-dockerhub>
</form>
</rd-widget-body>
</rd-widget>