From b6f45c480656ad54b09c655d740337a7f7f3af28 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 | 66 ++++++++++++++++----------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/virtcontainers/pkg/oci/utils.go b/virtcontainers/pkg/oci/utils.go index 8e6a3dbc10..28ac1b114f 100644 --- a/virtcontainers/pkg/oci/utils.go +++ b/virtcontainers/pkg/oci/utils.go @@ -367,9 +367,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) } } @@ -377,11 +377,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 } @@ -407,12 +407,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 } @@ -420,11 +420,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 } @@ -456,7 +456,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 @@ -512,23 +512,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 @@ -547,7 +547,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 { @@ -607,7 +607,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 @@ -746,7 +746,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 @@ -763,7 +763,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 @@ -798,7 +798,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 { @@ -893,7 +893,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 @@ -904,7 +904,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 } @@ -914,17 +914,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, @@ -938,19 +938,19 @@ func SandboxConfig(ocispec specs.Spec, runtime RuntimeConfig, bundlePath, cid, c SystemdCgroup: systemdCgroup, - SandboxCgroupOnly: runtime.SandboxCgroupOnly, + SandboxCgroupOnly: runtimeConfig.SandboxCgroupOnly, - EnableAgentPidNs: runtime.EnableAgentPidNs, + EnableAgentPidNs: runtimeConfig.EnableAgentPidNs, - 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 }