Skip to content

Commit

Permalink
Merge pull request #583 from happybhati/release-1105
Browse files Browse the repository at this point in the history
  • Loading branch information
happybhati authored Oct 16, 2024
2 parents e091a3b + fc70fe4 commit bd73069
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ func (l *loader) GetMatchingReleasePlanAdmission(ctx context.Context, cli client
// are in the namespace specified by the ReleasePlanAdmission's origin. If the List operation fails, an
// error will be returned.
func (l *loader) GetMatchingReleasePlans(ctx context.Context, cli client.Client, releasePlanAdmission *v1alpha1.ReleasePlanAdmission) (*v1alpha1.ReleasePlanList, error) {

if releasePlanAdmission.Spec.Origin == "" {
return nil, fmt.Errorf("releasePlanAdmission has no origin, so no ReleasePlans can be found")
}

releasePlans := &v1alpha1.ReleasePlanList{}
err := cli.List(ctx, releasePlans,
client.InNamespace(releasePlanAdmission.Spec.Origin),
Expand Down
10 changes: 10 additions & 0 deletions loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,16 @@ var _ = Describe("Release Adapter", Ordered, func() {
return returnedObject != &v1alpha1.ReleasePlanList{} && err == nil && contains == false
})
})

It("fails to return release plans if origin is empty", func() {
modifiedReleasePlanAdmission := releasePlanAdmission.DeepCopy()
modifiedReleasePlanAdmission.Spec.Origin = ""

returnedObject, err := loader.GetMatchingReleasePlans(ctx, k8sClient, modifiedReleasePlanAdmission)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("releasePlanAdmission has no origin, so no ReleasePlans can be found"))
Expect(returnedObject).To(BeNil())
})
})

When("calling GetPreviousRelease", func() {
Expand Down

0 comments on commit bd73069

Please sign in to comment.