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

Commit

Permalink
Add FormatPackageURL public helper
Browse files Browse the repository at this point in the history
  • Loading branch information
neomantra committed Nov 22, 2021
1 parent 42bf3d9 commit 260e7db
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions generic_packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,23 @@ type GenericPackagesFile struct {
NewFilePath string `json:"new_file_path"`
}

// FormatPackageURL returns the GitLab Package Registry URL for the given artifact metadata, without the BaseURL.
// This does not make a GitLab API request, but rather computes it based on their documentation.
func (s *GenericPackagesService) FormatPackageURL(pid interface{}, packageName, packageVersion, fileName string) (string, error) {
project, err := parseID(pid)
if err != nil {
return "", err
}
u := fmt.Sprintf(
"projects/%s/packages/generic/%s/%s/%s",
pathEscape(project),
pathEscape(packageName),
pathEscape(packageVersion),
pathEscape(fileName),
)
return u, nil
}

// PublishPackageFileOptions represents the available PublishPackageFile()
// options.
//
Expand Down

0 comments on commit 260e7db

Please sign in to comment.