From 0d5d221ef32b043b38dce62f32274828caca7cc7 Mon Sep 17 00:00:00 2001 From: Christophe de Dinechin Date: Thu, 10 Sep 2020 19:47:41 +0200 Subject: [PATCH] annotations: Rename checkPathIsInGlobList with checkPathIsInGlobs The name is shorter and more specific Fixes: #3004 Suggested-by: James O.D. Hunt Signed-off-by: Christophe de Dinechin --- virtcontainers/pkg/oci/utils.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/virtcontainers/pkg/oci/utils.go b/virtcontainers/pkg/oci/utils.go index a9979db8ad..4d3ae4750e 100644 --- a/virtcontainers/pkg/oci/utils.go +++ b/virtcontainers/pkg/oci/utils.go @@ -212,8 +212,8 @@ func regexpContains(s []string, e string) bool { return false } -func checkPathIsInGlobList(list []string, path string) bool { - for _, glob := range list { +func checkPathIsInGlobs(globs []string, path string) bool { + for _, glob := range globs { filenames, _ := filepath.Glob(glob) for _, a := range filenames { if path == a { @@ -422,21 +422,21 @@ func addHypervisorConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig, } if value, ok := ocispec.Annotations[vcAnnotations.HypervisorPath]; ok { - if !checkPathIsInGlobList(runtime.HypervisorConfig.HypervisorPathList, value) { + if !checkPathIsInGlobs(runtime.HypervisorConfig.HypervisorPathList, value) { return fmt.Errorf("hypervisor %v required from annotation is not valid", value) } config.HypervisorConfig.HypervisorPath = value } if value, ok := ocispec.Annotations[vcAnnotations.JailerPath]; ok { - if !checkPathIsInGlobList(runtime.HypervisorConfig.JailerPathList, value) { + if !checkPathIsInGlobs(runtime.HypervisorConfig.JailerPathList, value) { return fmt.Errorf("jailer %v required from annotation is not valid", value) } config.HypervisorConfig.JailerPath = value } if value, ok := ocispec.Annotations[vcAnnotations.CtlPath]; ok { - if !checkPathIsInGlobList(runtime.HypervisorConfig.HypervisorCtlPathList, value) { + if !checkPathIsInGlobs(runtime.HypervisorConfig.HypervisorCtlPathList, value) { return fmt.Errorf("hypervisor control %v required from annotation is not valid", value) } config.HypervisorConfig.HypervisorCtlPath = value @@ -475,7 +475,7 @@ func addHypervisorConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig, } if value, ok := ocispec.Annotations[vcAnnotations.VhostUserStorePath]; ok { - if !checkPathIsInGlobList(runtime.HypervisorConfig.VhostUserStorePathList, value) { + if !checkPathIsInGlobs(runtime.HypervisorConfig.VhostUserStorePathList, value) { return fmt.Errorf("vhost store path %v required from annotation is not valid", value) } config.HypervisorConfig.VhostUserStorePath = value @@ -591,7 +591,7 @@ func addHypervisorMemoryOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConfig } if value, ok := ocispec.Annotations[vcAnnotations.FileBackedMemRootDir]; ok { - if !checkPathIsInGlobList(runtime.HypervisorConfig.FileBackedMemRootList, value) { + if !checkPathIsInGlobs(runtime.HypervisorConfig.FileBackedMemRootList, value) { return fmt.Errorf("file_mem_backend value %v required from annotation is not valid", value) } sbConfig.HypervisorConfig.FileBackedMemRootDir = value @@ -729,7 +729,7 @@ func addHypervisorVirtioFsOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConf } if value, ok := ocispec.Annotations[vcAnnotations.VirtioFSDaemon]; ok { - if !checkPathIsInGlobList(runtime.HypervisorConfig.VirtioFSDaemonList, value) { + if !checkPathIsInGlobs(runtime.HypervisorConfig.VirtioFSDaemonList, value) { return fmt.Errorf("virtiofs daemon %v required from annotation is not valid", value) } sbConfig.HypervisorConfig.VirtioFSDaemon = value