1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 15:59:41 +02:00

task(code): remove unnecessary uses of govalidator BE-11181 (#12156)
Some checks are pending
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:s390x platform:linux version:]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run

This commit is contained in:
andres-portainer 2024-08-28 19:37:20 -03:00 committed by GitHub
parent eb3e367ba8
commit 5353570721
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 79 additions and 106 deletions

View file

@ -11,8 +11,6 @@ import (
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/request"
"github.com/portainer/portainer/pkg/libhttp/response"
"github.com/asaskevich/govalidator"
)
type registryCreatePayload struct {
@ -46,19 +44,19 @@ type registryCreatePayload struct {
}
func (payload *registryCreatePayload) Validate(_ *http.Request) error {
if govalidator.IsNull(payload.Name) {
if len(payload.Name) == 0 {
return errors.New("Invalid registry name")
}
if govalidator.IsNull(payload.URL) {
if len(payload.URL) == 0 {
return errors.New("Invalid registry URL")
}
if payload.Authentication {
if govalidator.IsNull(payload.Username) || govalidator.IsNull(payload.Password) {
if len(payload.Username) == 0 || len(payload.Password) == 0 {
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) {
if len(payload.Ecr.Region) == 0 {
return errors.New("invalid credentials: access key ID, secret access key and region must be specified when authentication is enabled")
}
}