You've already forked postgres_exporter
							
							
				mirror of
				https://github.com/prometheus-community/postgres_exporter.git
				synced 2025-11-03 07:53:12 +03:00 
			
		
		
		
	Replace another custom implementation of slices.Contains (#1180)
				
					
				
			Followup of https://github.com/prometheus-community/postgres_exporter/pull/1176 Signed-off-by: Cristian Greco <cristian@regolo.cc>
This commit is contained in:
		@@ -18,6 +18,7 @@ import (
 | 
				
			|||||||
	"net/url"
 | 
						"net/url"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"regexp"
 | 
						"regexp"
 | 
				
			||||||
 | 
						"slices"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/prometheus/client_golang/prometheus"
 | 
						"github.com/prometheus/client_golang/prometheus"
 | 
				
			||||||
@@ -64,11 +65,11 @@ func (e *Exporter) discoverDatabaseDSNs() []string {
 | 
				
			|||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		for _, databaseName := range databaseNames {
 | 
							for _, databaseName := range databaseNames {
 | 
				
			||||||
			if contains(e.excludeDatabases, databaseName) {
 | 
								if slices.Contains(e.excludeDatabases, databaseName) {
 | 
				
			||||||
				continue
 | 
									continue
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if len(e.includeDatabases) != 0 && !contains(e.includeDatabases, databaseName) {
 | 
								if len(e.includeDatabases) != 0 && !slices.Contains(e.includeDatabases, databaseName) {
 | 
				
			||||||
				continue
 | 
									continue
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,15 +24,6 @@ import (
 | 
				
			|||||||
	"github.com/lib/pq"
 | 
						"github.com/lib/pq"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func contains(a []string, x string) bool {
 | 
					 | 
				
			||||||
	for _, n := range a {
 | 
					 | 
				
			||||||
		if x == n {
 | 
					 | 
				
			||||||
			return true
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return false
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// convert a string to the corresponding ColumnUsage
 | 
					// convert a string to the corresponding ColumnUsage
 | 
				
			||||||
func stringToColumnUsage(s string) (ColumnUsage, error) {
 | 
					func stringToColumnUsage(s string) (ColumnUsage, error) {
 | 
				
			||||||
	var u ColumnUsage
 | 
						var u ColumnUsage
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user