From 9b98c26a801d711acdaf622e40d299a14611aefa Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Mon, 19 Mar 2018 18:52:33 +0000 Subject: [PATCH] lint: Fix virtcontainers `maligned` errors Correct `maligned` linter issues. Signed-off-by: James O. D. Hunt --- virtcontainers/hypervisor.go | 36 +++++++++++++------------- virtcontainers/pkg/hyperstart/types.go | 34 ++++++++++++++---------- virtcontainers/pod.go | 16 ++++++------ 3 files changed, 46 insertions(+), 40 deletions(-) diff --git a/virtcontainers/hypervisor.go b/virtcontainers/hypervisor.go index e9538b9b33..d341640731 100644 --- a/virtcontainers/hypervisor.go +++ b/virtcontainers/hypervisor.go @@ -145,6 +145,12 @@ type Param struct { // HypervisorConfig is the hypervisor configuration. type HypervisorConfig struct { + // KernelParams are additional guest kernel parameters. + KernelParams []Param + + // HypervisorParams are additional hypervisor parameters. + HypervisorParams []Param + // KernelPath is the guest kernel host path. KernelPath string @@ -160,26 +166,19 @@ type HypervisorConfig struct { // HypervisorPath is the hypervisor executable host path. HypervisorPath string - // DisableBlockDeviceUse disallows a block device from being used. - DisableBlockDeviceUse bool - // BlockDeviceDriver specifies the driver to be used for block device // either VirtioSCSI or VirtioBlock with the default driver being defaultBlockDriver BlockDeviceDriver string - // KernelParams are additional guest kernel parameters. - KernelParams []Param - - // HypervisorParams are additional hypervisor parameters. - HypervisorParams []Param - // HypervisorMachineType specifies the type of machine being // emulated. HypervisorMachineType string - // Debug changes the default hypervisor and kernel parameters to - // enable debug output where available. - Debug bool + // customAssets is a map of assets. + // Each value in that map takes precedence over the configured assets. + // For example, if there is a value for the "kernel" key in this map, + // it will be used for the pod's kernel path instead of KernelPath. + customAssets map[assetType]*asset // DefaultVCPUs specifies default number of vCPUs for the VM. DefaultVCPUs uint32 @@ -195,6 +194,13 @@ type HypervisorConfig struct { // Bridges can be used to hot plug devices DefaultBridges uint32 + // DisableBlockDeviceUse disallows a block device from being used. + DisableBlockDeviceUse bool + + // Debug changes the default hypervisor and kernel parameters to + // enable debug output where available. + Debug bool + // MemPrealloc specifies if the memory should be pre-allocated MemPrealloc bool @@ -212,12 +218,6 @@ type HypervisorConfig struct { // DisableNestingChecks is used to override customizations performed // when running on top of another VMM. DisableNestingChecks bool - - // customAssets is a map of assets. - // Each value in that map takes precedence over the configured assets. - // For example, if there is a value for the "kernel" key in this map, - // it will be used for the pod's kernel path instead of KernelPath. - customAssets map[assetType]*asset } func (conf *HypervisorConfig) valid() (bool, error) { diff --git a/virtcontainers/pkg/hyperstart/types.go b/virtcontainers/pkg/hyperstart/types.go index 5f87b90aa0..b3f407b839 100644 --- a/virtcontainers/pkg/hyperstart/types.go +++ b/virtcontainers/pkg/hyperstart/types.go @@ -168,28 +168,34 @@ type Capabilities struct { // Process describes a process running on a container inside a pod. type Process struct { - User string `json:"user,omitempty"` - Group string `json:"group,omitempty"` + // Args specifies the binary and arguments for the application to execute. + Args []string `json:"args"` + + // Rlimits specifies rlimit options to apply to the process. + Rlimits []Rlimit `json:"rlimits,omitempty"` + + // Envs populates the process environment for the process. + Envs []EnvironmentVar `json:"envs,omitempty"` + AdditionalGroups []string `json:"additionalGroups,omitempty"` - // Terminal creates an interactive terminal for the process. - Terminal bool `json:"terminal"` + + // Workdir is the current working directory for the process and must be + // relative to the container's root. + Workdir string `json:"workdir"` + + User string `json:"user,omitempty"` + Group string `json:"group,omitempty"` // Sequeue number for stdin and stdout Stdio uint64 `json:"stdio,omitempty"` // Sequeue number for stderr if it is not shared with stdout Stderr uint64 `json:"stderr,omitempty"` - // Args specifies the binary and arguments for the application to execute. - Args []string `json:"args"` - // Envs populates the process environment for the process. - Envs []EnvironmentVar `json:"envs,omitempty"` - // Workdir is the current working directory for the process and must be - // relative to the container's root. - Workdir string `json:"workdir"` - // Rlimits specifies rlimit options to apply to the process. - Rlimits []Rlimit `json:"rlimits,omitempty"` // NoNewPrivileges indicates that the process should not gain any additional privileges + Capabilities Capabilities `json:"capabilities"` + NoNewPrivileges bool `json:"noNewPrivileges"` // Capabilities specifies the sets of capabilities for the process(es) inside the container. - Capabilities Capabilities `json:"capabilities"` + // Terminal creates an interactive terminal for the process. + Terminal bool `json:"terminal"` } // SystemMountsInfo describes additional information for system mounts that the agent diff --git a/virtcontainers/pod.go b/virtcontainers/pod.go index 778c729916..e0779477be 100644 --- a/virtcontainers/pod.go +++ b/virtcontainers/pod.go @@ -274,9 +274,9 @@ type LinuxCapabilities struct { // Cmd represents a command to execute in a running container. type Cmd struct { - Args []string - Envs []EnvVar - WorkDir string + Args []string + Envs []EnvVar + SupplementaryGroups []string // Note that these fields *MUST* remain as strings. // @@ -300,15 +300,15 @@ type Cmd struct { // all the user and group mapping is handled by the container manager // and specified to the runtime in terms of UID/GID's in the // configuration file generated by the container manager. - User string - PrimaryGroup string - SupplementaryGroups []string + User string + PrimaryGroup string + WorkDir string + Console string + Capabilities LinuxCapabilities Interactive bool - Console string Detach bool NoNewPrivileges bool - Capabilities LinuxCapabilities } // Resources describes VM resources configuration.