Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
0bfd6104
Commit
0bfd6104
authored
Sep 15, 2017
by
yuexiao-wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize then function in kind visitor
Signed-off-by:
yuexiao-wang
<
wang.yuexiao@zte.com.cn
>
parent
5d995e3f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
21 deletions
+11
-21
kind_visitor.go
pkg/kubectl/apps/kind_visitor.go
+11
-21
No files found.
pkg/kubectl/apps/kind_visitor.go
View file @
0bfd6104
...
@@ -39,35 +39,25 @@ type GroupKindElement schema.GroupKind
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment