Merge pull request #51321 from mengqiy/kubectl_apply_openapi

Automatic merge from submit-queue (batch tested with PRs 51321, 55969, 55039, 56183, 55976). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Kubectl apply and strategic merge patch using openapi

- [x] support openapi in strategic merge patch
- [x] test openapi in strategic merge patch
- [x] kubectl apply use openapi to calculate diff be default. It will fall back to use baked-in types when openapi is not available.
- [x] test openapi in kubectl apply

Fixes: kubernetes/kubectl#55

```release-note
kubectl apply use openapi to calculate diff be default. It will fall back to use baked-in types when openapi is not available.
```

/assign @apelisse

Kubernetes-commit: e412ad5393b8c949474b904616fc411c3aa478a9
This commit is contained in:
Kubernetes Publisher
2017-11-22 11:59:49 -08:00
18 changed files with 3058 additions and 1416 deletions
+3 -6
View File
@@ -26,17 +26,14 @@ const (
// struct field given the struct type and the JSON name of the field.
// It returns field type, a slice of patch strategies, merge key and error.
// TODO: fix the returned errors to be introspectable.
func LookupPatchMetadata(t reflect.Type, jsonField string) (
func LookupPatchMetadataForStruct(t reflect.Type, jsonField string) (
elemType reflect.Type, patchStrategies []string, patchMergeKey string, e error) {
if t.Kind() == reflect.Ptr {
t = t.Elem()
}
if t.Kind() == reflect.Map {
elemType = t.Elem()
return
}
if t.Kind() != reflect.Struct {
e = fmt.Errorf("merging an object in json but data type is not map or struct, instead is: %s",
e = fmt.Errorf("merging an object in json but data type is not struct, instead is: %s",
t.Kind().String())
return
}