mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #8786 from swordqiu/hotfix/qj-keystone-init-empty-catalog
fix: keystone init empty catalogy cause panic
This commit is contained in:
@@ -61,7 +61,7 @@ func policyReadFilter(session *mcclient.ClientSession, s jsonutils.JSONObject, q
|
||||
}
|
||||
|
||||
func policyWriteFilter(session *mcclient.ClientSession, s jsonutils.JSONObject, query jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
ret := jsonutils.NewDict()
|
||||
ret := s.(*jsonutils.JSONDict).CopyExcludes("policy")
|
||||
if s.Contains("policy") {
|
||||
blobJson, err := s.Get("policy")
|
||||
if err != nil {
|
||||
@@ -78,17 +78,6 @@ func policyWriteFilter(session *mcclient.ClientSession, s jsonutils.JSONObject,
|
||||
// ret.Add(jsonutils.NewString(blobJson.String()), "blob")
|
||||
ret.Add(blobJson, "blob")
|
||||
}
|
||||
for _, k := range []string{
|
||||
"name", "type", "enabled", "domain", "domain_id", "project_domain", "description", "is_public", "public_scope", "shared_domains", "scope", "is_system",
|
||||
} {
|
||||
if s.Contains(k) {
|
||||
val, err := s.Get(k)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret.Add(val, k)
|
||||
}
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/gotypes"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/identity"
|
||||
@@ -147,7 +148,11 @@ func (this *ClientSession) GetServiceVersionURL(service, endpointType, apiVersio
|
||||
endpointType = this.endpointType
|
||||
}
|
||||
service = this.getServiceName(service, apiVersion)
|
||||
url, err := this.GetServiceCatalog().GetServiceURL(service, this.region, this.zone, endpointType)
|
||||
catalog := this.GetServiceCatalog()
|
||||
if gotypes.IsNil(catalog) {
|
||||
return this.client.authUrl, nil
|
||||
}
|
||||
url, err := catalog.GetServiceURL(service, this.region, this.zone, endpointType)
|
||||
if err != nil && service == api.SERVICE_TYPE {
|
||||
return this.client.authUrl, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user