Skip to content

Commit

Permalink
Merge pull request #1013 from ioito/hotfix/qx-gcp-eip-list
Browse files Browse the repository at this point in the history
fix(gcp): eip list without internal ip
  • Loading branch information
ioito authored Jul 5, 2024
2 parents 6a30207 + 2077d73 commit 7fe0241
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/multicloud/google/eip.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package google

import (
"fmt"
"strings"
"time"

"yunion.io/x/jsonutils"
Expand Down Expand Up @@ -49,9 +50,11 @@ type SAddress struct {
func (region *SRegion) GetEips(address string, maxResults int, pageToken string) ([]SAddress, error) {
eips := []SAddress{}
params := map[string]string{}
filters := []string{"addressType=EXTERNAL"}
if len(address) > 0 {
params["filter"] = fmt.Sprintf(`address="%s"`, address)
filters = append(filters, fmt.Sprintf(`address="%s"`, address))
}
params["filter"] = strings.Join(filters, " ADN ")
resource := fmt.Sprintf("regions/%s/addresses", region.Name)
return eips, region.List(resource, params, maxResults, pageToken, &eips)
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/multicloud/google/globaleip.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,12 @@ func (addr *SGlobalAddress) GetProjectId() string {
func (region *SGlobalRegion) GetEips(address string) ([]SGlobalAddress, error) {
eips := []SGlobalAddress{}
params := map[string]string{}
filters := []string{"addressType=EXTERNAL"}
if len(address) > 0 {
params["filter"] = fmt.Sprintf(`address="%s"`, address)
filters = append(filters, fmt.Sprintf(`address="%s"`, address))
}
params["filter"] = strings.Join(filters, " ADN ")

resource := "global/addresses"

err := region.ListAll(resource, params, &eips)
Expand Down

0 comments on commit 7fe0241

Please sign in to comment.