Skip to content

Commit

Permalink
feat: support projectTags and isLatest flags for bom uploads
Browse files Browse the repository at this point in the history
Signed-off-by: nscuro <[email protected]>
  • Loading branch information
nscuro committed Oct 27, 2024
1 parent 096b70c commit 85997f7
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions bom.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/google/uuid"
"net/http"
"net/url"
"strings"
)

type BOMService struct {
Expand All @@ -16,9 +17,11 @@ type BOMUploadRequest struct {
ProjectUUID *uuid.UUID `json:"project,omitempty"`
ProjectName string `json:"projectName,omitempty"`
ProjectVersion string `json:"projectVersion,omitempty"`
ParentUUID *uuid.UUID `json:"parentUUID,omitempty"` // Since v4.8.0
ParentName string `json:"parentName,omitempty"` // Since v4.8.0
ParentVersion string `json:"parentVersion,omitempty"` // Since v4.8.0
ProjectTags []Tag `json:"projectTags,omitempty"` // Since v4.12.0
ParentUUID *uuid.UUID `json:"parentUUID,omitempty"` // Since v4.8.0
ParentName string `json:"parentName,omitempty"` // Since v4.8.0
ParentVersion string `json:"parentVersion,omitempty"` // Since v4.8.0
IsLatest bool `json:"isLatestProjectVersion,omitempty"` // Since v4.12.0
AutoCreate bool `json:"autoCreate"`
BOM string `json:"bom"`
}
Expand Down Expand Up @@ -111,6 +114,16 @@ func (bs BOMService) PostBom(ctx context.Context, uploadReq BOMUploadRequest) (t
if uploadReq.ProjectVersion != "" {
params["projectVersion"] = append(params["projectVersion"], uploadReq.ProjectVersion)
}
if len(uploadReq.ProjectTags) > 0 {
tagNames := make([]string, len(uploadReq.ProjectTags))
for i := range uploadReq.ProjectTags {
tagNames[i] = uploadReq.ProjectTags[i].Name
}
params["projectTags"] = append(params["projectTags"], strings.Join(tagNames, ","))
}
if uploadReq.IsLatest {
params["isLatest"] = append(params["isLatest"], "true")
}
if uploadReq.ParentUUID != nil {
params["parentUUID"] = append(params["parentUUID"], uploadReq.ParentUUID.String())
}
Expand Down

0 comments on commit 85997f7

Please sign in to comment.