我正在尝试使用Avi Go SDK来获取 gslb 配置。
首先如下所示初始化与控制器的连接,
aviClient, err := clients.NewAviClient("mycontroller", "USER",
session.SetPassword("PASSS"),
session.SetTenant("TENANT"),
session.SetInsecure)
if err != nil {
t.Error(err)
}
然后尝试如下获取 gslb 详细信息,
//Fetch gslb
var obj interface{}
err = aviClient.AviSession.GetObjectByName("gslbservice", "mygslbname", &obj)
fmt.Printf("%v\n", obj)
并打印如下详细信息,
map[_last_modified:1650419741251661 controller_health_status_enabled:true created_by:null description:null domain_names:[xxxxxxxxxxxxx] down_response:map[type:GSLB_SERVICE_DOWN_RESPONSE_ALL_RECORDS] enabled:true groups:[map[algorithm:GSLB_ALGORITHM_ROUND_ROBIN members:[map[cluster_uuid:xxxxxxxxxxxxxxxxxxxx enabled:true fqdn:xxxxxxxxxxxxxxxxxxxxxxxxx ip:map[addr:xxxxxxxxxxxxxxx type:V4] location:map[source:GSLB_LOCATION_SRC_INHERIT_FROM_SITE] ratio:1]] name:xxxxxxxxxxxxxxxxxxxxxxx priority:10]] health_monitor_refs:[https://xxxxxxxxxxxxxxxx] health_monitor_scope:GSLB_SERVICE_HEALTH_MONITOR_ALL_MEMBERS name:xxxxxxxxxxxxxxxx num_dns_ip:1 tenant_ref:https://xxxxxxxxxxxxxxxxxxx ttl:30 url:https://xxxxxxxxxxxxxxxxxxxx use_edns_client_subnet:true uuid:xxxxxxxxxxxxxxxxxxx wildcard_match:false]
现在我想将整个映射存储到变量中,以便我可以如下进行断言和测试,
var obj1 interface{}
appDeployment := aviClient.AviSession.GetObjectByName("gslbservice", "mygslbname", &obj1)
if err != nil {
t.Error(err)
}
assert.Equal(t, appDeployment.domain_names, "mygslbname")
我得到以下错误,
appDeployment.domain_names undefined (type error has no field or method domain_names)
任何协助?
或者如何打印地图中的任何值,例如如何打印上面地图中的 ttl 值?
犯罪嫌疑人X
慕田峪7331174
相关分类