Skip to content

Commit

Permalink
chore(service): fix returning wrong releases in pipeline payload
Browse files Browse the repository at this point in the history
  • Loading branch information
donch1989 committed Dec 12, 2023
1 parent 1187346 commit fa2ea87
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions pkg/service/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,11 @@ func (s *service) DBToPBPipeline(ctx context.Context, dbPipeline *datamodel.Pipe
pbPipeline.OpenapiSchema = spec
}
}
releases := []*pipelinePB.PipelineRelease{}
releases := []*datamodel.PipelineRelease{}
pageToken := ""
for {
var page []*pipelinePB.PipelineRelease
page, _, pageToken, err = s.ListPipelineReleasesAdmin(ctx, 100, pageToken, view, filtering.Filter{}, false)
var page []*datamodel.PipelineRelease
page, _, pageToken, err = s.repository.ListNamespacePipelineReleases(ctx, dbPipeline.Owner, dbPipeline.UID, 100, pageToken, false, filtering.Filter{}, false)
if err != nil {
return nil, err
}
Expand All @@ -503,7 +503,23 @@ func (s *service) DBToPBPipeline(ctx context.Context, dbPipeline *datamodel.Pipe
break
}
}
pbPipeline.Releases = releases

latestReleaseUID := uuid.Nil
defaultReleaseUID := uuid.Nil
latestRelease, err := s.repository.GetLatestNamespacePipelineRelease(ctx, dbPipeline.Owner, dbPipeline.UID, true)
if err == nil {
latestReleaseUID = latestRelease.UID
}
defaultRelease, err := s.repository.GetNamespacePipelineByID(ctx, dbPipeline.Owner, pbPipeline.Id, true)
if err == nil {
defaultReleaseUID = defaultRelease.UID
}

pbReleases, err := s.DBToPBPipelineReleases(ctx, releases, VIEW_FULL, latestReleaseUID, defaultReleaseUID)
if err != nil {
return nil, err
}
pbPipeline.Releases = pbReleases

return &pbPipeline, nil
}
Expand Down

0 comments on commit fa2ea87

Please sign in to comment.