From c2cbceb0d15d541bdb6d7225e8532407fd1655f6 Mon Sep 17 00:00:00 2001 From: Christophe de Dinechin Date: Tue, 27 Oct 2020 13:44:11 +0100 Subject: [PATCH] config: Rename 'runtime' to 'runtimeConfig' This was suggested for consistency in other code. For consistency within the file, this also changes the existing usage in that file, where `func SandboxConfig` used `runtime` for a long time. Suggested-by: Archana Shinde Signed-off-by: Christophe de Dinechin --- virtcontainers/pkg/oci/utils.go | 64 ++++++++++++++++----------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/virtcontainers/pkg/oci/utils.go b/virtcontainers/pkg/oci/utils.go index 118db31eb5..936f31d8b4 100644 --- a/virtcontainers/pkg/oci/utils.go +++ b/virtcontainers/pkg/oci/utils.go @@ -364,9 +364,9 @@ func SandboxID(spec specs.Spec) (string, error) { return "", fmt.Errorf("Could not find sandbox ID") } -func addAnnotations(ocispec specs.Spec, config *vc.SandboxConfig, runtime RuntimeConfig) error { +func addAnnotations(ocispec specs.Spec, config *vc.SandboxConfig, runtimeConfig RuntimeConfig) error { for key := range ocispec.Annotations { - if !checkAnnotationNameIsValid(runtime.HypervisorConfig.EnableAnnotations, key, vcAnnotations.KataAnnotationHypervisorPrefix) { + if !checkAnnotationNameIsValid(runtimeConfig.HypervisorConfig.EnableAnnotations, key, vcAnnotations.KataAnnotationHypervisorPrefix) { return fmt.Errorf("annotation %v is not enabled", key) } } @@ -374,11 +374,11 @@ func addAnnotations(ocispec specs.Spec, config *vc.SandboxConfig, runtime Runtim if err != nil { return err } - if err := addHypervisorConfigOverrides(ocispec, config, runtime); err != nil { + if err := addHypervisorConfigOverrides(ocispec, config, runtimeConfig); err != nil { return err } - if err := addRuntimeConfigOverrides(ocispec, config, runtime); err != nil { + if err := addRuntimeConfigOverrides(ocispec, config, runtimeConfig); err != nil { return err } @@ -404,12 +404,12 @@ func addAssetAnnotations(ocispec specs.Spec, config *vc.SandboxConfig) error { return nil } -func addHypervisorConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig, runtime RuntimeConfig) error { +func addHypervisorConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig, runtimeConfig RuntimeConfig) error { if err := addHypervisorCPUOverrides(ocispec, config); err != nil { return err } - if err := addHypervisorMemoryOverrides(ocispec, config, runtime); err != nil { + if err := addHypervisorMemoryOverrides(ocispec, config, runtimeConfig); err != nil { return err } @@ -417,11 +417,11 @@ func addHypervisorConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig, return err } - if err := addHypervisorVirtioFsOverrides(ocispec, config, runtime); err != nil { + if err := addHypervisorVirtioFsOverrides(ocispec, config, runtimeConfig); err != nil { return err } - if err := addHypervisorPathOverrides(ocispec, config, runtime); err != nil { + if err := addHypervisorPathOverrides(ocispec, config, runtimeConfig); err != nil { return err } @@ -447,7 +447,7 @@ func addHypervisorConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig, } if value, ok := ocispec.Annotations[vcAnnotations.VhostUserStorePath]; ok { - if !checkPathIsInGlobs(runtime.HypervisorConfig.VhostUserStorePathList, value) { + if !checkPathIsInGlobs(runtimeConfig.HypervisorConfig.VhostUserStorePathList, value) { return fmt.Errorf("vhost store path %v required from annotation is not valid", value) } config.HypervisorConfig.VhostUserStorePath = value @@ -503,23 +503,23 @@ func addHypervisorConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig, return nil } -func addHypervisorPathOverrides(ocispec specs.Spec, config *vc.SandboxConfig, runtime RuntimeConfig) error { +func addHypervisorPathOverrides(ocispec specs.Spec, config *vc.SandboxConfig, runtimeConfig RuntimeConfig) error { if value, ok := ocispec.Annotations[vcAnnotations.HypervisorPath]; ok { - if !checkPathIsInGlobs(runtime.HypervisorConfig.HypervisorPathList, value) { + if !checkPathIsInGlobs(runtimeConfig.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 !checkPathIsInGlobs(runtime.HypervisorConfig.JailerPathList, value) { + if !checkPathIsInGlobs(runtimeConfig.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 !checkPathIsInGlobs(runtime.HypervisorConfig.HypervisorCtlPathList, value) { + if !checkPathIsInGlobs(runtimeConfig.HypervisorConfig.HypervisorCtlPathList, value) { return fmt.Errorf("hypervisor control %v required from annotation is not valid", value) } config.HypervisorConfig.HypervisorCtlPath = value @@ -538,7 +538,7 @@ func addHypervisorPathOverrides(ocispec specs.Spec, config *vc.SandboxConfig, ru return nil } -func addHypervisorMemoryOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConfig, runtime RuntimeConfig) error { +func addHypervisorMemoryOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConfig, runtimeConfig RuntimeConfig) error { if value, ok := ocispec.Annotations[vcAnnotations.DefaultMemory]; ok { memorySz, err := strconv.ParseUint(value, 10, 32) if err != nil { @@ -598,7 +598,7 @@ func addHypervisorMemoryOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConfig } if value, ok := ocispec.Annotations[vcAnnotations.FileBackedMemRootDir]; ok { - if !checkPathIsInGlobs(runtime.HypervisorConfig.FileBackedMemRootList, value) { + if !checkPathIsInGlobs(runtimeConfig.HypervisorConfig.FileBackedMemRootList, value) { return fmt.Errorf("file_mem_backend value %v required from annotation is not valid", value) } sbConfig.HypervisorConfig.FileBackedMemRootDir = value @@ -719,7 +719,7 @@ func addHypervisorBlockOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConfig) return nil } -func addHypervisorVirtioFsOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConfig, runtime RuntimeConfig) error { +func addHypervisorVirtioFsOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConfig, runtimeConfig RuntimeConfig) error { if value, ok := ocispec.Annotations[vcAnnotations.SharedFS]; ok { supportedSharedFS := []string{config.Virtio9P, config.VirtioFS} valid := false @@ -736,7 +736,7 @@ func addHypervisorVirtioFsOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConf } if value, ok := ocispec.Annotations[vcAnnotations.VirtioFSDaemon]; ok { - if !checkPathIsInGlobs(runtime.HypervisorConfig.VirtioFSDaemonList, value) { + if !checkPathIsInGlobs(runtimeConfig.HypervisorConfig.VirtioFSDaemonList, value) { return fmt.Errorf("virtiofs daemon %v required from annotation is not valid", value) } sbConfig.HypervisorConfig.VirtioFSDaemon = value @@ -771,7 +771,7 @@ func addHypervisorVirtioFsOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConf return nil } -func addRuntimeConfigOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConfig, runtime RuntimeConfig) error { +func addRuntimeConfigOverrides(ocispec specs.Spec, sbConfig *vc.SandboxConfig, runtimeConfig RuntimeConfig) error { if value, ok := ocispec.Annotations[vcAnnotations.DisableGuestSeccomp]; ok { disableGuestSeccomp, err := strconv.ParseBool(value) if err != nil { @@ -866,7 +866,7 @@ func addAgentConfigOverrides(ocispec specs.Spec, config *vc.SandboxConfig) error // SandboxConfig converts an OCI compatible runtime configuration file // to a virtcontainers sandbox configuration structure. -func SandboxConfig(ocispec specs.Spec, runtime RuntimeConfig, bundlePath, cid, console string, detach, systemdCgroup bool) (vc.SandboxConfig, error) { +func SandboxConfig(ocispec specs.Spec, runtimeConfig RuntimeConfig, bundlePath, cid, console string, detach, systemdCgroup bool) (vc.SandboxConfig, error) { containerConfig, err := ContainerConfig(ocispec, bundlePath, cid, console, detach) if err != nil { return vc.SandboxConfig{}, err @@ -877,7 +877,7 @@ func SandboxConfig(ocispec specs.Spec, runtime RuntimeConfig, bundlePath, cid, c return vc.SandboxConfig{}, err } - networkConfig, err := networkConfig(ocispec, runtime) + networkConfig, err := networkConfig(ocispec, runtimeConfig) if err != nil { return vc.SandboxConfig{}, err } @@ -887,17 +887,17 @@ func SandboxConfig(ocispec specs.Spec, runtime RuntimeConfig, bundlePath, cid, c Hostname: ocispec.Hostname, - HypervisorType: runtime.HypervisorType, - HypervisorConfig: runtime.HypervisorConfig, + HypervisorType: runtimeConfig.HypervisorType, + HypervisorConfig: runtimeConfig.HypervisorConfig, - AgentType: runtime.AgentType, - AgentConfig: runtime.AgentConfig, + AgentType: runtimeConfig.AgentType, + AgentConfig: runtimeConfig.AgentConfig, - ProxyType: runtime.ProxyType, - ProxyConfig: runtime.ProxyConfig, + ProxyType: runtimeConfig.ProxyType, + ProxyConfig: runtimeConfig.ProxyConfig, - ShimType: runtime.ShimType, - ShimConfig: runtime.ShimConfig, + ShimType: runtimeConfig.ShimType, + ShimConfig: runtimeConfig.ShimConfig, NetworkConfig: networkConfig, @@ -911,17 +911,17 @@ func SandboxConfig(ocispec specs.Spec, runtime RuntimeConfig, bundlePath, cid, c SystemdCgroup: systemdCgroup, - SandboxCgroupOnly: runtime.SandboxCgroupOnly, + SandboxCgroupOnly: runtimeConfig.SandboxCgroupOnly, - DisableGuestSeccomp: runtime.DisableGuestSeccomp, + DisableGuestSeccomp: runtimeConfig.DisableGuestSeccomp, // Q: Is this really necessary? @weizhang555 // Spec: &ocispec, - Experimental: runtime.Experimental, + Experimental: runtimeConfig.Experimental, } - if err := addAnnotations(ocispec, &sandboxConfig, runtime); err != nil { + if err := addAnnotations(ocispec, &sandboxConfig, runtimeConfig); err != nil { return vc.SandboxConfig{}, err }