@@ -1055,8 +1055,8 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
1055
1055
},
1056
1056
"invalid-network-device-status" : {
1057
1057
wantFailures : field.ErrorList {
1058
- field .TooLong (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "interfaceName" ), "" , interfaceNameMaxLength ),
1059
- field .TooLong (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "hardwareAddress" ), "" , hardwareAddressMaxLength ),
1058
+ field .TooLong (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "interfaceName" ), "" , resource . NetworkDeviceDataInterfaceNameMaxLength ),
1059
+ field .TooLong (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "hardwareAddress" ), "" , resource . NetworkDeviceDataHardwareAddressMaxLength ),
1060
1060
field .Invalid (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "ips" ).Index (0 ), "300.9.8.0/24" , "must be a valid CIDR value, (e.g. 10.9.8.0/24 or 2001:db8::/64)" ),
1061
1061
},
1062
1062
oldClaim : func () * resource.ResourceClaim { return validAllocatedClaim }(),
@@ -1067,8 +1067,8 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
1067
1067
Pool : goodName ,
1068
1068
Device : goodName ,
1069
1069
NetworkData : & resource.NetworkDeviceData {
1070
- InterfaceName : strings .Repeat ("x" , interfaceNameMaxLength + 1 ),
1071
- HardwareAddress : strings .Repeat ("x" , hardwareAddressMaxLength + 1 ),
1070
+ InterfaceName : strings .Repeat ("x" , resource . NetworkDeviceDataInterfaceNameMaxLength + 1 ),
1071
+ HardwareAddress : strings .Repeat ("x" , resource . NetworkDeviceDataHardwareAddressMaxLength + 1 ),
1072
1072
IPs : []string {
1073
1073
"300.9.8.0/24" ,
1074
1074
},
@@ -1101,9 +1101,9 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
1101
1101
},
1102
1102
"invalid-data-device-status-limits" : {
1103
1103
wantFailures : field.ErrorList {
1104
- field .TooMany (field .NewPath ("status" , "devices" ).Index (0 ).Child ("conditions" ), maxConditions + 1 , maxConditions ),
1105
- field .TooLong (field .NewPath ("status" , "devices" ).Index (0 ).Child ("data" ), "" /* unused */ , resource .OpaqueParametersMaxLength ),
1106
- field .TooMany (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "ips" ), maxIPs + 1 , maxIPs ),
1104
+ field .TooMany (field .NewPath ("status" , "devices" ).Index (0 ).Child ("conditions" ), resource . AllocatedDeviceStatusMaxConditions + 1 , resource . AllocatedDeviceStatusMaxConditions ),
1105
+ field .TooLong (field .NewPath ("status" , "devices" ).Index (0 ).Child ("data" ), "" /* unused */ , resource .AllocatedDeviceStatusDataMaxLength ),
1106
+ field .TooMany (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "ips" ), resource . NetworkDeviceDataMaxIPs + 1 , resource . NetworkDeviceDataMaxIPs ),
1107
1107
},
1108
1108
oldClaim : func () * resource.ResourceClaim { return validAllocatedClaim }(),
1109
1109
update : func (claim * resource.ResourceClaim ) * resource.ResourceClaim {
@@ -1112,7 +1112,7 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
1112
1112
Driver : goodName ,
1113
1113
Pool : goodName ,
1114
1114
Device : goodName ,
1115
- Data : runtime.RawExtension {Raw : []byte (`{"str": "` + strings .Repeat ("x" , resource .OpaqueParametersMaxLength - 9 - 2 + 1 /* too large by one */ ) + `"}` )},
1115
+ Data : runtime.RawExtension {Raw : []byte (`{"str": "` + strings .Repeat ("x" , resource .AllocatedDeviceStatusDataMaxLength - 9 - 2 + 1 /* too large by one */ ) + `"}` )},
1116
1116
Conditions : []metav1.Condition {
1117
1117
{Type : "test-0" , Status : metav1 .ConditionTrue , Reason : "test_reason" , LastTransitionTime : metav1 .Now (), ObservedGeneration : 0 },
1118
1118
{Type : "test-1" , Status : metav1 .ConditionTrue , Reason : "test_reason" , LastTransitionTime : metav1 .Now (), ObservedGeneration : 0 },
@@ -1184,8 +1184,8 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
1184
1184
},
1185
1185
"invalid-network-device-status-disabled-feature-gate" : {
1186
1186
wantFailures : field.ErrorList {
1187
- field .TooLong (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "interfaceName" ), "" , interfaceNameMaxLength ),
1188
- field .TooLong (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "hardwareAddress" ), "" , hardwareAddressMaxLength ),
1187
+ field .TooLong (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "interfaceName" ), "" , resource . NetworkDeviceDataInterfaceNameMaxLength ),
1188
+ field .TooLong (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "hardwareAddress" ), "" , resource . NetworkDeviceDataHardwareAddressMaxLength ),
1189
1189
field .Invalid (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "ips" ).Index (0 ), "300.9.8.0/24" , "must be a valid CIDR value, (e.g. 10.9.8.0/24 or 2001:db8::/64)" ),
1190
1190
},
1191
1191
oldClaim : func () * resource.ResourceClaim { return validAllocatedClaim }(),
@@ -1196,8 +1196,8 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
1196
1196
Pool : goodName ,
1197
1197
Device : goodName ,
1198
1198
NetworkData : & resource.NetworkDeviceData {
1199
- InterfaceName : strings .Repeat ("x" , interfaceNameMaxLength + 1 ),
1200
- HardwareAddress : strings .Repeat ("x" , hardwareAddressMaxLength + 1 ),
1199
+ InterfaceName : strings .Repeat ("x" , resource . NetworkDeviceDataInterfaceNameMaxLength + 1 ),
1200
+ HardwareAddress : strings .Repeat ("x" , resource . NetworkDeviceDataHardwareAddressMaxLength + 1 ),
1201
1201
IPs : []string {
1202
1202
"300.9.8.0/24" ,
1203
1203
},
@@ -1230,9 +1230,9 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
1230
1230
},
1231
1231
"invalid-data-device-status-limits-feature-gate" : {
1232
1232
wantFailures : field.ErrorList {
1233
- field .TooMany (field .NewPath ("status" , "devices" ).Index (0 ).Child ("conditions" ), maxConditions + 1 , maxConditions ),
1234
- field .TooLong (field .NewPath ("status" , "devices" ).Index (0 ).Child ("data" ), "" /* unused */ , resource .OpaqueParametersMaxLength ),
1235
- field .TooMany (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "ips" ), maxIPs + 1 , maxIPs ),
1233
+ field .TooMany (field .NewPath ("status" , "devices" ).Index (0 ).Child ("conditions" ), resource . AllocatedDeviceStatusMaxConditions + 1 , resource . AllocatedDeviceStatusMaxConditions ),
1234
+ field .TooLong (field .NewPath ("status" , "devices" ).Index (0 ).Child ("data" ), "" /* unused */ , resource .AllocatedDeviceStatusDataMaxLength ),
1235
+ field .TooMany (field .NewPath ("status" , "devices" ).Index (0 ).Child ("networkData" , "ips" ), resource . NetworkDeviceDataMaxIPs + 1 , resource . NetworkDeviceDataMaxIPs ),
1236
1236
},
1237
1237
oldClaim : func () * resource.ResourceClaim { return validAllocatedClaim }(),
1238
1238
update : func (claim * resource.ResourceClaim ) * resource.ResourceClaim {
@@ -1241,7 +1241,7 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
1241
1241
Driver : goodName ,
1242
1242
Pool : goodName ,
1243
1243
Device : goodName ,
1244
- Data : runtime.RawExtension {Raw : []byte (`{"str": "` + strings .Repeat ("x" , resource .OpaqueParametersMaxLength - 9 - 2 + 1 /* too large by one */ ) + `"}` )},
1244
+ Data : runtime.RawExtension {Raw : []byte (`{"str": "` + strings .Repeat ("x" , resource .AllocatedDeviceStatusDataMaxLength - 9 - 2 + 1 /* too large by one */ ) + `"}` )},
1245
1245
Conditions : []metav1.Condition {
1246
1246
{Type : "test-0" , Status : metav1 .ConditionTrue , Reason : "test_reason" , LastTransitionTime : metav1 .Now (), ObservedGeneration : 0 },
1247
1247
{Type : "test-1" , Status : metav1 .ConditionTrue , Reason : "test_reason" , LastTransitionTime : metav1 .Now (), ObservedGeneration : 0 },
0 commit comments