mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Merge pull request #116179 from justinsb/visiteduids_deprecation
cleanup: replace deprecated sets.String
This commit is contained in:
commit
096e67d30e
@ -121,8 +121,8 @@ type ApplyOptions struct {
|
|||||||
|
|
||||||
// Stores visited objects/namespaces for later use
|
// Stores visited objects/namespaces for later use
|
||||||
// calculating the set of objects to prune.
|
// calculating the set of objects to prune.
|
||||||
VisitedUids sets.String
|
VisitedUids sets.Set[types.UID]
|
||||||
VisitedNamespaces sets.String
|
VisitedNamespaces sets.Set[string]
|
||||||
|
|
||||||
// Function run after the objects are generated and
|
// Function run after the objects are generated and
|
||||||
// stored in the "objects" field, but before the
|
// stored in the "objects" field, but before the
|
||||||
@ -352,8 +352,8 @@ func (flags *ApplyFlags) ToOptions(f cmdutil.Factory, cmd *cobra.Command, baseNa
|
|||||||
objects: []*resource.Info{},
|
objects: []*resource.Info{},
|
||||||
objectsCached: false,
|
objectsCached: false,
|
||||||
|
|
||||||
VisitedUids: sets.NewString(),
|
VisitedUids: sets.New[types.UID](),
|
||||||
VisitedNamespaces: sets.NewString(),
|
VisitedNamespaces: sets.New[string](),
|
||||||
|
|
||||||
ApplySet: applySet,
|
ApplySet: applySet,
|
||||||
}
|
}
|
||||||
@ -981,7 +981,7 @@ func (o *ApplyOptions) MarkObjectVisited(info *resource.Info) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
o.VisitedUids.Insert(string(metadata.GetUID()))
|
o.VisitedUids.Insert(metadata.GetUID())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/cli-runtime/pkg/printers"
|
"k8s.io/cli-runtime/pkg/printers"
|
||||||
"k8s.io/client-go/dynamic"
|
"k8s.io/client-go/dynamic"
|
||||||
@ -35,8 +36,8 @@ type pruner struct {
|
|||||||
mapper meta.RESTMapper
|
mapper meta.RESTMapper
|
||||||
dynamicClient dynamic.Interface
|
dynamicClient dynamic.Interface
|
||||||
|
|
||||||
visitedUids sets.String
|
visitedUids sets.Set[types.UID]
|
||||||
visitedNamespaces sets.String
|
visitedNamespaces sets.Set[string]
|
||||||
labelSelector string
|
labelSelector string
|
||||||
fieldSelector string
|
fieldSelector string
|
||||||
|
|
||||||
@ -119,7 +120,7 @@ func (p *pruner) prune(namespace string, mapping *meta.RESTMapping) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
uid := metadata.GetUID()
|
uid := metadata.GetUID()
|
||||||
if p.visitedUids.Has(string(uid)) {
|
if p.visitedUids.Has(uid) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
name := metadata.GetName()
|
name := metadata.GetName()
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/cli-runtime/pkg/resource"
|
"k8s.io/cli-runtime/pkg/resource"
|
||||||
"k8s.io/client-go/dynamic"
|
"k8s.io/client-go/dynamic"
|
||||||
@ -34,16 +35,16 @@ type pruner struct {
|
|||||||
mapper meta.RESTMapper
|
mapper meta.RESTMapper
|
||||||
dynamicClient dynamic.Interface
|
dynamicClient dynamic.Interface
|
||||||
|
|
||||||
visitedUids sets.String
|
visitedUids sets.Set[types.UID]
|
||||||
visitedNamespaces sets.String
|
visitedNamespaces sets.Set[string]
|
||||||
labelSelector string
|
labelSelector string
|
||||||
resources []prune.Resource
|
resources []prune.Resource
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPruner(dc dynamic.Interface, m meta.RESTMapper, r []prune.Resource, selector string) *pruner {
|
func newPruner(dc dynamic.Interface, m meta.RESTMapper, r []prune.Resource, selector string) *pruner {
|
||||||
return &pruner{
|
return &pruner{
|
||||||
visitedUids: sets.NewString(),
|
visitedUids: sets.New[types.UID](),
|
||||||
visitedNamespaces: sets.NewString(),
|
visitedNamespaces: sets.New[string](),
|
||||||
dynamicClient: dc,
|
dynamicClient: dc,
|
||||||
mapper: m,
|
mapper: m,
|
||||||
resources: r,
|
resources: r,
|
||||||
@ -104,7 +105,7 @@ func (p *pruner) prune(namespace string, mapping *meta.RESTMapping) ([]runtime.O
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
uid := metadata.GetUID()
|
uid := metadata.GetUID()
|
||||||
if p.visitedUids.Has(string(uid)) {
|
if p.visitedUids.Has(uid) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,5 +124,5 @@ func (p *pruner) MarkVisited(info *resource.Info) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p.visitedUids.Insert(string(metadata.GetUID()))
|
p.visitedUids.Insert(metadata.GetUID())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user