Skip to content

Commit b5e68ee

Browse files
committed
Implement map-based lookup for manfiest whitelist
1 parent 8dc7176 commit b5e68ee

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

pkg/skaffold/deploy/kubectl/visitor.go

+10-15
Original file line numberDiff line numberDiff line change
@@ -23,39 +23,39 @@ import (
2323
apimachinery "k8s.io/apimachinery/pkg/runtime/schema"
2424
)
2525

26-
var transformableWhitelist = []apimachinery.GroupKind{
26+
var transformableWhitelist = map[apimachinery.GroupKind]bool{
2727
{
2828
Group: "",
2929
Kind: "Pod",
30-
},
30+
}: true,
3131
{
3232
Group: "apps",
3333
Kind: "DaemonSet",
34-
},
34+
}: true,
3535
{
3636
Group: "apps",
3737
Kind: "Deployment",
38-
},
38+
}: true,
3939
{
4040
Group: "apps",
4141
Kind: "ReplicaSet",
42-
},
42+
}: true,
4343
{
4444
Group: "apps",
4545
Kind: "StatefulSet",
46-
},
46+
}: true,
4747
{
4848
Group: "batch",
4949
Kind: "CronJob",
50-
},
50+
}: true,
5151
{
5252
Group: "batch",
5353
Kind: "Job",
54-
},
54+
}: true,
5555
{
5656
Group: "serving.knative.dev",
5757
Kind: "Service",
58-
},
58+
}: true,
5959
}
6060

6161
// FieldVisitor represents the aggregation/transformation that should be performed on each traversed field.
@@ -123,12 +123,7 @@ func shouldTransformManifest(manifest map[interface{}]interface{}) bool {
123123
Kind: gvk.Kind,
124124
}
125125

126-
for _, allowedGroupKind := range transformableWhitelist {
127-
if groupKind == allowedGroupKind {
128-
return true
129-
}
130-
}
131-
return false
126+
return transformableWhitelist[groupKind]
132127
}
133128

134129
// recursiveVisitorDecorator adds recursion to a FieldVisitor.

0 commit comments

Comments
 (0)