func newStrategicMergeSliceFromBytes(in []byte) (strategicMergeSlice, error) {
	decoder := yaml.NewYAMLOrJSONDecoder(bytes.NewReader(in), 1024)
	var result strategicMergeSlice
	var err error
	// Parse all the yaml documents in the file
	for err == nil || isEmptyYamlError(err) {
		var u unstructured.Unstructured
		err = decoder.Decode(&u)
		// if the yaml document is a valid unstructured object
		if err == nil {
			// it the unstructured object is empty, move to the next
			if len(u.Object) == 0 {
				continue
			}

			// validate the object has kind, metadata.name as required by Kustomize
			if err := validate(u); err != nil {
				return nil, err
			}

			// if the document is a list of objects
			if strings.HasSuffix(u.GetKind(), "List") {
				// for each item in the list of objects
				if err := u.EachListItem(func(item runtime.Object) error {
					// Marshal the object
					itemJSON, err := json.Marshal(item)
					if err != nil {
						return err
					}

					// Get the strategicMergeSlice for the item
					itemU, err := newStrategicMergeSliceFromBytes(itemJSON)
					if err != nil {
						return err
					}

					// append the strategicMergeSlice for the item to the strategicMergeSlice
					result = append(result, itemU...)

					return nil
				}); err != nil {
					return nil, err
				}

				continue
			}

			// append the object to the stategicMergeSlice
			result = append(result, &u)
		}
	}
	if err != io.EOF {
		return nil, err
	}
	return result, nil
}
// newStrategicMergeSliceFromBytes returns a strategic merge patches contained in a []byte.
// This functions handles all the nuances of Kubernetes yaml (e.g. many yaml
// documents in one file, List of objects)
newStrategicMergeSliceFromBytes returns a strategic merge patches contained in a []byte.
This functions handles all the nuances of Kubernetes yaml
// newStrategicMergeSliceFromBytes returns a strategic merge patches contained in a [] byte . // This functions handles all the nuances of Kubernetes yaml ( e . g . many yaml // documents in one file List of objects )
func newStrategicMergeSliceFromBytes(in []byte) (strategicMergeSlice, error) {
	decoder := yaml.NewYAMLOrJSONDecoder(bytes.NewReader(in), 1024)
	var result strategicMergeSlice
	var err error
	for err == nil || isEmptyYamlError(err) {
		var u unstructured.Unstructured
		err = decoder.Decode(&u)
		if err == nil {
			if len(u.Object) == 0 {
				continue
			}
			if err := validate(u); err != nil {
				return nil, err
			}
			if strings.HasSuffix(u.GetKind(), "List") {
				if err := u.EachListItem(func(item runtime.Object) error {
					itemJSON, err := json.Marshal(item)
					if err != nil {
						return err
					}
					itemU, err := newStrategicMergeSliceFromBytes(itemJSON)
					if err != nil {
						return err
					}
					result = append(result, itemU...)
					return nil
				}); err != nil {
					return nil, err
				}
				continue
			}
			result = append(result, &u)
		}
	}
	if err != io.EOF {
		return nil, err
	}
	return result, nil
}
func newStrategicMergeSliceFromBytes ( in [ ] byte ) ( strategicMergeSlice , error ) { decoder := yaml . NewYAMLOrJSONDecoder ( bytes . NewReader ( in ) , 1024 ) var result strategicMergeSlice var err error for err == nil || isEmptyYamlError ( err ) { var u unstructured . Unstructured err = decoder . Decode ( & u ) if err == nil { if len ( u . Object ) == 0 { continue } if err := validate ( u ) ; err != nil { return nil , err } if strings . HasSuffix ( u . GetKind ( ) , " " ) { if err := u . EachListItem ( func ( item runtime . Object ) error { itemJSON , err := json . Marshal ( item ) if err != nil { return err } itemU , err := newStrategicMergeSliceFromBytes ( itemJSON ) if err != nil { return err } result = append ( result , itemU ... ) return nil } ) ; err != nil { return nil , err } continue } result = append ( result , & u ) } } if err != io . EOF { return nil , err } return result , nil }
newStrategicMergeSliceFromBytes returns a strategic merge patches contained in a []byte.
newStrategicMergeSliceFromBytes returns a strategic merge patches contained in a [] byte .
// Parse all the yaml documents in the file // if the yaml document is a valid unstructured object // it the unstructured object is empty, move to the next // validate the object has kind, metadata.name as required by Kustomize // if the document is a list of objects // for each item in the list of objects // Marshal the object // Get the strategicMergeSlice for the item // append the strategicMergeSlice for the item to the strategicMergeSlice // append the object to the stategicMergeSlice