mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
feat(registry) EE-806 add support for AWS ECR (#6165)
* feat(ecr) EE-806 add support for aws ecr * feat(ecr) EE-806 fix wrong doc for Ecr Region Co-authored-by: Simon Meng <simon.meng@portainer.io>
This commit is contained in:
parent
ff6185cc81
commit
a86c7046df
29 changed files with 694 additions and 51 deletions
|
@ -17,8 +17,15 @@ import (
|
|||
type registryCreatePayload struct {
|
||||
// Name that will be used to identify this registry
|
||||
Name string `example:"my-registry" validate:"required"`
|
||||
// Registry Type. Valid values are: 1 (Quay.io), 2 (Azure container registry), 3 (custom registry), 4 (Gitlab registry), 5 (ProGet registry) or 6 (DockerHub)
|
||||
Type portainer.RegistryType `example:"1" validate:"required" enums:"1,2,3,4,5,6"`
|
||||
// Registry Type. Valid values are:
|
||||
// 1 (Quay.io),
|
||||
// 2 (Azure container registry),
|
||||
// 3 (custom registry),
|
||||
// 4 (Gitlab registry),
|
||||
// 5 (ProGet registry),
|
||||
// 6 (DockerHub)
|
||||
// 7 (ECR)
|
||||
Type portainer.RegistryType `example:"1" validate:"required" enums:"1,2,3,4,5,6,7"`
|
||||
// URL or IP address of the Docker registry
|
||||
URL string `example:"registry.mydomain.tld:2375/feed" validate:"required"`
|
||||
// BaseURL required for ProGet registry
|
||||
|
@ -33,6 +40,8 @@ type registryCreatePayload struct {
|
|||
Gitlab portainer.GitlabRegistryData
|
||||
// Quay specific details, required when type = 1
|
||||
Quay portainer.QuayRegistryData
|
||||
// ECR specific details, required when type = 7
|
||||
Ecr portainer.EcrData
|
||||
}
|
||||
|
||||
func (payload *registryCreatePayload) Validate(_ *http.Request) error {
|
||||
|
@ -42,14 +51,22 @@ func (payload *registryCreatePayload) Validate(_ *http.Request) error {
|
|||
if govalidator.IsNull(payload.URL) {
|
||||
return errors.New("Invalid registry URL")
|
||||
}
|
||||
if payload.Authentication && (govalidator.IsNull(payload.Username) || govalidator.IsNull(payload.Password)) {
|
||||
return errors.New("Invalid credentials. Username and password must be specified when authentication is enabled")
|
||||
|
||||
if payload.Authentication {
|
||||
if govalidator.IsNull(payload.Username) || govalidator.IsNull(payload.Password) {
|
||||
return errors.New("Invalid credentials. Username and password must be specified when authentication is enabled")
|
||||
}
|
||||
if payload.Type == portainer.EcrRegistry {
|
||||
if govalidator.IsNull(payload.Ecr.Region) {
|
||||
return errors.New("invalid credentials: access key ID, secret access key and region must be specified when authentication is enabled")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch payload.Type {
|
||||
case portainer.QuayRegistry, portainer.AzureRegistry, portainer.CustomRegistry, portainer.GitlabRegistry, portainer.ProGetRegistry, portainer.DockerHubRegistry:
|
||||
case portainer.QuayRegistry, portainer.AzureRegistry, portainer.CustomRegistry, portainer.GitlabRegistry, portainer.ProGetRegistry, portainer.DockerHubRegistry, portainer.EcrRegistry:
|
||||
default:
|
||||
return errors.New("invalid registry type. Valid values are: 1 (Quay.io), 2 (Azure container registry), 3 (custom registry), 4 (Gitlab registry), 5 (ProGet registry) or 6 (DockerHub)")
|
||||
return errors.New("invalid registry type. Valid values are: 1 (Quay.io), 2 (Azure container registry), 3 (custom registry), 4 (Gitlab registry), 5 (ProGet registry), 6 (DockerHub), 7 (ECR)")
|
||||
}
|
||||
|
||||
if payload.Type == portainer.ProGetRegistry && payload.BaseURL == "" {
|
||||
|
@ -96,9 +113,10 @@ func (handler *Handler) registryCreate(w http.ResponseWriter, r *http.Request) *
|
|||
Authentication: payload.Authentication,
|
||||
Username: payload.Username,
|
||||
Password: payload.Password,
|
||||
RegistryAccesses: portainer.RegistryAccesses{},
|
||||
Gitlab: payload.Gitlab,
|
||||
Quay: payload.Quay,
|
||||
RegistryAccesses: portainer.RegistryAccesses{},
|
||||
Ecr: payload.Ecr,
|
||||
}
|
||||
|
||||
registries, err := handler.DataStore.Registry().Registries()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue