-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable service plan filtering by offering guid
Co-authored-by: Georgi Sabev <[email protected]>
- Loading branch information
1 parent
ff8c0b2
commit e27b5c9
Showing
9 changed files
with
164 additions
and
19 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -428,6 +428,7 @@ func main() { | |
), | ||
handlers.NewServicePlan( | ||
*serverURL, | ||
requestValidator, | ||
servicePlanRepo, | ||
), | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package payloads | ||
|
||
import ( | ||
"net/url" | ||
"regexp" | ||
|
||
"code.cloudfoundry.org/korifi/api/payloads/parse" | ||
"code.cloudfoundry.org/korifi/api/repositories" | ||
) | ||
|
||
type ServicePlanList struct { | ||
ServiceOfferingGUIDs string | ||
} | ||
|
||
func (l *ServicePlanList) ToMessage() repositories.ListServicePlanMessage { | ||
return repositories.ListServicePlanMessage{ | ||
ServiceOfferingGUIDs: parse.ArrayParam(l.ServiceOfferingGUIDs), | ||
} | ||
} | ||
|
||
func (l *ServicePlanList) SupportedKeys() []string { | ||
return []string{"service_offering_guids", "page", "per_page"} | ||
} | ||
|
||
func (l *ServicePlanList) IgnoredKeys() []*regexp.Regexp { | ||
return []*regexp.Regexp{regexp.MustCompile(`fields\[.+\]`)} | ||
} | ||
|
||
func (l *ServicePlanList) DecodeFromURLValues(values url.Values) error { | ||
l.ServiceOfferingGUIDs = values.Get("service_offering_guids") | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package payloads_test | ||
|
||
import ( | ||
"code.cloudfoundry.org/korifi/api/payloads" | ||
"code.cloudfoundry.org/korifi/api/repositories" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("ServicePlan", func() { | ||
DescribeTable("valid query", | ||
func(query string, expectedServicePlanList payloads.ServicePlanList) { | ||
actualServicePlanList, decodeErr := decodeQuery[payloads.ServicePlanList](query) | ||
|
||
Expect(decodeErr).NotTo(HaveOccurred()) | ||
Expect(*actualServicePlanList).To(Equal(expectedServicePlanList)) | ||
}, | ||
Entry("service_offering_guids", "service_offering_guids=b1,b2", payloads.ServicePlanList{ServiceOfferingGUIDs: "b1,b2"}), | ||
) | ||
|
||
Describe("ToMessage", func() { | ||
It("converts payload to repository message", func() { | ||
payload := &payloads.ServicePlanList{ServiceOfferingGUIDs: "b1,b2"} | ||
|
||
Expect(payload.ToMessage()).To(Equal(repositories.ListServicePlanMessage{ | ||
ServiceOfferingGUIDs: []string{"b1", "b2"}, | ||
})) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters