From 189a3bf3b9738baa19e3283a8869d64c05f442cb Mon Sep 17 00:00:00 2001 From: Alberto Carretero Date: Fri, 27 Sep 2024 14:51:38 +0200 Subject: [PATCH] move info logic into helper function --- internal/archive/archive.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/internal/archive/archive.go b/internal/archive/archive.go index f208d967..c09fbdfb 100644 --- a/internal/archive/archive.go +++ b/internal/archive/archive.go @@ -131,12 +131,7 @@ func (a *ubuntuArchive) Fetch(pkg string) (io.ReadCloser, *PackageInfo, error) { if err != nil { return nil, nil, err } - info := &PackageInfo{ - Name: section.Get("Package"), - Version: section.Get("Version"), - Arch: section.Get("Architecture"), - SHA256: section.Get("SHA256"), - } + info := sectionPackageInfo(section) return reader, info, nil } @@ -145,12 +140,7 @@ func (a *ubuntuArchive) Info(pkg string) (*PackageInfo, error) { if err != nil { return nil, err } - info := &PackageInfo{ - Name: section.Get("Package"), - Version: section.Get("Version"), - Arch: section.Get("Architecture"), - SHA256: section.Get("SHA256"), - } + info := sectionPackageInfo(section) return info, nil } @@ -364,3 +354,12 @@ func (index *ubuntuIndex) fetch(suffix, digest string, flags fetchFlags) (io.Rea return index.archive.cache.Open(writer.Digest()) } + +func sectionPackageInfo(section control.Section) *PackageInfo { + return &PackageInfo{ + Name: section.Get("Package"), + Version: section.Get("Version"), + Arch: section.Get("Architecture"), + SHA256: section.Get("SHA256"), + } +}