Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AppConfig]Unblock using "kv set" to add keyvault reference and feature … #12377

Merged
merged 1 commit into from
Mar 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
validate_import_depth, validate_query_fields,
validate_feature_query_fields, validate_filter_parameters,
validate_separator, validate_secret_identifier,
validate_key, validate_content_type, validate_feature,
validate_key, validate_feature,
validate_identity)


Expand Down Expand Up @@ -147,7 +147,7 @@ def load_arguments(self, _):
c.argument('key', validator=validate_key, help="Key to be set. Key cannot be a '.' or '..', or contain the '%' character.")
c.argument('label', help="If no label specified, set the key with null label by default")
c.argument('tags', arg_type=tags_type)
c.argument('content_type', validator=validate_content_type, help='Content type of the keyvalue to be set.')
c.argument('content_type', help='Content type of the keyvalue to be set.')
c.argument('value', help='Value of the keyvalue to be set.')

with self.argument_context('appconfig kv set-keyvault') as c:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
from ._featuremodels import FeatureQueryFields

logger = get_logger(__name__)
FEATURE_FLAG_PREFIX = ".appconfig.featureflag/"
FEATURE_FLAG_CONTENT_TYPE = "application/vnd.microsoft.appconfig.ff+json;charset=utf-8"
KEYVAULT_CONTENT_TYPE = "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8"


def validate_datetime(namespace):
Expand Down Expand Up @@ -192,21 +189,10 @@ def validate_key(namespace):
input_key = str(namespace.key).lower()
if input_key == '.' or input_key == '..' or '%' in input_key:
raise CLIError("Key is invalid. Key cannot be a '.' or '..', or contain the '%' character.")
if input_key.startswith(FEATURE_FLAG_PREFIX):
raise CLIError("Key is invalid. Key cannot start with the reserved prefix for feature flags.")
else:
raise CLIError("Key cannot be empty.")


def validate_content_type(namespace):
if namespace.content_type is not None:
content_type = str(namespace.content_type).lower()
if content_type == FEATURE_FLAG_CONTENT_TYPE:
raise CLIError("Content type is invalid. It's a reserved content type for feature flags.")
if content_type == KEYVAULT_CONTENT_TYPE:
raise CLIError("Content type is invalid. It's a reserved content type for KeyVault references.")


def validate_feature(namespace):
if namespace.feature:
invalid_pattern = re.compile(r'[^a-zA-Z0-9._-]')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ def set_key(cmd,
cmd, name, connection_string)
azconfig_client = AzconfigClient(connection_string)

if content_type:
if content_type.lower() == KeyVaultConstants.KEYVAULT_CONTENT_TYPE:
logger.warning("There is a dedicated command to set key vault reference. 'appconfig kv set-keyvault -h'")
elif content_type.lower() == FeatureFlagConstants.FEATURE_FLAG_CONTENT_TYPE:
logger.warning("There is a dedicated command to set feature flag. 'appconfig feature set -h'")

retry_times = 3
retry_interval = 1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"FeatureManagement": {
"Beta": false,
"Percentage": true,
"Timestamp": {
"EnabledFor": [
{
"Name": "Local Tests",
"Parameters": {
"EndTime": "2019-09-01T00:00:00Z",
"StartTime": "2019-01-01T00:00:00Z"
}
"StartTime": "2019-01-01T00:00:00Z",
"EndTime": "2019-09-01T00:00:00Z"
},
"Name": "Local Tests"
},
{
"Name": "Production Tests",
"Parameters": {
"EndTime": "2019-11-01T00:00:00Z",
"StartTime": "2019-09-02T00:00:00Z"
}
"StartTime": "2019-09-02T00:00:00Z",
"EndTime": "2019-11-01T00:00:00Z"
},
"Name": "Production Tests"
}
]
},
"Percentage": true,
"Beta": false
}
},
"Region": "West US",
"Color": "Red"
"Color": "Red",
"Region": "West US"
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#Wed Feb 12 14:14:17 Pacific Standard Time 2020
#Thu Feb 27 13:28:32 Pacific Standard Time 2020
feature-management.FeatureSample.enabled-for[3].Parameters.EmptyValue=
feature-management.FeatureSample.enabled-for[1].Name=Filter2
Color=Red
Region=West US
feature-management.FeatureSample.enabled-for[3].Name=filter.4
feature-management.FeatureSample.enabled-for[3].Parameters.dotInFilter.Param=?
feature-management.FeatureSample.enabled-for[0].Name=Filter1
feature-management.TrueFeature=true
feature-management.FeatureSample.enabled-for[2].Name=Filter@3
feature-management.FeatureSample.enabled-for[0].Parameters.paramforfilter1=value1
feature-management.FeatureSample.enabled-for[3].Parameters.EmptyValue=
feature-management.FalseFeature=false
feature-management.FeatureSample.enabled-for[1].Name=Filter2
feature-management.FeatureSample.enabled-for[2].Name=Filter@3
feature-management.TrueFeature=true
feature-management.FeatureSample.enabled-for[3].Name=filter.4
Region=West US
Color=Red
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Color: Red
Region: West US
feature-management:
Timestamp:
enabled-for:
- Parameters:
EndTime: '2019-09-01T00:00:00Z'
StartTime: '2019-01-01T00:00:00Z'
EndTime: '2019-09-01T00:00:00Z'
Name: Local Tests
- Parameters:
EndTime: '2019-11-01T00:00:00Z'
StartTime: '2019-09-02T00:00:00Z'
EndTime: '2019-11-01T00:00:00Z'
Name: Production Tests
Beta: false
Region: West US
Color: Red

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading