kubectl explain: ignore trailing period

kubectl explain ingress.spec.rules.http.paths. is valid
and defaults to kubectl explain ingress.spec.rules.http.paths

Rational: We use kubectl explain by adding fields
(e.g. service, then service.spec, then service.spec.ports ...)
so it's very easy to forget a trailing . at the end. We should
ignore the trailing period and display the result without it.
This commit is contained in:
Nikhita Raghunath
2017-11-01 19:04:36 +05:30
parent 28c483e161
commit 4add679528
4 changed files with 92 additions and 0 deletions

View File

@@ -30,6 +30,10 @@ type fieldsPrinter interface {
func splitDotNotation(model string) (string, []string) {
var fieldsPath []string
// ignore trailing period
model = strings.TrimSuffix(model, ".")
dotModel := strings.Split(model, ".")
if len(dotModel) >= 1 {
fieldsPath = dotModel[1:]