Skip to content

Commit 477087c

Browse files
authored
chore: show validation error (#106)
Signed-off-by: Miguel Martinez Trivino <[email protected]>
1 parent 4893e30 commit 477087c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

app/controlplane/internal/service/ocirepository.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ func (s *OCIRepositoryService) Save(ctx context.Context, req *pb.OCIRepositorySe
5050
username := req.GetKeyPair().Username
5151
password := req.GetKeyPair().Password
5252

53-
// Create credentials
53+
// Create and validate credentials
5454
k, err := ociauth.NewCredentials(req.Repository, username, password)
5555
if err != nil {
56-
return nil, sl.LogAndMaskErr(err, s.log)
56+
return nil, errors.BadRequest("wrong credentials", err.Error())
5757
}
5858

5959
// Check credentials

internal/ociauth/auth.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package ociauth
1717

1818
import (
1919
"errors"
20+
"fmt"
2021

2122
"github.com/google/go-containerregistry/pkg/authn"
2223
"github.com/google/go-containerregistry/pkg/name"
@@ -31,7 +32,7 @@ type Credentials struct {
3132
func NewCredentials(repoURI, username, password string) (authn.Keychain, error) {
3233
repo, err := name.NewRepository(repoURI)
3334
if err != nil {
34-
return nil, err
35+
return nil, fmt.Errorf("invalid repository URI: %w", err)
3536
}
3637

3738
// NOTE: NewRepository parses incorrectly URIs with schemas

0 commit comments

Comments
 (0)