From 697113f5f07124641df79bb6e6212b09ba29af58 Mon Sep 17 00:00:00 2001 From: Joe Betz Date: Tue, 16 Sep 2025 17:57:59 -0400 Subject: [PATCH] Add utility function to errors to allow format composition --- .../apimachinery/pkg/util/validation/field/errors.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/staging/src/k8s.io/apimachinery/pkg/util/validation/field/errors.go b/staging/src/k8s.io/apimachinery/pkg/util/validation/field/errors.go index f2a983aebf6..950d8386823 100644 --- a/staging/src/k8s.io/apimachinery/pkg/util/validation/field/errors.go +++ b/staging/src/k8s.io/apimachinery/pkg/util/validation/field/errors.go @@ -341,6 +341,14 @@ func (list ErrorList) MarkCoveredByDeclarative() ErrorList { return list } +// PrefixDetail adds a prefix to the Detail for all errors in the list and returns the updated list. +func (list ErrorList) PrefixDetail(prefix string) ErrorList { + for _, err := range list { + err.Detail = prefix + err.Detail + } + return list +} + // ToAggregate converts the ErrorList into an errors.Aggregate. func (list ErrorList) ToAggregate() utilerrors.Aggregate { if len(list) == 0 {