feat(actions): simplify macro parsing (#560)

* refactor(action): parse macros

* feat(action): add ctx to arr clients and test
This commit is contained in:
ze0s 2022-12-10 21:48:19 +01:00 committed by GitHub
parent f6e68fae2b
commit 839eb9f3f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 323 additions and 334 deletions

View file

@ -2,7 +2,6 @@ package download_client
import (
"context"
"errors"
"log"
"sync"
@ -69,11 +68,9 @@ func (s *service) FindByID(ctx context.Context, id int32) (*domain.DownloadClien
}
func (s *service) Store(ctx context.Context, client domain.DownloadClient) (*domain.DownloadClient, error) {
// validate data
if client.Host == "" {
return nil, errors.New("validation error: no host")
} else if client.Type == "" {
return nil, errors.New("validation error: no type")
// basic validation of client
if err := client.Validate(); err != nil {
return nil, err
}
// store
@ -87,11 +84,9 @@ func (s *service) Store(ctx context.Context, client domain.DownloadClient) (*dom
}
func (s *service) Update(ctx context.Context, client domain.DownloadClient) (*domain.DownloadClient, error) {
// validate data
if client.Host == "" {
return nil, errors.New("validation error: no host")
} else if client.Type == "" {
return nil, errors.New("validation error: no type")
// basic validation of client
if err := client.Validate(); err != nil {
return nil, err
}
// update
@ -125,10 +120,8 @@ func (s *service) Delete(ctx context.Context, clientID int) error {
func (s *service) Test(ctx context.Context, client domain.DownloadClient) error {
// basic validation of client
if client.Host == "" {
return errors.New("validation error: no host")
} else if client.Type == "" {
return errors.New("validation error: no type")
if err := client.Validate(); err != nil {
return err
}
// test