Handle some incorrect type values like 'int' and 'bool' in setters

This commit is contained in:
Morten Torkildsen
2020-07-28 13:49:07 -07:00
parent 9ba04e3f7d
commit de0c8dedc4
2 changed files with 90 additions and 0 deletions

View File

@@ -666,6 +666,68 @@ spec:
- "1"
- "2"
- "3"
`,
},
{
name: "set-with-invalid-type-int",
description: "if a type is set to int instead of integer, we accept it",
setter: "foo",
openapi: `
openAPI:
definitions:
io.k8s.cli.setters.foo:
x-k8s-cli:
setter:
name: foo
value: "4"
type: int
`,
input: `
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
annotations:
foo: 3 # {"$ref": "#/definitions/io.k8s.cli.setters.foo"}
`,
expected: `
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
annotations:
foo: 4 # {"$ref": "#/definitions/io.k8s.cli.setters.foo"}
`,
},
{
name: "set-with-invalid-type-bool",
description: "if a type is set to bool instead of boolean, we accept it",
setter: "foo",
openapi: `
openAPI:
definitions:
io.k8s.cli.setters.foo:
x-k8s-cli:
setter:
name: foo
value: "true"
type: bool
`,
input: `
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
annotations:
foo: false # {"$ref": "#/definitions/io.k8s.cli.setters.foo"}
`,
expected: `
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
annotations:
foo: true # {"$ref": "#/definitions/io.k8s.cli.setters.foo"}
`,
},
}