Skip to content

Commit

Permalink
Add ParsePackageIndexFromJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
cpanato committed Mar 7, 2024
1 parent 17cf392 commit 9218d6d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/apk/apk.go
Expand Up @@ -3,6 +3,7 @@ package apk
import (
"archive/tar"
"compress/gzip"
"encoding/json"
"fmt"
"io"
"log"
Expand Down Expand Up @@ -43,6 +44,18 @@ func (c Context) GetApkPackages() (map[string]*apk.Package, error) {
return ParseApkIndex(resp.Body)
}

func ParsePackageIndexFromJSON(jsonAPKLIndex []byte) (map[string]*apk.Package, error) {
var idx apk.APKIndex
wolfiPackages := make(map[string]*apk.Package)

err := json.Unmarshal(jsonAPKLIndex, &idx)
if err != nil {
return nil, err
}

return getLatestPackagesMap(idx.Packages, wolfiPackages)
}

func ParseUnpackedApkIndex(indexData io.ReadCloser) (map[string]*apk.Package, error) {
wolfiPackages := make(map[string]*apk.Package)

Expand Down

0 comments on commit 9218d6d

Please sign in to comment.