Skip to content

Commit 35b8f65

Browse files
author
Christine WANJAU
committed
Support set and filtering by tags for feature commands
1 parent 7952300 commit 35b8f65

File tree

7 files changed

+49678
-48333
lines changed

7 files changed

+49678
-48333
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ class FeatureFlag:
134134
The list of variants defined for this feature.
135135
:ivar dict {string, object} telemetry:
136136
The declaration of options used to configure telemetry for this feature.
137+
:ivar dict tags:
138+
Tags associated with the feature flag.
137139
"""
138140

139141
def __init__(
@@ -151,6 +153,7 @@ def __init__(
151153
allocation=None,
152154
variants=None,
153155
telemetry=None,
156+
tags=None
154157
):
155158
self.name = name
156159
self.key = key
@@ -165,6 +168,7 @@ def __init__(
165168
self.variants = variants
166169
self.telemetry = telemetry
167170
self.display_name = display_name
171+
self.tags = tags
168172

169173
def __repr__(self):
170174
featureflag = {
@@ -180,7 +184,8 @@ def __repr__(self):
180184
"Allocation": custom_serialize_allocation(self.allocation),
181185
"Variants": custom_serialize_variants(self.variants),
182186
"Telemetry": custom_serialize_telemetry(self.telemetry),
183-
"Display Name": self.display_name
187+
"Display Name": self.display_name,
188+
"Tags": self.tags
184189
}
185190

186191
return json.dumps(featureflag, indent=2, ensure_ascii=False)
@@ -803,7 +808,8 @@ def map_keyvalue_to_featureflag(keyvalue, show_all_details=True, hide_enabled=Tr
803808
last_modified=keyvalue.last_modified,
804809
allocation=feature_flag_value.allocation,
805810
variants=feature_flag_value.variants,
806-
telemetry=feature_flag_value.telemetry
811+
telemetry=feature_flag_value.telemetry,
812+
tags=keyvalue.tags
807813
)
808814

809815
# By Default, we will try to show conditions unless the user has

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,18 +358,21 @@ def load_arguments(self, _):
358358
c.argument('key', validator=validate_feature_key, help='Key of the feature flag. Key must start with the ".appconfig.featureflag/" prefix. Key cannot contain the "%" character. Default key is the reserved prefix ".appconfig.featureflag/" + feature name.')
359359
c.argument('requirement_type', arg_type=get_enum_type([FeatureFlagConstants.REQUIREMENT_TYPE_ALL, FeatureFlagConstants.REQUIREMENT_TYPE_ANY]),
360360
help='Requirement type determines if filters should use "Any" or "All" logic when evaluating the state of a feature.')
361+
c.argument('tags', arg_type=tags_type)
361362

362363
with self.argument_context('appconfig feature delete') as c:
363364
c.argument('feature', help='Name of the feature to be deleted. If the feature flag key is different from the default key, provide the `--key` argument instead. Support star sign as filters, for instance * means all features and abc* means features with abc as prefix. Comma separated features are not supported. Please provide escaped string if your feature name contains comma.')
364365
c.argument('label', help="If no label specified, delete the feature flag with null label by default. Support star sign as filters, for instance * means all labels and abc* means labels with abc as prefix.")
365366
c.argument('key', validator=validate_feature_key, help='Key of the feature flag. Key must start with the ".appconfig.featureflag/" prefix. Key cannot contain the "%" character. If both key and feature arguments are provided, only key will be used. Support star sign as filters, for instance ".appconfig.featureflag/*" means all features and ".appconfig.featureflag/abc*" means features with abc as prefix. Comma separated features are not supported. Please provide escaped string if your feature name contains comma.')
367+
c.argument('tags', arg_type=tags_arg_type, help="If no tags are specified, delete all feature flags with any tags. Support space-separated tags: key[=value] [key[=value] ...].")
366368

367369
with self.argument_context('appconfig feature list') as c:
368370
c.argument('feature', help='Name of the feature to be listed. If the feature flag key is different from the default key, provide the `--key` argument instead. Support star sign as filters, for instance * means all features and abc* means features with abc as prefix. Comma separated features are not supported. Please provide escaped string if your feature name contains comma.')
369371
c.argument('label', help="If no label specified, list all labels. Support star sign as filters, for instance * means all labels and abc* means labels with abc as prefix. Use '\\0' for null label.")
370372
c.argument('fields', arg_type=feature_fields_arg_type)
371373
c.argument('all_', help="List all feature flags.")
372374
c.argument('key', validator=validate_feature_key, help='Key of the feature flag. Key must start with the ".appconfig.featureflag/" prefix. Key cannot contain the "%" character. If both key and feature arguments are provided, only key will be used. Support star sign as filters, for instance ".appconfig.featureflag/*" means all features and ".appconfig.featureflag/abc*" means features with abc as prefix. Comma separated features are not supported. Please provide escaped string if your feature name contains comma.')
375+
c.argument('tags', arg_type=tags_arg_type, help="If no tags are specified, delete all feature flags with any tags. Support space-separated tags: key[=value] [key[=value] ...].")
373376

374377
with self.argument_context('appconfig feature lock') as c:
375378
c.argument('feature', help='Name of the feature to be locked. If the feature flag key is different from the default key, provide the `--key` argument instead.')

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ def set_feature(cmd,
5151
yes=False,
5252
connection_string=None,
5353
auth_mode="key",
54-
endpoint=None):
54+
endpoint=None,
55+
tags=None):
5556
if key is None and feature is None:
5657
raise CLIErrors.RequiredArgumentMissingError("Please provide either `--key` or `--feature` value.")
5758

@@ -67,7 +68,6 @@ def set_feature(cmd,
6768
raise exception
6869

6970
# when creating a new Feature flag, these defaults will be used
70-
tags = {}
7171
default_conditions = {FeatureFlagConstants.CLIENT_FILTERS: []}
7272

7373
if requirement_type:
@@ -145,6 +145,7 @@ def set_feature(cmd,
145145

146146
# Convert KeyValue object to required FeatureFlag format for
147147
# display
148+
148149
feature_flag = map_keyvalue_to_featureflag(set_kv, show_all_details=True)
149150
entry = json.dumps(feature_flag, default=lambda o: o.__dict__, indent=2, sort_keys=True, ensure_ascii=False)
150151

@@ -185,7 +186,8 @@ def delete_feature(cmd,
185186
yes=False,
186187
connection_string=None,
187188
auth_mode="key",
188-
endpoint=None):
189+
endpoint=None,
190+
tags=None):
189191
if key is None and feature is None:
190192
raise CLIErrors.RequiredArgumentMissingError("Please provide either `--key` or `--feature` value.")
191193
if key and feature:
@@ -204,9 +206,10 @@ def delete_feature(cmd,
204206
retrieved_keyvalues = __list_all_keyvalues(azconfig_client,
205207
key_filter=key_filter,
206208
label=SearchFilterOptions.EMPTY_LABEL if label is None else label,
207-
correlation_request_id=correlation_request_id)
209+
correlation_request_id=correlation_request_id,
210+
tags=tags)
208211

209-
confirmation_message = "Found '{}' feature flags matching the specified feature and label. Are you sure you want to delete these feature flags?".format(len(retrieved_keyvalues))
212+
confirmation_message = "Found '{}' feature flags matching the specified feature, label, and tags. Are you sure you want to delete these feature flags?".format(len(retrieved_keyvalues))
210213
user_confirmation(confirmation_message, yes)
211214

212215
deleted_kvs = []
@@ -304,7 +307,8 @@ def list_feature(cmd,
304307
top=None,
305308
all_=False,
306309
auth_mode="key",
307-
endpoint=None):
310+
endpoint=None,
311+
tags=None):
308312
return __list_features(
309313
cmd=cmd,
310314
feature=feature,
@@ -316,7 +320,8 @@ def list_feature(cmd,
316320
top=top,
317321
all_=all_,
318322
auth_mode=auth_mode,
319-
endpoint=endpoint
323+
endpoint=endpoint,
324+
tags=tags
320325
)
321326

322327

0 commit comments

Comments
 (0)