code review: remove obsolete commented code

Signed-off-by: Steve Kriss <krisss@vmware.com>
pull/1146/head
Steve Kriss 2019-01-09 14:31:04 -07:00
parent 250f109c41
commit 86c5c25d13
2 changed files with 0 additions and 187 deletions

View File

@ -97,159 +97,3 @@ func (a *podAction) Execute(obj runtime.Unstructured, restore *api.Restore) (run
return &unstructured.Unstructured{Object: res}, nil, nil
}
// func (a *podAction) Execute(obj runtime.Unstructured, restore *api.Restore) (runtime.Unstructured, error, error) {
// unstructured.RemoveNestedField(obj.UnstructuredContent(), "spec", "nodeName")
// unstructured.RemoveNestedField(obj.UnstructuredContent(), "spec", "priority")
// // if there are no volumes, then there can't be any volume mounts, so we're done.
// res, found, err := unstructured.NestedFieldNoCopy(obj.UnstructuredContent(), "spec", "volumes")
// if err != nil {
// return nil, nil, errors.WithStack(err)
// }
// if !found {
// return obj, nil, nil
// }
// volumes, ok := res.([]interface{})
// if !ok {
// return nil, nil, errors.Errorf("unexpected type for .spec.volumes %T", res)
// }
// serviceAccountName, found, err := unstructured.NestedString(obj.UnstructuredContent(), "spec", "serviceAccountName")
// if err != nil {
// return nil, nil, errors.WithStack(err)
// }
// if !found {
// return nil, nil, errors.New(".spec.serviceAccountName not found")
// }
// prefix := serviceAccountName + "-token-"
// var preservedVolumes []interface{}
// for _, obj := range volumes {
// volume, ok := obj.(map[string]interface{})
// if !ok {
// return nil, nil, errors.Errorf("unexpected type for volume %T", obj)
// }
// name, found, err := unstructured.NestedString(volume, "name")
// if err != nil {
// return nil, nil, errors.WithStack(err)
// }
// if !found {
// return nil, nil, errors.New("no name found for volume")
// }
// if !strings.HasPrefix(name, prefix) {
// preservedVolumes = append(preservedVolumes, volume)
// }
// }
// if err := unstructured.SetNestedSlice(obj.UnstructuredContent(), preservedVolumes, "spec", "volumes"); err != nil {
// return nil, nil, errors.WithStack(err)
// }
// containers, err := nestedSliceRef(obj.UnstructuredContent(), "spec", "containers")
// if err != nil {
// return nil, nil, err
// }
// for _, obj := range containers {
// container, ok := obj.(map[string]interface{})
// if !ok {
// return nil, nil, errors.Errorf("unexpected type for container %T", obj)
// }
// volumeMounts, err := nestedSliceRef(container, "volumeMounts")
// if err != nil {
// return nil, nil, err
// }
// var preservedVolumeMounts []interface{}
// for _, obj := range volumeMounts {
// mount, ok := obj.(map[string]interface{})
// if !ok {
// return nil, nil, errors.Errorf("unexpected type for volume mount %T", obj)
// }
// name, found, err := unstructured.NestedString(mount, "name")
// if err != nil {
// return nil, nil, errors.WithStack(err)
// }
// if !found {
// return nil, nil, errors.New("no name found for volume mount")
// }
// if !strings.HasPrefix(name, prefix) {
// preservedVolumeMounts = append(preservedVolumeMounts, mount)
// }
// }
// container["volumeMounts"] = preservedVolumeMounts
// }
// res, found, err = unstructured.NestedFieldNoCopy(obj.UnstructuredContent(), "spec", "initContainers")
// if err != nil {
// return nil, nil, errors.WithStack(err)
// }
// if !found {
// return obj, nil, nil
// }
// initContainers, ok := res.([]interface{})
// if !ok {
// return nil, nil, errors.Errorf("unexpected type for .spec.initContainers %T", res)
// }
// for _, obj := range initContainers {
// initContainer, ok := obj.(map[string]interface{})
// if !ok {
// return nil, nil, errors.Errorf("unexpected type for init container %T", obj)
// }
// volumeMounts, err := nestedSliceRef(initContainer, "volumeMounts")
// if err != nil {
// return nil, nil, err
// }
// var preservedVolumeMounts []interface{}
// for _, obj := range volumeMounts {
// mount, ok := obj.(map[string]interface{})
// if !ok {
// return nil, nil, errors.Errorf("unexpected type for volume mount %T", obj)
// }
// name, found, err := unstructured.NestedString(mount, "name")
// if err != nil {
// return nil, nil, errors.WithStack(err)
// }
// if !found {
// return nil, nil, errors.New("no name found for volume mount")
// }
// if !strings.HasPrefix(name, prefix) {
// preservedVolumeMounts = append(preservedVolumeMounts, mount)
// }
// }
// initContainer["volumeMounts"] = preservedVolumeMounts
// }
// return obj, nil, nil
// }
// func nestedSliceRef(obj map[string]interface{}, fields ...string) ([]interface{}, error) {
// val, found, err := unstructured.NestedFieldNoCopy(obj, fields...)
// if err != nil {
// return nil, errors.WithStack(err)
// }
// if !found {
// return nil, errors.Errorf(".%s not found", strings.Join(fields, "."))
// }
// slice, ok := val.([]interface{})
// if !ok {
// return nil, errors.Errorf("unexpected type for .%s %T", strings.Join(fields, "."), val)
// }
// return slice, nil
// }

View File

@ -118,35 +118,4 @@ func deleteNodePorts(service *corev1api.Service) error {
}
return nil
// preservedPorts, err := getPreservedPorts(obj)
// if err != nil {
// return err
// }
// res, found, err := unstructured.NestedFieldNoCopy(obj.UnstructuredContent(), "spec", "ports")
// if err != nil {
// return errors.WithStack(err)
// }
// if !found {
// return errors.New(".spec.ports not found")
// }
// ports, ok := res.([]interface{})
// if !ok {
// return errors.Errorf("unexpected type for .spec.ports %T", res)
// }
// for _, port := range ports {
// p := port.(map[string]interface{})
// var name string
// if nameVal, ok := p["name"]; ok {
// name = nameVal.(string)
// }
// if preservedPorts[name] {
// continue
// }
// delete(p, "nodePort")
// }
// return nil
}