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:
Fish-pro 2023-02-16 22:05:48 +08:00 committed by GitHub
parent 1cdd61fb94
commit ac8dd3dd53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 18 additions and 18 deletions

View file

@ -541,11 +541,11 @@ func (n *NGINXController) getDefaultUpstream() *ingress.Backend {
}
// 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)
var passUpstreams []*ingress.SSLPassthroughBackend
hosts := sets.NewString()
hosts := sets.New[string]()
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

View file

@ -37,13 +37,13 @@ type ObjectRefMap interface {
type objectRefMap struct {
sync.Mutex
v map[string]sets.String
v map[string]sets.Set[string]
}
// NewObjectRefMap returns a new ObjectRefMap.
func NewObjectRefMap() 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 {
if _, ok := o.v[r]; !ok {
o.v[r] = sets.NewString(consumer)
o.v[r] = sets.New[string](consumer)
continue
}
o.v[r].Insert(consumer)
@ -112,7 +112,7 @@ func (o *objectRefMap) Reference(ref string) []string {
if !ok {
return make([]string, 0)
}
return consumers.List()
return consumers.UnsortedList()
}
// ReferencedBy returns all objects referenced by the given object.

View file

@ -792,7 +792,7 @@ rewrite "(?i)%s" %s break;
func filterRateLimits(input interface{}) []ratelimit.Config {
ratelimits := []ratelimit.Config{}
found := sets.String{}
found := sets.Set[string]{}
servers, ok := input.([]*ingress.Server)
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
// one for limiting requests per second.
func buildRateLimitZones(input interface{}) []string {
zones := sets.String{}
zones := sets.Set[string]{}
servers, ok := input.([]*ingress.Server)
if !ok {
klog.Errorf("expected a '[]*ingress.Server' type but %T was returned", input)
return zones.List()
return zones.UnsortedList()
}
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
@ -1654,7 +1654,7 @@ func buildModSecurityForLocation(cfg config.Configuration, location *ingress.Loc
func buildMirrorLocations(locs []*ingress.Location) string {
var buffer bytes.Buffer
mapped := sets.String{}
mapped := sets.Set[string]{}
for _, loc := range locs {
if loc.Mirror.Source == "" || loc.Mirror.Target == "" {