Repository: kubernetes/kubernetes
File: staging/src/k8s.io/apimachinery/pkg/util/validation/field/errors.go (Go)

Code before:
	return list
}

// Filter removes items from the ErrorList that match the provided fns.
func (list ErrorList) Filter(fns ...utilerrors.Matcher) ErrorList {
	err := utilerrors.FilterOut(list.ToAggregate(), fns...)
	if err == nil {
		return nil
	}
	// FilterOut takes an Aggregate and returns an Aggregate
	return fromAggregate(err.(utilerrors.Aggregate))
}

// ExtractCoveredByDeclarative returns a new ErrorList containing only the errors that should be covered by declarative validation.
func (list ErrorList) ExtractCoveredByDeclarative() ErrorList {
	newList := ErrorList{}
	for _, err := range list {
		if err.CoveredByDeclarative {
			newList = append(newList, err)
		}
	}
	return newList
}

// MarkDeclarativeNative marks the error as originating from a declarative-native validation.
func (e *Error) MarkDeclarativeNative() *Error {
	e.DeclarativeNative = true
	return e
}

// MarkDeclarativeNative marks all errors in the list as originating from declarative-native validations.
func (list ErrorList) MarkDeclarativeNative() ErrorList {
	for _, err := range list {
		err.DeclarativeNative = true
	}
	return list
}

// MarkAlpha marks the error as an alpha validation error.
func (e *Error) MarkAlpha() *Error {
	e.ValidationStabilityLevel = stabilityLevelAlpha
	return e
}

// MarkAlpha marks the errors as alpha validation errors.
func (list ErrorList) MarkAlpha() ErrorList {
	for _, err := range list {
		err.ValidationStabilityLevel = stabilityLevelAlpha
	}
	return list
}

Review comment (bug):
Did this method have a test in errors_test.go that also needs to be removed?  I don't think so from a cursory glance of the code @ HEAD but want to double check (IIUC it did the test would fail ) as I thought there was an associated test

Code after:
func (list ErrorList) Filter(fns ...utilerrors.Matcher) ErrorList {
	err := utilerrors.FilterOut(list.ToAggregate(), fns...)
	if err == nil {
		return nil
	}
	// FilterOut takes an Aggregate and returns an Aggregate
	return fromAggregate(err.(utilerrors.Aggregate))
}

// ExtractCoveredByDeclarative returns a new ErrorList containing only the errors that should be covered by declarative validation.
func (list ErrorList) ExtractCoveredByDeclarative() ErrorList {
	newList := ErrorList{}
	for _, err := range list {
		if err.CoveredByDeclarative {
			newList = append(newList, err)
		}
	}
	return newList
}

// MarkAlpha marks the error as an alpha validation error.
func (e *Error) MarkAlpha() *Error {
	e.ValidationStabilityLevel = stabilityLevelAlpha
	return e
}

// MarkAlpha marks the errors as alpha validation errors.
func (list ErrorList) MarkAlpha() ErrorList {
	for _, err := range list {
		err.ValidationStabilityLevel = stabilityLevelAlpha
	}
	return list
}

// MarkBeta marks the error as a beta validation error.
func (e *Error) MarkBeta() *Error {
	e.ValidationStabilityLevel = stabilityLevelBeta
	return e
}

// MarkBeta marks the errors as beta validation errors.
func (list ErrorList) MarkBeta() ErrorList {
	for _, err := range list {
		err.ValidationStabilityLevel = stabilityLevelBeta
	}
	return list
}

// RemoveCoveredByDeclarative returns a new ErrorList containing only the errors that should not be covered by declarative validation.
func (list ErrorList) RemoveCoveredByDeclarative() ErrorList {
	newList := ErrorList{}