Skip to content

Commit

Permalink
move info logic into helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
letFunny committed Sep 27, 2024
1 parent aaf70b1 commit 189a3bf
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions internal/archive/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down Expand Up @@ -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"),
}
}

0 comments on commit 189a3bf

Please sign in to comment.