mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 06:09:39 +08:00
Automatic merge from release/2.0.0 -> release/2.1.0
* commit 'cb814816551a25ec5b81cf02f4cd4e839af7107d': auth token add list endpoints method
This commit is contained in:
@@ -11,6 +11,15 @@ type ExternalService struct {
|
||||
Url string
|
||||
}
|
||||
|
||||
type Endpoint struct {
|
||||
Id string
|
||||
RegionId string
|
||||
ServiceId string
|
||||
ServiceName string
|
||||
Url string
|
||||
Interface string
|
||||
}
|
||||
|
||||
type TokenCredential interface {
|
||||
gotypes.ISerializable
|
||||
|
||||
@@ -33,4 +42,5 @@ type TokenCredential interface {
|
||||
GetServiceURL(service, region, zone, endpointType string) (string, error)
|
||||
GetInternalServices(region string) []string
|
||||
GetExternalServices(region string) []ExternalService
|
||||
GetEndpoints(region string, endpointType string) []Endpoint
|
||||
}
|
||||
|
||||
@@ -144,6 +144,10 @@ func (this *TokenCredentialV2) GetExternalServices(region string) []ExternalServ
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *TokenCredentialV2) GetEndpoints(region string, endpointType string) []Endpoint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func stringArrayContains(arr []string, needle string) bool {
|
||||
for i := 0; i < len(arr); i++ {
|
||||
if arr[i] == needle {
|
||||
|
||||
@@ -152,6 +152,10 @@ func (this *TokenCredentialV3) GetExternalServices(region string) []ExternalServ
|
||||
return this.Token.Catalog.getExternalServices(region)
|
||||
}
|
||||
|
||||
func (this *TokenCredentialV3) GetEndpoints(region string, endpointType string) []Endpoint {
|
||||
return this.Token.Catalog.getEndpoints(region, endpointType)
|
||||
}
|
||||
|
||||
func (catalog KeystoneServiceCatalogV3) getInternalServices(region string) []string {
|
||||
services := make([]string, 0)
|
||||
for i := 0; i < len(catalog); i++ {
|
||||
@@ -200,6 +204,27 @@ func (catalog KeystoneServiceCatalogV3) getRegions() []string {
|
||||
return regions
|
||||
}
|
||||
|
||||
func (catalog KeystoneServiceCatalogV3) getEndpoints(region string, endpointType string) []Endpoint {
|
||||
endpoints := make([]Endpoint, 0)
|
||||
for i := 0; i < len(catalog); i++ {
|
||||
for j := 0; j < len(catalog[i].Endpoints); j++ {
|
||||
endpoint := catalog[i].Endpoints[j]
|
||||
if (endpoint.Region_id == region || strings.HasPrefix(endpoint.Region_id, region+"-")) && endpoint.Interface == endpointType {
|
||||
endpoints = append(endpoints, Endpoint{
|
||||
endpoint.Id,
|
||||
endpoint.Region_id,
|
||||
catalog[i].Id,
|
||||
catalog[i].Name,
|
||||
endpoint.Url,
|
||||
endpoint.Interface,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return endpoints
|
||||
}
|
||||
|
||||
func RegionID(region, zone string) string {
|
||||
if len(zone) > 0 {
|
||||
return fmt.Sprintf("%s%c%s", region, REGION_ZONE_SEP, zone)
|
||||
|
||||
@@ -104,6 +104,10 @@ func (self *SSimpleToken) GetExternalServices(region string) []ExternalService {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *SSimpleToken) GetEndpoints(region string, endpointType string) []Endpoint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func SimplifyToken(token TokenCredential) TokenCredential {
|
||||
simToken, ok := token.(*SSimpleToken)
|
||||
if ok {
|
||||
|
||||
Reference in New Issue
Block a user