Skip to content

Commit

Permalink
Merge pull request #20774 from eriknelson/bz1609676
Browse files Browse the repository at this point in the history
Bug 1609676 - Fix missing bind values regression
  • Loading branch information
openshift-merge-robot authored Aug 28, 2018
2 parents 49341c4 + 2b48b4e commit ae86f05
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/templateservicebroker/servicebroker/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
func evaluateJSONPathExpression(obj interface{}, annotation, expression string, base64encode bool) (string, error) {
var s []string

j := jsonpath.New("templateservicebroker")
j := jsonpath.New("templateservicebroker").AllowMissingKeys(true)
err := j.Parse(expression)
if err != nil {
return "", fmt.Errorf("failed to parse annotation %s: %v", annotation, err)
Expand All @@ -44,7 +44,15 @@ func evaluateJSONPathExpression(obj interface{}, annotation, expression string,
return "", fmt.Errorf("FindResults failed on annotation %s: %v", annotation, err)
}

// strip away empty results that represent lookups that were not found
strippedResults := [][]reflect.Value{}
for _, r := range results {
if len(r) != 0 {
strippedResults = append(strippedResults, r)
}
}

for _, r := range strippedResults {
// we don't permit individual JSONPath expressions which return multiple
// objects as we haven't decided how these should be output
if len(r) != 1 {
Expand Down
4 changes: 4 additions & 0 deletions pkg/templateservicebroker/servicebroker/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ func TestEvaluateJSONPathExpression(t *testing.T) {
expression: "{.DoesntExist}",
expectedError: "FindResults failed on annotation a: DoesntExist is not found",
},
{
expression: "http://{.String}/{.DoesntExist}",
expectedResult: "http://teststring/",
},
{
expression: "{.IntSlice[*]}",
expectedError: "3 JSONPath results found on annotation a",
Expand Down

0 comments on commit ae86f05

Please sign in to comment.