Factor out API defaulting from validation logic
Currently, the validation logic validates fields in an object and supply default values wherever applies. This change factors out defaulting to a set of defaulting callback functions for decoding (see #1502 for more discussion). * This change is based on pull request 2587. * Most defaulting has been migrated to defaults.go where the defaulting functions are added. * validation_test.go and converter_test.go have been adapted to not testing the default values. * Fixed all tests with that create invalid objects with the absence of defaulting logic.
This commit is contained in:
@@ -103,18 +103,17 @@ var invalidPod2 = `{
|
||||
"manifest": {
|
||||
"version": "v1beta1",
|
||||
"id": "apache-php",
|
||||
"containers": [
|
||||
{
|
||||
"name": "apache-php",
|
||||
"image": "php:5.6.2-apache",
|
||||
"ports": [{ "name": "apache", "containerPort": 80, "hostPort":"13380", "protocol":"TCP" }],
|
||||
"volumeMounts": [{"name": "shared-disk","mountPath": "/var/www/html", "readOnly": false}]
|
||||
}
|
||||
]
|
||||
"containers": [{
|
||||
"name": "apache-php",
|
||||
"image": "php:5.6.2-apache",
|
||||
"ports": [{ "name": "apache", "containerPort": 80, "hostPort":"13380", "protocol":"TCP" }],
|
||||
"volumeMounts": [{"name": "shared-disk","mountPath": "/var/www/html", "readOnly": false}]
|
||||
}]
|
||||
}
|
||||
},
|
||||
"labels": { "name": "apache-php" },
|
||||
"restartPolicy": {"always": {}},
|
||||
"dnsPolicy": "ClusterFirst",
|
||||
"volumes": [
|
||||
"name": "shared-disk",
|
||||
"source": {
|
||||
@@ -134,18 +133,17 @@ var invalidPod3 = `{
|
||||
"manifest": {
|
||||
"version": "v1beta1",
|
||||
"id": "apache-php",
|
||||
"containers": [
|
||||
{
|
||||
"name": "apache-php",
|
||||
"image": "php:5.6.2-apache",
|
||||
"ports": [{ "name": "apache", "containerPort": 80, "hostPort":"13380", "protocol":"TCP" }],
|
||||
"volumeMounts": [{"name": "shared-disk","mountPath": "/var/www/html", "readOnly": false}]
|
||||
}
|
||||
]
|
||||
"containers": [{
|
||||
"name": "apache-php",
|
||||
"image": "php:5.6.2-apache",
|
||||
"ports": [{ "name": "apache", "containerPort": 80, "hostPort":"13380", "protocol":"TCP" }],
|
||||
"volumeMounts": [{"name": "shared-disk","mountPath": "/var/www/html", "readOnly": false}]
|
||||
}]
|
||||
}
|
||||
},
|
||||
"labels": { "name": "apache-php" },
|
||||
"restartPolicy": {"always": {}},
|
||||
"dnsPolicy": "ClusterFirst",
|
||||
"volumes": [
|
||||
{
|
||||
"name": "shared-disk",
|
||||
|
Reference in New Issue
Block a user