mirror of
https://github.com/harness/drone.git
synced 2025-05-05 15:32:56 +00:00
feat:[AH-1241]: fix for yarn package and delete tag issue for NPM (#3704)
* feat:[AH-1241]: fix for yarn package and delete tag issue for NPM * Merge branch 'main' of https://git0.harness.io/l7B_kbSEQD2wjrM7PShm5w/PROD/Harness_Commons/gitness * Merge branch 'main' of https://git0.harness.io/l7B_kbSEQD2wjrM7PShm5w/PROD/Harness_Commons/gitness * Merge branch 'release/registry-api_1.18.0' of https://git0.harness.io/l7B_kbSEQD2wjrM7PShm5w/PROD/Harness_Commons/gitness * feat:[AH-1083]: url fix (#3669) * feat:[AH-1083]: url fix
This commit is contained in:
parent
febd3e3fc9
commit
d361fc3f5a
@ -50,8 +50,9 @@ func (h *handler) DownloadPackageFile(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}()
|
||||
|
||||
if !commons.IsEmpty(response.GetError()) {
|
||||
if response.GetError() != nil {
|
||||
h.HandleError(r.Context(), w, response.GetError())
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Disposition", "attachment; filename="+info.Filename)
|
||||
|
@ -18,7 +18,6 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/harness/gitness/registry/app/pkg/commons"
|
||||
npm2 "github.com/harness/gitness/registry/app/pkg/types/npm"
|
||||
"github.com/harness/gitness/registry/request"
|
||||
|
||||
@ -44,8 +43,9 @@ func (h *handler) DownloadPackageFileByName(w http.ResponseWriter, r *http.Reque
|
||||
}
|
||||
}()
|
||||
|
||||
if !commons.IsEmpty(response.GetError()) {
|
||||
if response.GetError() != nil {
|
||||
h.HandleError(r.Context(), w, response.GetError())
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Disposition", "attachment; filename="+info.Filename)
|
||||
|
@ -90,12 +90,16 @@ func (h *handler) GetPackageArtifactInfo(r *http.Request) (pkg.PackageArtifactIn
|
||||
log.Info().Msgf("Invalid image name/version: %s/%s", info.Image, version)
|
||||
return nil, fmt.Errorf("invalid name or version")
|
||||
}
|
||||
distTags := r.PathValue("tag")
|
||||
|
||||
npmInfo := npm.ArtifactInfo{
|
||||
ArtifactInfo: info,
|
||||
Filename: fileName,
|
||||
Version: version,
|
||||
ArtifactInfo: info,
|
||||
Filename: fileName,
|
||||
Version: version,
|
||||
ParentRegIdentifier: info.RegIdentifier,
|
||||
DistTags: []string{distTags},
|
||||
}
|
||||
|
||||
if r.Body == nil || r.ContentLength == 0 {
|
||||
return npmInfo, nil
|
||||
}
|
||||
@ -136,10 +140,11 @@ func GetNPMMetadata(r *http.Request, info pkg.ArtifactInfo) (pkg.PackageArtifact
|
||||
|
||||
for _, meta := range md.Versions {
|
||||
a := npm.ArtifactInfo{
|
||||
ArtifactInfo: info,
|
||||
Metadata: md.PackageMetadata,
|
||||
Version: meta.Version,
|
||||
DistTags: make([]string, 0),
|
||||
ArtifactInfo: info,
|
||||
Metadata: md.PackageMetadata,
|
||||
Version: meta.Version,
|
||||
DistTags: make([]string, 0),
|
||||
ParentRegIdentifier: info.RegIdentifier,
|
||||
}
|
||||
for tag := range md.DistTags {
|
||||
a.DistTags = append(a.DistTags, tag)
|
||||
|
@ -93,7 +93,7 @@ func (r *proxy) GetPackageMetadata(ctx context.Context, info npm2.ArtifactInfo)
|
||||
if err != nil {
|
||||
return npm.PackageMetadata{}, err
|
||||
}
|
||||
regURL := r.urlProvider.PackageURL(ctx, info.RootIdentifier+"/"+info.RegIdentifier, "npm")
|
||||
regURL := r.urlProvider.PackageURL(ctx, info.RootIdentifier+"/"+info.ParentRegIdentifier, "npm")
|
||||
|
||||
versions := make(map[string]*npm.PackageMetadataVersion)
|
||||
for _, version := range result.Versions {
|
||||
|
@ -21,10 +21,11 @@ import (
|
||||
|
||||
type ArtifactInfo struct {
|
||||
pkg.ArtifactInfo
|
||||
Metadata npm.PackageMetadata
|
||||
Version string
|
||||
DistTags []string
|
||||
Filename string
|
||||
Metadata npm.PackageMetadata
|
||||
Version string
|
||||
DistTags []string
|
||||
Filename string
|
||||
ParentRegIdentifier string
|
||||
}
|
||||
|
||||
type File struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user