diff --git a/internal/topology/variables/cluster_variable_defaulting.go b/internal/topology/variables/cluster_variable_defaulting.go index 442998f2fe40..3f4a38ad344c 100644 --- a/internal/topology/variables/cluster_variable_defaulting.go +++ b/internal/topology/variables/cluster_variable_defaulting.go @@ -19,6 +19,7 @@ package variables import ( "encoding/json" "fmt" + "strings" "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" @@ -49,8 +50,11 @@ func defaultClusterVariables(values []clusterv1.ClusterVariable, definitions []c // - variables with the same name do not have a mix of empty and non-empty DefinitionFrom. valuesIndex, err := newValuesIndex(values) if err != nil { - return nil, append(allErrs, field.Invalid(fldPath, values, - fmt.Sprintf("cluster variables not valid: %s", err))) + var valueStrings []string + for _, v := range values { + valueStrings = append(valueStrings, fmt.Sprintf("Name: %s DefinitionFrom: %s", v.Name, v.DefinitionFrom)) + } + return nil, append(allErrs, field.Invalid(fldPath, "["+strings.Join(valueStrings, ",")+"]", fmt.Sprintf("cluster variables not valid: %s", err))) } // Get an index for each variable name and definition. diff --git a/internal/topology/variables/cluster_variable_validation.go b/internal/topology/variables/cluster_variable_validation.go index 992bc600c67d..1b4a07772640 100644 --- a/internal/topology/variables/cluster_variable_validation.go +++ b/internal/topology/variables/cluster_variable_validation.go @@ -49,7 +49,11 @@ func validateClusterVariables(values []clusterv1.ClusterVariable, definitions [] // - variables with the same name do not have a mix of empty and non-empty DefinitionFrom. valuesMap, err := newValuesIndex(values) if err != nil { - return append(allErrs, field.Invalid(fldPath, values, fmt.Sprintf("cluster variables not valid: %s", err))) + var valueStrings []string + for _, v := range values { + valueStrings = append(valueStrings, fmt.Sprintf("Name: %s DefinitionFrom: %s", v.Name, v.DefinitionFrom)) + } + return append(allErrs, field.Invalid(fldPath, "["+strings.Join(valueStrings, ",")+"]", fmt.Sprintf("cluster variables not valid: %s", err))) } // Get an index of definitions for each variable name and definition from the ClusterClass variable.