Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(service): fix returning wrong releases in pipeline payload #327

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading