mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 07:27:21 +00:00
Skip visiting empty secret and configmap names
This commit is contained in:
@@ -365,6 +365,21 @@ func TestPodSecrets(t *testing.T) {
|
||||
t.Logf("Extra secret names:\n%s", strings.Join(extraNames.List(), "\n"))
|
||||
t.Error("Extra secret names extracted. Verify VisitPodSecretNames() is correctly extracting secret names")
|
||||
}
|
||||
|
||||
// emptyPod is a stub containing empty object names
|
||||
emptyPod := &api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{{
|
||||
EnvFrom: []api.EnvFromSource{{
|
||||
SecretRef: &api.SecretEnvSource{
|
||||
LocalObjectReference: api.LocalObjectReference{
|
||||
Name: ""}}}}}},
|
||||
},
|
||||
}
|
||||
VisitPodSecretNames(emptyPod, func(name string) bool {
|
||||
t.Fatalf("expected no empty names collected, got %q", name)
|
||||
return false
|
||||
}, AllContainers)
|
||||
}
|
||||
|
||||
// collectResourcePaths traverses the object, computing all the struct paths that lead to fields with resourcename in the name.
|
||||
@@ -494,6 +509,21 @@ func TestPodConfigmaps(t *testing.T) {
|
||||
t.Logf("Extra names:\n%s", strings.Join(extraNames.List(), "\n"))
|
||||
t.Error("Extra names extracted. Verify VisitPodConfigmapNames() is correctly extracting resource names")
|
||||
}
|
||||
|
||||
// emptyPod is a stub containing empty object names
|
||||
emptyPod := &api.Pod{
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{{
|
||||
EnvFrom: []api.EnvFromSource{{
|
||||
ConfigMapRef: &api.ConfigMapEnvSource{
|
||||
LocalObjectReference: api.LocalObjectReference{
|
||||
Name: ""}}}}}},
|
||||
},
|
||||
}
|
||||
VisitPodConfigmapNames(emptyPod, func(name string) bool {
|
||||
t.Fatalf("expected no empty names collected, got %q", name)
|
||||
return false
|
||||
}, AllContainers)
|
||||
}
|
||||
|
||||
func TestDropFSGroupFields(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user