deprecated node labels: make naming consistant and remove some unused args in funcs
This commit is contained in:
@@ -17,7 +17,6 @@ limitations under the License.
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
@@ -25,14 +24,14 @@ import (
|
||||
"k8s.io/kubernetes/pkg/apis/storage"
|
||||
)
|
||||
|
||||
func GetWarningsForStorageClass(ctx context.Context, sc *storage.StorageClass) []string {
|
||||
func GetWarningsForStorageClass(sc *storage.StorageClass) []string {
|
||||
var warnings []string
|
||||
|
||||
if sc != nil && sc.AllowedTopologies != nil {
|
||||
// use of deprecated node labels in allowedTopologies's matchLabelExpressions
|
||||
for i, topo := range sc.AllowedTopologies {
|
||||
for j, expression := range topo.MatchLabelExpressions {
|
||||
if msg, deprecated := nodeapi.GetLabelDeprecatedMessage(expression.Key); deprecated {
|
||||
if msg, deprecated := nodeapi.GetNodeLabelDeprecatedMessage(expression.Key); deprecated {
|
||||
warnings = append(warnings, fmt.Sprintf("%s: %s", field.NewPath("allowedTopologies").Index(i).Child("matchLabelExpressions").Index(j).Child("key"), msg))
|
||||
}
|
||||
}
|
||||
@@ -42,9 +41,9 @@ func GetWarningsForStorageClass(ctx context.Context, sc *storage.StorageClass) [
|
||||
return warnings
|
||||
}
|
||||
|
||||
func GetWarningsForCSIStorageCapacity(ctx context.Context, csc *storage.CSIStorageCapacity) []string {
|
||||
func GetWarningsForCSIStorageCapacity(csc *storage.CSIStorageCapacity) []string {
|
||||
if csc != nil {
|
||||
return nodeapi.WarningsForNodeSelector(csc.NodeTopology, field.NewPath("nodeTopology"))
|
||||
return nodeapi.GetWarningsForNodeSelector(csc.NodeTopology, field.NewPath("nodeTopology"))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@@ -17,7 +17,6 @@ limitations under the License.
|
||||
package storage
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -77,7 +76,7 @@ func TestStorageClassWarnings(t *testing.T) {
|
||||
|
||||
for _, tc := range testcases {
|
||||
t.Run("podspec_"+tc.name, func(t *testing.T) {
|
||||
actual := sets.NewString(GetWarningsForStorageClass(context.TODO(), tc.template)...)
|
||||
actual := sets.NewString(GetWarningsForStorageClass(tc.template)...)
|
||||
expected := sets.NewString(tc.expected...)
|
||||
for _, missing := range expected.Difference(actual).List() {
|
||||
t.Errorf("missing: %s", missing)
|
||||
@@ -158,7 +157,7 @@ func TestCSIStorageCapacityWarnings(t *testing.T) {
|
||||
|
||||
for _, tc := range testcases {
|
||||
t.Run("podspec_"+tc.name, func(t *testing.T) {
|
||||
actual := sets.NewString(GetWarningsForCSIStorageCapacity(context.TODO(), tc.template)...)
|
||||
actual := sets.NewString(GetWarningsForCSIStorageCapacity(tc.template)...)
|
||||
expected := sets.NewString(tc.expected...)
|
||||
for _, missing := range expected.Difference(actual).List() {
|
||||
t.Errorf("missing: %s", missing)
|
||||
|
Reference in New Issue
Block a user