Merge pull request #72356 from vithati/users/vithati/kubectl505

Fix for kubectl go-template 'eq' & 'lt' not working with integers.
This commit is contained in:
Kubernetes Prow Robot 2019-01-07 12:09:25 -08:00 committed by GitHub
commit 3f2ef1417f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -20,6 +20,7 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/json:go_default_library",
"//staging/src/k8s.io/client-go/util/jsonpath:go_default_library",
"//vendor/sigs.k8s.io/yaml:go_default_library",
],

View File

@ -18,13 +18,13 @@ package printers
import (
"encoding/base64"
"encoding/json"
"fmt"
"io"
"reflect"
"text/template"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/json"
)
// GoTemplatePrinter is an implementation of ResourcePrinter which formats data with a Go Template.

View File

@ -52,6 +52,14 @@ func TestTemplate(t *testing.T) {
return "a base64 decode error", matched
},
},
{
name: "template 'eq' should not throw error for numbers",
template: "{{ eq .count 1}}",
obj: &v1.Event{
Count: 1,
},
expectOut: "true",
},
}
for _, test := range testCase {
t.Run(test.name, func(t *testing.T) {