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

Commit

Permalink
config: Rename 'runtime' to 'runtimeConfig'
Browse files Browse the repository at this point in the history
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 <archana.m.shinde@intel.com>
Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
  • Loading branch information
c3d authored and fidencio committed Nov 11, 2020
1 parent 7c1bf82 commit c2cbceb
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions virtcontainers/pkg/oci/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,21 +364,21 @@ 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)
}
}
err := addAssetAnnotations(ocispec, config)
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
}

Expand All @@ -404,24 +404,24 @@ 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
}

if err := addHypervisorBlockOverrides(ocispec, config); err != nil {
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
}

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand All @@ -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,

Expand All @@ -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
}

Expand Down

0 comments on commit c2cbceb

Please sign in to comment.