Skip to content

Commit fcc4d33

Browse files
committed
Add option to ignor mathing kvs in diff utils.
1 parent a287786 commit fcc4d33

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/azure-cli/azure/cli/command_modules/appconfig/_diff_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(self, src_kvs, compare_fields, preserve_labels=True, label=None, co
3232
kv.label = label
3333

3434
# Returns a diff in the form {"add": List[KeyValue], "delete": List[KeyValue], "update": List[{"new": KeyValue, "old": KeyValue}]}
35-
def compare(self, dest_kvs, strict=False):
35+
def compare(self, dest_kvs, strict=False, ignore_matching_kvs=True):
3636
if not strict and not self._src_kvs:
3737
return {}
3838

@@ -52,7 +52,7 @@ def compare(self, dest_kvs, strict=False):
5252
kv_diff[JsonDiff.ADD].append(kv)
5353

5454
else:
55-
if not self._kv_equals(kv, dest_kv_lookup[lookup_key], self._compare_fields):
55+
if not (ignore_matching_kvs and self._kv_equals(kv, dest_kv_lookup[lookup_key], self._compare_fields)):
5656
kv_diff[JsonDiff.UPDATE].append({"new": kv, "old": dest_kv_lookup[lookup_key]})
5757

5858
del dest_kv_lookup[lookup_key]

src/azure-cli/azure/cli/command_modules/appconfig/keyvalue.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def import_config(cmd,
175175
label=label,
176176
content_type=content_type)
177177

178-
kv_diff = kv_comparer.compare(dest_kvs=dest_kvs, strict=strict)
178+
kv_diff = kv_comparer.compare(dest_kvs=dest_kvs, strict=strict, ignore_matching_kvs=import_mode==ImportMode.IGNORE_MATCH)
179179
# Show indented key-value preview similar to kvset for appconfig source
180180
indent = 2 if source == "appconfig" else None
181181
need_kv_change = print_preview(kv_diff, source, yes=yes, strict=strict, title="Key Values", indent=indent)
@@ -198,7 +198,7 @@ def import_config(cmd,
198198
compare_fields=CompareFieldsMap[source],
199199
preserve_labels=source == "appconfig" and preserve_labels,
200200
label=label)
201-
ff_diff = ff_comparer.compare(dest_kvs=dest_features, strict=strict)
201+
ff_diff = ff_comparer.compare(dest_kvs=dest_features, strict=strict, ignore_matching_kvs=import_mode==ImportMode.IGNORE_MATCH)
202202
need_feature_change = print_preview(ff_diff, source, yes=yes, strict=strict, title="Feature Flags")
203203

204204
if not need_kv_change and not need_feature_change:

0 commit comments

Comments
 (0)