mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
optimize then function in kind visitor
Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>
This commit is contained in:
parent
5d995e3f7b
commit
0bfd6104a1
@ -39,35 +39,25 @@ type GroupKindElement schema.GroupKind
|
|||||||
|
|
||||||
// Accept calls the Visit method on visitor that corresponds to elem's Kind
|
// Accept calls the Visit method on visitor that corresponds to elem's Kind
|
||||||
func (elem GroupKindElement) Accept(visitor KindVisitor) error {
|
func (elem GroupKindElement) Accept(visitor KindVisitor) error {
|
||||||
if elem.GroupMatch("apps", "extensions") && elem.Kind == "DaemonSet" {
|
switch {
|
||||||
|
case elem.GroupMatch("apps", "extensions") && elem.Kind == "DaemonSet":
|
||||||
visitor.VisitDaemonSet(elem)
|
visitor.VisitDaemonSet(elem)
|
||||||
return nil
|
case elem.GroupMatch("apps", "extensions") && elem.Kind == "Deployment":
|
||||||
}
|
|
||||||
if elem.GroupMatch("apps", "extensions") && elem.Kind == "Deployment" {
|
|
||||||
visitor.VisitDeployment(elem)
|
visitor.VisitDeployment(elem)
|
||||||
return nil
|
case elem.GroupMatch("batch") && elem.Kind == "Job":
|
||||||
}
|
|
||||||
if elem.GroupMatch("batch") && elem.Kind == "Job" {
|
|
||||||
visitor.VisitJob(elem)
|
visitor.VisitJob(elem)
|
||||||
return nil
|
case elem.GroupMatch("", "core") && elem.Kind == "Pod":
|
||||||
}
|
|
||||||
if elem.GroupMatch("", "core") && elem.Kind == "Pod" {
|
|
||||||
visitor.VisitPod(elem)
|
visitor.VisitPod(elem)
|
||||||
return nil
|
case elem.GroupMatch("extensions") && elem.Kind == "ReplicaSet":
|
||||||
}
|
|
||||||
if elem.GroupMatch("extensions") && elem.Kind == "ReplicaSet" {
|
|
||||||
visitor.VisitReplicaSet(elem)
|
visitor.VisitReplicaSet(elem)
|
||||||
return nil
|
case elem.GroupMatch("", "core") && elem.Kind == "ReplicationController":
|
||||||
}
|
|
||||||
if elem.GroupMatch("", "core") && elem.Kind == "ReplicationController" {
|
|
||||||
visitor.VisitReplicationController(elem)
|
visitor.VisitReplicationController(elem)
|
||||||
return nil
|
case elem.GroupMatch("apps") && elem.Kind == "StatefulSet":
|
||||||
}
|
|
||||||
if elem.GroupMatch("apps") && elem.Kind == "StatefulSet" {
|
|
||||||
visitor.VisitStatefulSet(elem)
|
visitor.VisitStatefulSet(elem)
|
||||||
return nil
|
default:
|
||||||
|
return fmt.Errorf("no visitor method exists for %v", elem)
|
||||||
}
|
}
|
||||||
return fmt.Errorf("no visitor method exists for %v", elem)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GroupMatch returns true if and only if elem's group matches one
|
// GroupMatch returns true if and only if elem's group matches one
|
||||||
|
Loading…
Reference in New Issue
Block a user