Skip to content

Commit

Permalink
fix(KFLUXBUGS-1754): rp shouldn't show matched if RPA doesn't exist
Browse files Browse the repository at this point in the history
This commit fixes the loader function to return nil instead of an empty
RPA if the RPA specified in the RP label does not exist.

Signed-off-by: Johnny Bieren <[email protected]>
  • Loading branch information
johnbieren committed Oct 22, 2024
1 parent a103042 commit 5486574
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ func (l *loader) GetMatchingReleasePlanAdmission(ctx context.Context, cli client

if designatedReleasePlanAdmissionName != "" {
releasePlanAdmission := &v1alpha1.ReleasePlanAdmission{}
return releasePlanAdmission, toolkit.GetObject(designatedReleasePlanAdmissionName, releasePlan.Spec.Target, cli, ctx, releasePlanAdmission)
err := toolkit.GetObject(designatedReleasePlanAdmissionName, releasePlan.Spec.Target, cli, ctx, releasePlanAdmission)
if err != nil {
return nil, err
}
return releasePlanAdmission, nil

Check warning on line 124 in loader/loader.go

View check run for this annotation

Codecov / codecov/patch

loader/loader.go#L124

Added line #L124 was not covered by tests
}

if releasePlan.Spec.Target == "" {
Expand Down
2 changes: 1 addition & 1 deletion loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ var _ = Describe("Release Adapter", Ordered, func() {
returnedObject, err := loader.GetMatchingReleasePlanAdmission(ctx, k8sClient, modifiedReleasePlan)
Expect(err).To(HaveOccurred())
Expect(errors.IsNotFound(err)).To(BeTrue())
Expect(returnedObject).To(Equal(&v1alpha1.ReleasePlanAdmission{}))
Expect(returnedObject).To(BeNil())
})

It("fails to return a release plan admission if the target does not match", func() {
Expand Down

0 comments on commit 5486574

Please sign in to comment.