From f32ebbc247a9684be73b793792ec11d3e0d5a211 Mon Sep 17 00:00:00 2001 From: Igor Shishkin Date: Sun, 12 Jan 2025 02:36:42 +0300 Subject: [PATCH] Use named type for object handler (#308) Signed-off-by: Igor Shishkin --- cli/service/source/local/local.go | 2 +- cli/service/source/mock/mock.go | 2 +- cli/service/source/source.go | 4 +++- cli/service/source/yum/yum.go | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cli/service/source/local/local.go b/cli/service/source/local/local.go index b15ce2b..4525721 100644 --- a/cli/service/source/local/local.go +++ b/cli/service/source/local/local.go @@ -42,7 +42,7 @@ func New(dir string, c cache.CacheRepository) source.Source { } } -func (l *local) Process(ctx context.Context, handler func(ctx context.Context, obj source.Object) error) error { +func (l *local) Process(ctx context.Context, handler source.ObjectHandler) error { log.WithFields(log.Fields{ "source_type": sourceType, "directory": l.dir, diff --git a/cli/service/source/mock/mock.go b/cli/service/source/mock/mock.go index 1481c4e..10e6e65 100644 --- a/cli/service/source/mock/mock.go +++ b/cli/service/source/mock/mock.go @@ -17,7 +17,7 @@ func New() *Mock { return &Mock{} } -func (m *Mock) Process(ctx context.Context, handler func(ctx context.Context, obj source.Object) error) error { +func (m *Mock) Process(ctx context.Context, handler source.ObjectHandler) error { args := m.Called() return args.Error(0) } diff --git a/cli/service/source/source.go b/cli/service/source/source.go index b199a08..0b0fc0b 100644 --- a/cli/service/source/source.go +++ b/cli/service/source/source.go @@ -13,6 +13,8 @@ type Object struct { MimeType string } +type ObjectHandler func(ctx context.Context, obj Object) error + type Source interface { - Process(ctx context.Context, handler func(ctx context.Context, obj Object) error) error + Process(ctx context.Context, handler ObjectHandler) error } diff --git a/cli/service/source/yum/yum.go b/cli/service/source/yum/yum.go index b57042f..5d14771 100644 --- a/cli/service/source/yum/yum.go +++ b/cli/service/source/yum/yum.go @@ -51,7 +51,7 @@ func New(repoURL string, rpmGPGKeyURL, rpmGPGKeySHA256 *string) source.Source { } } -func (r *repository) Process(ctx context.Context, handler func(ctx context.Context, obj source.Object) error) error { +func (r *repository) Process(ctx context.Context, handler source.ObjectHandler) error { log.WithFields(log.Fields{ "repository_url": r.repoURL, }).Info("running creating version from YUM repository ...")