登录
首页 >  Golang >  Go问答

Azure SDK for Go - 获取 KeyVault 的操作不包含 KeyVault.Properties 的属性

来源:stackoverflow

时间:2024-03-04 08:09:26 460浏览 收藏

编程并不是一个机械性的工作,而是需要有思考,有创新的工作,语法是固定的,但解决问题的思路则是依靠人的思维,这就需要我们坚持学习和更新自己的知识。今天golang学习网就整理分享《Azure SDK for Go - 获取 KeyVault 的操作不包含 KeyVault.Properties 的属性》,文章讲解的知识点主要包括,如果你对Golang方面的知识点感兴趣,就不要错过golang学习网,在这可以对大家的知识积累有所帮助,助力开发能力的提升。

问题内容

我目前正在使用 azure sdk for go。一切都很顺利,直到我遇到了以下问题:

keyvault, err := client.get(context.background(), "name_of_resource_group", "name_of_key_vault")

当我运行这个时:

log.print(*keyvault.name)

它显示了 key vault 的名称,这很好。

但是当我尝试做任何事情时:

*keyvault.properties.enablesoftdelete

我得到 - null

我可以在模型上看到 vault 属性:

type Vault struct {
    autorest.Response `json:"-"`
    // Properties - Properties of the vault
    Properties *VaultProperties `json:"properties,omitempty"`
    // ID - READ-ONLY; The Azure Resource Manager resource ID for the key vault.
    ID *string `json:"id,omitempty"`
    // Name - READ-ONLY; The name of the key vault.
    Name *string `json:"name,omitempty"`
    // Type - READ-ONLY; The resource type of the key vault.
    Type *string `json:"type,omitempty"`
    // Location - The supported Azure location where the key vault should be created.
    Location *string `json:"location,omitempty"`
    // Tags - The tags that will be assigned to the key vault.
    Tags map[string]*string `json:"tags"`
}

但无论我尝试什么,我都只是 null

任何帮助都会很棒。


解决方案


好吧,我意识到问题是什么了。

如果 enablesoftdelete 未设置或可能从未设置过,则情况并非如此:

*keyvault.properties.enablesoftdelete = false

这是真的:

*keyvault.properties.enablesoftdelete = null

因此,这是一个 azure rest api 响应,其中软删除未启用且从未禁用:

{
"id": "/subscriptions/***/resourceGroups/rg-prd-aus-dislqmwkcq/providers/Microsoft.KeyVault/vaults/kv-prd-aus-dislqmwkcq",
"name": "kv-prd-aus-dislqmwkcq",
"type": "Microsoft.KeyVault/vaults",
"location": "australiasoutheast",
"tags": {
    "example_key_vault_1": "example-kv"
},
"properties": {
    "sku": {
        "family": "A",
        "name": "premium"
    },
    "tenantId": "***",
    "networkAcls": {
        "bypass": "AzureServices",
        "defaultAction": "Deny",
        "ipRules": [
            {
                "value": "0.0.0.0/0"
            }
        ],
        "virtualNetworkRules": []
    },
    "accessPolicies": [],
    "enabledForDeployment": false,
    "enabledForDiskEncryption": false,
    "enabledForTemplateDeployment": false,
    "vaultUri": "https://***.azure.net/",
    "provisioningState": "Succeeded"
}

}

到这里,我们也就讲完了《Azure SDK for Go - 获取 KeyVault 的操作不包含 KeyVault.Properties 的属性》的内容了。个人认为,基础知识的学习和巩固,是为了更好的将其运用到项目中,欢迎关注golang学习网公众号,带你了解更多关于的知识点!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>