sets.String is deprecated: use generic Set instead. new ways: s1 := Set[string]{} s2 := New[string]() (#9589)
Signed-off-by: Fish-pro <zechun.chen@daocloud.io>
This commit is contained in:
parent
1cdd61fb94
commit
ac8dd3dd53
8 changed files with 18 additions and 18 deletions
|
@ -541,11 +541,11 @@ func (n *NGINXController) getDefaultUpstream() *ingress.Backend {
|
||||||
}
|
}
|
||||||
|
|
||||||
// getConfiguration returns the configuration matching the standard kubernetes ingress
|
// getConfiguration returns the configuration matching the standard kubernetes ingress
|
||||||
func (n *NGINXController) getConfiguration(ingresses []*ingress.Ingress) (sets.String, []*ingress.Server, *ingress.Configuration) {
|
func (n *NGINXController) getConfiguration(ingresses []*ingress.Ingress) (sets.Set[string], []*ingress.Server, *ingress.Configuration) {
|
||||||
upstreams, servers := n.getBackendServers(ingresses)
|
upstreams, servers := n.getBackendServers(ingresses)
|
||||||
var passUpstreams []*ingress.SSLPassthroughBackend
|
var passUpstreams []*ingress.SSLPassthroughBackend
|
||||||
|
|
||||||
hosts := sets.NewString()
|
hosts := sets.New[string]()
|
||||||
|
|
||||||
for _, server := range servers {
|
for _, server := range servers {
|
||||||
// If a location is defined by a prefix string that ends with the slash character, and requests are processed by one of
|
// If a location is defined by a prefix string that ends with the slash character, and requests are processed by one of
|
||||||
|
|
|
@ -37,13 +37,13 @@ type ObjectRefMap interface {
|
||||||
|
|
||||||
type objectRefMap struct {
|
type objectRefMap struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
v map[string]sets.String
|
v map[string]sets.Set[string]
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewObjectRefMap returns a new ObjectRefMap.
|
// NewObjectRefMap returns a new ObjectRefMap.
|
||||||
func NewObjectRefMap() ObjectRefMap {
|
func NewObjectRefMap() ObjectRefMap {
|
||||||
return &objectRefMap{
|
return &objectRefMap{
|
||||||
v: make(map[string]sets.String),
|
v: make(map[string]sets.Set[string]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ func (o *objectRefMap) Insert(consumer string, ref ...string) {
|
||||||
|
|
||||||
for _, r := range ref {
|
for _, r := range ref {
|
||||||
if _, ok := o.v[r]; !ok {
|
if _, ok := o.v[r]; !ok {
|
||||||
o.v[r] = sets.NewString(consumer)
|
o.v[r] = sets.New[string](consumer)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
o.v[r].Insert(consumer)
|
o.v[r].Insert(consumer)
|
||||||
|
@ -112,7 +112,7 @@ func (o *objectRefMap) Reference(ref string) []string {
|
||||||
if !ok {
|
if !ok {
|
||||||
return make([]string, 0)
|
return make([]string, 0)
|
||||||
}
|
}
|
||||||
return consumers.List()
|
return consumers.UnsortedList()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReferencedBy returns all objects referenced by the given object.
|
// ReferencedBy returns all objects referenced by the given object.
|
||||||
|
|
|
@ -792,7 +792,7 @@ rewrite "(?i)%s" %s break;
|
||||||
|
|
||||||
func filterRateLimits(input interface{}) []ratelimit.Config {
|
func filterRateLimits(input interface{}) []ratelimit.Config {
|
||||||
ratelimits := []ratelimit.Config{}
|
ratelimits := []ratelimit.Config{}
|
||||||
found := sets.String{}
|
found := sets.Set[string]{}
|
||||||
|
|
||||||
servers, ok := input.([]*ingress.Server)
|
servers, ok := input.([]*ingress.Server)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -815,12 +815,12 @@ func filterRateLimits(input interface{}) []ratelimit.Config {
|
||||||
// for connection limit by IP address, one for limiting requests per minute, and
|
// for connection limit by IP address, one for limiting requests per minute, and
|
||||||
// one for limiting requests per second.
|
// one for limiting requests per second.
|
||||||
func buildRateLimitZones(input interface{}) []string {
|
func buildRateLimitZones(input interface{}) []string {
|
||||||
zones := sets.String{}
|
zones := sets.Set[string]{}
|
||||||
|
|
||||||
servers, ok := input.([]*ingress.Server)
|
servers, ok := input.([]*ingress.Server)
|
||||||
if !ok {
|
if !ok {
|
||||||
klog.Errorf("expected a '[]*ingress.Server' type but %T was returned", input)
|
klog.Errorf("expected a '[]*ingress.Server' type but %T was returned", input)
|
||||||
return zones.List()
|
return zones.UnsortedList()
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, server := range servers {
|
for _, server := range servers {
|
||||||
|
@ -859,7 +859,7 @@ func buildRateLimitZones(input interface{}) []string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return zones.List()
|
return zones.UnsortedList()
|
||||||
}
|
}
|
||||||
|
|
||||||
// buildRateLimit produces an array of limit_req to be used inside the Path of
|
// buildRateLimit produces an array of limit_req to be used inside the Path of
|
||||||
|
@ -1654,7 +1654,7 @@ func buildModSecurityForLocation(cfg config.Configuration, location *ingress.Loc
|
||||||
func buildMirrorLocations(locs []*ingress.Location) string {
|
func buildMirrorLocations(locs []*ingress.Location) string {
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
|
|
||||||
mapped := sets.String{}
|
mapped := sets.Set[string]{}
|
||||||
|
|
||||||
for _, loc := range locs {
|
for _, loc := range locs {
|
||||||
if loc.Mirror.Source == "" || loc.Mirror.Target == "" {
|
if loc.Mirror.Source == "" || loc.Mirror.Target == "" {
|
||||||
|
|
|
@ -80,7 +80,7 @@ type SocketCollector struct {
|
||||||
|
|
||||||
metricMapping map[string]interface{}
|
metricMapping map[string]interface{}
|
||||||
|
|
||||||
hosts sets.String
|
hosts sets.Set[string]
|
||||||
|
|
||||||
metricsPerHost bool
|
metricsPerHost bool
|
||||||
reportStatusClasses bool
|
reportStatusClasses bool
|
||||||
|
@ -505,7 +505,7 @@ func (sc SocketCollector) Collect(ch chan<- prometheus.Metric) {
|
||||||
|
|
||||||
// SetHosts sets the hostnames that are being served by the ingress controller
|
// SetHosts sets the hostnames that are being served by the ingress controller
|
||||||
// This set of hostnames is used to filter the metrics to be exposed
|
// This set of hostnames is used to filter the metrics to be exposed
|
||||||
func (sc *SocketCollector) SetHosts(hosts sets.String) {
|
func (sc *SocketCollector) SetHosts(hosts sets.Set[string]) {
|
||||||
sc.hosts = hosts
|
sc.hosts = hosts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -485,7 +485,7 @@ func TestCollector(t *testing.T) {
|
||||||
t.Errorf("registering collector failed: %s", err)
|
t.Errorf("registering collector failed: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sc.SetHosts(sets.NewString("testshop.com"))
|
sc.SetHosts(sets.New[string]("testshop.com"))
|
||||||
|
|
||||||
for _, d := range c.data {
|
for _, d := range c.data {
|
||||||
sc.handleMessage([]byte(d))
|
sc.handleMessage([]byte(d))
|
||||||
|
|
|
@ -69,7 +69,7 @@ func (dc DummyCollector) SetSSLInfo([]*ingress.Server) {}
|
||||||
func (dc DummyCollector) SetSSLExpireTime([]*ingress.Server) {}
|
func (dc DummyCollector) SetSSLExpireTime([]*ingress.Server) {}
|
||||||
|
|
||||||
// SetHosts ...
|
// SetHosts ...
|
||||||
func (dc DummyCollector) SetHosts(hosts sets.String) {}
|
func (dc DummyCollector) SetHosts(hosts sets.Set[string]) {}
|
||||||
|
|
||||||
// OnStartedLeading indicates the pod is not the current leader
|
// OnStartedLeading indicates the pod is not the current leader
|
||||||
func (dc DummyCollector) OnStartedLeading(electionID string) {}
|
func (dc DummyCollector) OnStartedLeading(electionID string) {}
|
||||||
|
|
|
@ -52,7 +52,7 @@ type Collector interface {
|
||||||
SetSSLInfo(servers []*ingress.Server)
|
SetSSLInfo(servers []*ingress.Server)
|
||||||
|
|
||||||
// SetHosts sets the hostnames that are being served by the ingress controller
|
// SetHosts sets the hostnames that are being served by the ingress controller
|
||||||
SetHosts(sets.String)
|
SetHosts(set sets.Set[string])
|
||||||
|
|
||||||
Start(string)
|
Start(string)
|
||||||
Stop(string)
|
Stop(string)
|
||||||
|
@ -191,7 +191,7 @@ func (c *collector) DecOrphanIngress(namespace string, name string, orphanityTyp
|
||||||
c.ingressController.DecOrphanIngress(namespace, name, orphanityType)
|
c.ingressController.DecOrphanIngress(namespace, name, orphanityType)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *collector) SetHosts(hosts sets.String) {
|
func (c *collector) SetHosts(hosts sets.Set[string]) {
|
||||||
c.socket.SetHosts(hosts)
|
c.socket.SetHosts(hosts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,7 @@ type redirect struct {
|
||||||
|
|
||||||
// BuildRedirects build the redirects of servers based on configurations and certificates
|
// BuildRedirects build the redirects of servers based on configurations and certificates
|
||||||
func BuildRedirects(servers []*ingress.Server) []*redirect {
|
func BuildRedirects(servers []*ingress.Server) []*redirect {
|
||||||
names := sets.String{}
|
names := sets.Set[string]{}
|
||||||
redirectServers := make([]*redirect, 0)
|
redirectServers := make([]*redirect, 0)
|
||||||
|
|
||||||
for _, srv := range servers {
|
for _, srv := range servers {
|
||||||
|
|
Loading…
Reference in a new issue