@@ -154,7 +154,7 @@ func runCluster(requestedNamespace string, w *tabwriter.Writer, verbose int) (bo
154154
155155func printResources (namespace corev1.Namespace , clientset * kubernetes.Clientset , w * tabwriter.Writer , verbose int ) (bool , error ) {
156156
157- var sockFoundPod , sockFoundDeploy , sockFoundStatefulSet , sockFoundJob , sockFoundCron bool
157+ sockFound := false
158158
159159 namespaceName := namespace .ObjectMeta .Name
160160
@@ -267,13 +267,19 @@ func printResources(namespace corev1.Namespace, clientset *kubernetes.Clientset,
267267 }
268268 } else {
269269 // Look up raw pods for volumes here
270- sockFoundPod = printVolumes (w , p .Spec .Volumes , namespaceName , "pod" , p .Name , verbose )
270+ found := printVolumes (w , p .Spec .Volumes , namespaceName , "pod" , p .Name , verbose )
271+ if found {
272+ sockFound = true
273+ }
271274 }
272275 }
273276 }
274277 // loop through all the unique deployments we found for volumes
275278 for _ , deploy := range nsDeployments {
276- sockFoundDeploy = printVolumes (w , deploy .Spec .Template .Spec .Volumes , namespaceName , "deployment" , deploy .Name , verbose )
279+ found := printVolumes (w , deploy .Spec .Template .Spec .Volumes , namespaceName , "deployment" , deploy .Name , verbose )
280+ if found {
281+ sockFound = true
282+ }
277283 }
278284
279285 // loop through all the unique DaemonSets in the namespace
@@ -284,6 +290,7 @@ func printResources(namespace corev1.Namespace, clientset *kubernetes.Clientset,
284290 // fmt.Printf("testing %s\n", v.VolumeSource.HostPath.Path)
285291 if containsDockerSock (v .VolumeSource .HostPath .Path ) {
286292 fmt .Fprintf (w , "%s\t %s\t %s\t %s\t \n " , namespaceName , "daemonset" , daemonset .Name , "mounted" )
293+ sockFound = true
287294 break
288295 }
289296 }
@@ -296,27 +303,32 @@ func printResources(namespace corev1.Namespace, clientset *kubernetes.Clientset,
296303
297304 // loop through all the unique StatefulSets in the namespace
298305 for _ , statefulset := range nsStatefulsets {
299- sockFoundStatefulSet = printVolumes (w , statefulset .Spec .Template .Spec .Volumes , namespaceName , "statefulset" , statefulset .Name , verbose )
306+ found := printVolumes (w , statefulset .Spec .Template .Spec .Volumes , namespaceName , "statefulset" , statefulset .Name , verbose )
307+ if found {
308+ sockFound = true
309+ }
300310 }
301311
302312 // loop through all the unique Jobs in the namespace
303313 for _ , job := range nsJobs {
304- sockFoundJob = printVolumes (w , job .Spec .Template .Spec .Volumes , namespaceName , "job" , job .Name , verbose )
314+ found := printVolumes (w , job .Spec .Template .Spec .Volumes , namespaceName , "job" , job .Name , verbose )
315+ if found {
316+ sockFound = true
317+ }
305318 }
306319
307320 // loop through all the unique CronJobs in the namespace
308321 for _ , cron := range nsCronJobs {
309- sockFoundCron = printVolumes (w , cron .Spec .JobTemplate .Spec .Template .Spec .Volumes , namespaceName , "cron" , cron .Name , verbose )
322+ found := printVolumes (w , cron .Spec .JobTemplate .Spec .Template .Spec .Volumes , namespaceName , "cron" , cron .Name , verbose )
323+ if found {
324+ sockFound = true
325+ }
310326 }
311327
312328 if len (errorList ) > 0 {
313329 return false , utilerrors .NewAggregate (errorList )
314330 }
315- if sockFoundPod || sockFoundDeploy || sockFoundStatefulSet || sockFoundJob || sockFoundCron {
316- return true , nil
317- } else {
318- return false , nil
319- }
331+ return sockFound , nil
320332}
321333
322334func containsDockerSock (s string ) bool {
0 commit comments