Skip to content

Commit

Permalink
kie-kogito-serverless-operator-335: Operator driven service discovery…
Browse files Browse the repository at this point in the history
… API Phase4

    - Augment the service uri query parameters
  • Loading branch information
wmedvede committed Jan 15, 2024
1 parent e61e0e4 commit 0dd922d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
11 changes: 7 additions & 4 deletions controllers/discovery/uri_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ import (

const (
// valid namespace, name, or label name.
dns1123LabelFmt string = "[a-z0-9]([-a-z0-9]*[a-z0-9])?"
namespaceAndNamePattern = "^/((" + dns1123LabelFmt + ")+)(/(" + dns1123LabelFmt + ")+)?"
queryStringPattern = "^(\\?((" + dns1123LabelFmt + ")+\\=(" + dns1123LabelFmt + ")+)" +
"(&(" + dns1123LabelFmt + ")+\\=(" + dns1123LabelFmt + ")+)*)?$"
dns1123LabelFmt string = "[a-z0-9]([-a-z0-9]*[a-z0-9])?"
queryParamName = "[a-zA-Z0-9][-a-zAz0-9]*"
queryParamValue = "[/a-zA-Z0-9][/-a-zAz0-9]*"

namespaceAndNamePattern = "^/((" + dns1123LabelFmt + ")+)(/(" + dns1123LabelFmt + ")+)?"
queryStringPattern = "^(\\?((" + queryParamName + ")+\\=(" + queryParamValue + ")+)" +
"(&(" + queryParamName + ")+\\=(" + queryParamValue + ")+)*)?$"

kubernetesGroupsPattern = "^(" + kubernetesServices +
"|" + kubernetesPods +
Expand Down
8 changes: 8 additions & 0 deletions controllers/discovery/uri_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ var KnativeServicesTestValues = map[string]*ResourceUri{
WithQueryParam("label-a", "value-a").
WithQueryParam("label-b", "value-b").
WithPort("custom-port-value").Build(),

"knative:services.v1.serving.knative.dev/my-namespace/my-function?path=/myKnativeFunction": NewResourceUriBuilder(KnativeScheme).
Kind("services").
Version("v1").
Group("serving.knative.dev").
Namespace("my-namespace").
Name("my-function").
WithQueryParam("path", "/myKnativeFunction").Build(),
}

var KnativeBrokersTestValues = map[string]*ResourceUri{
Expand Down
4 changes: 2 additions & 2 deletions controllers/profiles/common/properties/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ func Test_generateDiscoveryProperties(t *testing.T) {
Functions: []model.Function{
{
Name: "knServiceInvocation1",
Operation: "knative:services.v1.serving.knative.dev/namespace1/my-kn-service1?path=knative-function1",
Operation: "knative:services.v1.serving.knative.dev/namespace1/my-kn-service1?path=/knative-function1",
},
{
Name: "knServiceInvocation2",
Operation: "knative:services.v1.serving.knative.dev/my-kn-service3?path=knative-function3",
Operation: "knative:services.v1.serving.knative.dev/my-kn-service3?path=/knative-function3",
},
},
}
Expand Down

0 comments on commit 0dd922d

Please sign in to comment.