diff --git a/pkg/kubectl/apps/kind_visitor.go b/pkg/kubectl/apps/kind_visitor.go index 0170883e1e5..69d1d76609d 100644 --- a/pkg/kubectl/apps/kind_visitor.go +++ b/pkg/kubectl/apps/kind_visitor.go @@ -39,35 +39,25 @@ type GroupKindElement schema.GroupKind // Accept calls the Visit method on visitor that corresponds to elem's Kind 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) - return nil - } - if elem.GroupMatch("apps", "extensions") && elem.Kind == "Deployment" { + case elem.GroupMatch("apps", "extensions") && elem.Kind == "Deployment": visitor.VisitDeployment(elem) - return nil - } - if elem.GroupMatch("batch") && elem.Kind == "Job" { + case elem.GroupMatch("batch") && elem.Kind == "Job": visitor.VisitJob(elem) - return nil - } - if elem.GroupMatch("", "core") && elem.Kind == "Pod" { + case elem.GroupMatch("", "core") && elem.Kind == "Pod": visitor.VisitPod(elem) - return nil - } - if elem.GroupMatch("extensions") && elem.Kind == "ReplicaSet" { + case elem.GroupMatch("extensions") && elem.Kind == "ReplicaSet": visitor.VisitReplicaSet(elem) - return nil - } - if elem.GroupMatch("", "core") && elem.Kind == "ReplicationController" { + case elem.GroupMatch("", "core") && elem.Kind == "ReplicationController": visitor.VisitReplicationController(elem) - return nil - } - if elem.GroupMatch("apps") && elem.Kind == "StatefulSet" { + case elem.GroupMatch("apps") && elem.Kind == "StatefulSet": 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