Commit 2878adb
[GCU] Using simulated config instead of target config when validating replace operation in NoDependencyMoveValidator (#1987)
#### What I did
Using `SimulatedConfig` instead of `TargetConfig` for validating a move using `NoDependencyMoveValidator`
SimulatedConfig: config after applying the given move
TargetConfig: the final config state that's required by the patch
The problem is if the moves is to update a list item, the list item location in the `TargetConfig` might have different location in the `CurrentConfig`.
The reason for that is the `TargetConfig` has the final outcome after applying the `patch`, but the move might be just making a small change towards this goal.
Example:
Assume current_config
```
{
"VLAN": {
"Vlan100": {
"vlanid": "100",
"dhcp_servers": [
"192.0.0.1",
"192.0.0.2"
]
}
}
}
```
TargetConfig:
```
{
"VLAN": {
"Vlan100": {
"vlanid": "100",
"dhcp_servers": [
"192.0.0.3"
]
}
}
}
```
Move:
```python
ps.JsonMove(diff, OperationType.REPLACE, ["VLAN", "Vlan100", "dhcp_servers", 1], ["VLAN", "Vlan100", "dhcp_servers", 0])
```
The move means:
```
Replace the value in CurrentConfig that has path `/VLAN/Vlan100/dhcp_servers/1` with
the value from the TargetConfig that has the path `/VLAN/Vlan100/dhcp_servers/0`
```
Notice how the array index in CurrentConfig does not exist in TargetConfig
Instead of using TargetConfig to validate, use SimulatedConfig which is the config after applying the move. In this case it would be:
```
{
"VLAN": {
"Vlan100": {
"vlanid": "100",
"dhcp_servers": [
"192.0.0.1",
"192.0.0.3"
]
}
}
}
```
#### How I did it
Replace `diff.target_config` with `simulated_config`
#### How to verify it
added a unit-test1 parent fb8ca98 commit 2878adb
File tree
2 files changed
+35
-2
lines changed- generic_config_updater
- tests/generic_config_updater
2 files changed
+35
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
551 | 551 | | |
552 | 552 | | |
553 | 553 | | |
| 554 | + | |
554 | 555 | | |
555 | 556 | | |
556 | 557 | | |
557 | | - | |
| 558 | + | |
| 559 | + | |
558 | 560 | | |
559 | 561 | | |
560 | 562 | | |
| |||
1020 | 1022 | | |
1021 | 1023 | | |
1022 | 1024 | | |
1023 | | - | |
| 1025 | + | |
1024 | 1026 | | |
1025 | 1027 | | |
1026 | 1028 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1054 | 1054 | | |
1055 | 1055 | | |
1056 | 1056 | | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
1057 | 1088 | | |
1058 | 1089 | | |
1059 | 1090 | | |
| |||
0 commit comments