Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
annotations: Rename checkPathIsInGlobList with checkPathIsInGlobs
Browse files Browse the repository at this point in the history
The name is shorter and more specific

Fixes: #3004

Suggested-by: James O.D. Hunt <james.o.hunt@intel.com>
Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
  • Loading branch information
c3d authored and fidencio committed Nov 11, 2020
1 parent 179325d commit 0609d2d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions virtcontainers/pkg/oci/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,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 {
Expand Down Expand Up @@ -425,21 +425,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
Expand Down Expand Up @@ -484,7 +484,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
Expand Down Expand Up @@ -600,7 +600,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
Expand Down Expand Up @@ -756,7 +756,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
Expand Down

0 comments on commit 0609d2d

Please sign in to comment.