kubectl config set hangs on some invalid property names #415

This commit is contained in:
Peter Swica 2019-06-07 01:13:40 -04:00
parent 333081e79c
commit ae386f3143
2 changed files with 14 additions and 0 deletions

View File

@ -76,6 +76,8 @@ func newNavigationSteps(path string) (*navigationSteps, error) {
steps = append(steps, navigationStep{nextPart, fieldType}) steps = append(steps, navigationStep{nextPart, fieldType})
currPartIndex += len(strings.Split(nextPart, ".")) currPartIndex += len(strings.Split(nextPart, "."))
currType = fieldType currType = fieldType
default:
return nil, fmt.Errorf("unable to parse one or more field values of %v", path)
} }
} }

View File

@ -72,6 +72,18 @@ func TestParseWithBadValue(t *testing.T) {
test.run(t) test.run(t)
} }
func TestParseWithNoMatchingValue(t *testing.T) {
test := stepParserTest{
path: "users.jheiss.exec.command",
expectedNavigationSteps: navigationSteps{
steps: []navigationStep{},
},
expectedError: "unable to parse one or more field values of users.jheiss.exec",
}
test.run(t)
}
func (test stepParserTest) run(t *testing.T) { func (test stepParserTest) run(t *testing.T) {
actualSteps, err := newNavigationSteps(test.path) actualSteps, err := newNavigationSteps(test.path)
if len(test.expectedError) != 0 { if len(test.expectedError) != 0 {