Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Add support for SHA256 in PackageFile
Browse files Browse the repository at this point in the history
This information is needed when trying to directly download Pypi packages.
Check https://docs.gitlab.com/ee/api/packages/pypi.html#download-a-package-file-from-a-project
  • Loading branch information
gbonnefille committed Mar 19, 2024
1 parent 8f2dbc2 commit 7f507c0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
15 changes: 8 additions & 7 deletions packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,14 @@ func (s PackageTag) String() string {
//
// GitLab API docs: https://docs.gitlab.com/ee/api/packages.html
type PackageFile struct {
ID int `json:"id"`
PackageID int `json:"package_id"`
CreatedAt *time.Time `json:"created_at"`
FileName string `json:"file_name"`
Size int `json:"size"`
FileMD5 string `json:"file_md5"`
FileSHA1 string `json:"file_sha1"`
ID int `json:"id"`
PackageID int `json:"package_id"`
CreatedAt *time.Time `json:"created_at"`
FileName string `json:"file_name"`
Size int `json:"size"`
FileMD5 string `json:"file_md5"`
FileSHA1 string `json:"file_sha1,omitempty"`
FileSHA256 string `json:"file_sha256,omitempty"`
Pipeline *[]Pipeline `json:"pipelines"`
}

Expand Down
13 changes: 7 additions & 6 deletions packages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,13 @@ func TestPackagesService_ListPackageFiles(t *testing.T) {
})

want := []*PackageFile{{
ID: 25,
PackageID: 4,
FileName: "my-app-1.5-20181107.152550-1.jar",
Size: 2421,
FileMD5: "58e6a45a629910c6ff99145a688971ac",
FileSHA1: "ebd193463d3915d7e22219f52740056dfd26cbfe",
ID: 25,
PackageID: 4,
FileName: "my-app-1.5-20181107.152550-1.jar",
Size: 2421,
FileMD5: "58e6a45a629910c6ff99145a688971ac",
FileSHA1: "ebd193463d3915d7e22219f52740056dfd26cbfe",
FileSHA256: "a903393463d3915d7e22219f52740056dfd26cbfeff321b",
}}

ps, resp, err := client.Packages.ListPackageFiles(3, 4, nil)
Expand Down

0 comments on commit 7f507c0

Please sign in to comment.