'KeyVault Secret Set' command unable to set tag as null
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
**Describe the bug**
Issuing a command like "az keyvault secret set --tag '' -n --vault-name "
will not set the tag as null instead it will only set it as "file-encoding": "utf-8".
Keyvault and Cli 2.0 Version:
azure-cli (2.0.33)
keyvault (2.0.22)
Below are some examples during the testing that we had:
Command:az keyvault secret set -n --vault-name --value "new_secret_value" --tags ''
{
"attributes": {
"created": "2018-06-13T01:06:59+00:00",
"enabled": true,
"expires": null,
"notBefore": null,
"recoveryLevel": "Purgeable",
"updated": "2018-06-13T01:06:59+00:00"
},
"contentType": null,
"id": "https://keyvault.vault.azure.net/secrets/Fake-Secret-connection/",
"kid": null,
"managed": null,
**"tags": {
"file-encoding": "utf-8"
},**
"value": "new_secret_value"
}
Then tried setting the tags with set-attributes command:
Command : az keyvault secret set-attributes -n --vault-name --tags""
{
"attributes": {
"created": "2018-06-13T01:07:16+00:00",
"enabled": true,
"expires": null,
"notBefore": null,
"recoveryLevel": "Purgeable",
"updated": "2018-06-13T01:07:40+00:00"
},
"contentType": null,
"id": "https://keyvault.vault.azure.net/secrets/Fake-Secret-connection/",",
"kid": null,
"managed": null,
**"tags": {},**
"value": null
}
But if we use the old version CLI 1.0 npm we can have the output that we want tags are being set to null if we will not indicate any tags and that's the way it should I believe.
Also found out the package that was causing the tags to populate in Azure CLI 2.0.
DIR: /usr/lib64/az/lib/python2.7/site-packages/azure/keyvault/model/
File: secret_bundle.py
Code:
_validation = {
'kid': {'readonly': True},
'managed': {'readonly': True},
}
_attribute_map = {
'value': {'key': 'value', 'type': 'str'},
'id': {'key': 'id', 'type': 'str'},
'content_type': {'key': 'contentType', 'type': 'str'},
'attributes': {'key': 'attributes', 'type': 'SecretAttributes'},
'tags': {'key': 'tags', 'type': '{str}'},
'kid': {'key': 'kid', 'type': 'str'},
'managed': {'key': 'managed', 'type': 'bool'},
}
def __init__(self, value=None, id=None, content_type=None, attributes=None, tags=None):
self.value = value
self.id = id
self.content_type = content_type
self.attributes = attributes
**self.tags = tags**
self.kid = None
self.managed = None
When I tried setting the self.tags to None instead of tags, azure cli 2.0 keyvault secret set command is working as it should.
Not sure if what I have above is good but please help me find a solution on this. thanks!
Contributor guide
Assessment
This issue has not been assessed yet.