mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/awsapi: remove whitelist arg from GetFiltersQueryString(), since it may break new filters in the future
Let users decide which filters to use. If users start using disallowed filters, then AWS will return an error.
This commit is contained in:
parent
84326eacd6
commit
9ea3f0c0d3
3 changed files with 3 additions and 22 deletions
|
@ -427,15 +427,10 @@ func buildAPIEndpoint(customEndpoint, region, service string) string {
|
|||
}
|
||||
|
||||
// GetFiltersQueryString returns query string formed from the given filters.
|
||||
//
|
||||
// If whitelist isn't nil, then filters which don't fall into whitelist isn't returned.
|
||||
func GetFiltersQueryString(filters []Filter, whitelist map[string]bool) string {
|
||||
func GetFiltersQueryString(filters []Filter) string {
|
||||
// See how to build filters query string at examples at https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html
|
||||
var args []string
|
||||
for i, f := range filters {
|
||||
if whitelist != nil && !whitelist[f.Name] {
|
||||
continue
|
||||
}
|
||||
args = append(args, fmt.Sprintf("Filter.%d.Name=%s", i+1, url.QueryEscape(f.Name)))
|
||||
for j, v := range f.Values {
|
||||
args = append(args, fmt.Sprintf("Filter.%d.Value.%d=%s", i+1, j+1, url.QueryEscape(v)))
|
||||
|
|
|
@ -30,7 +30,7 @@ func getAZMap(cfg *apiConfig) map[string]string {
|
|||
|
||||
func getAvailabilityZones(cfg *apiConfig) ([]AvailabilityZone, error) {
|
||||
// See https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeAvailabilityZones.html
|
||||
azFilters := awsapi.GetFiltersQueryString(cfg.azFilters, azFiltersWhitelist)
|
||||
azFilters := awsapi.GetFiltersQueryString(cfg.azFilters)
|
||||
data, err := cfg.awsConfig.GetEC2APIResponse("DescribeAvailabilityZones", azFilters, "")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot obtain availability zones: %w", err)
|
||||
|
@ -42,20 +42,6 @@ func getAvailabilityZones(cfg *apiConfig) ([]AvailabilityZone, error) {
|
|||
return azr.AvailabilityZoneInfo.Items, nil
|
||||
}
|
||||
|
||||
// See https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeAvailabilityZones.html
|
||||
var azFiltersWhitelist = map[string]bool{
|
||||
"group-name": true,
|
||||
"message": true,
|
||||
"opt-in-status": true,
|
||||
"parent-zoneID": true,
|
||||
"parent-zoneName": true,
|
||||
"region-name": true,
|
||||
"state": true,
|
||||
"zone-id": true,
|
||||
"zone-type": true,
|
||||
"zone-name": true,
|
||||
}
|
||||
|
||||
// AvailabilityZonesResponse represents the response for https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeAvailabilityZones.html
|
||||
type AvailabilityZonesResponse struct {
|
||||
AvailabilityZoneInfo AvailabilityZoneInfo `xml:"availabilityZoneInfo"`
|
||||
|
|
|
@ -29,7 +29,7 @@ func getReservations(cfg *apiConfig) ([]Reservation, error) {
|
|||
// See https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeInstances.html
|
||||
var rs []Reservation
|
||||
pageToken := ""
|
||||
instanceFilters := awsapi.GetFiltersQueryString(cfg.instanceFilters, nil)
|
||||
instanceFilters := awsapi.GetFiltersQueryString(cfg.instanceFilters)
|
||||
for {
|
||||
data, err := cfg.awsConfig.GetEC2APIResponse("DescribeInstances", instanceFilters, pageToken)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue