mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-26 23:38:31 +00:00
lint: Fix virtcontainers unused errors
Remove unused variables and functions identified by the `varcheck` and `unused` linters. Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
parent
97d2ef2712
commit
d51a5e303d
@ -37,7 +37,6 @@ const testContainer = "testContainer"
|
||||
var testCCShimPath = "/usr/bin/virtcontainers/bin/test/cc-shim"
|
||||
var testProxyURL = "foo:///foo/clear-containers/proxy.sock"
|
||||
var testWrongConsolePath = "/foo/wrong-console"
|
||||
var testConsolePath = "tty-console"
|
||||
|
||||
func getMockCCShimBinPath() string {
|
||||
if DefaultMockCCShimBinPath == "" {
|
||||
|
@ -1,30 +0,0 @@
|
||||
//
|
||||
// Copyright (c) 2017 Intel Corporation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package virtcontainers
|
||||
|
||||
type mockAddr struct {
|
||||
network string
|
||||
ipAddr string
|
||||
}
|
||||
|
||||
func (m mockAddr) Network() string {
|
||||
return m.network
|
||||
}
|
||||
|
||||
func (m mockAddr) String() string {
|
||||
return m.ipAddr
|
||||
}
|
@ -231,10 +231,6 @@ func (c *Container) storeProcess() error {
|
||||
return c.pod.storage.storeContainerProcess(c.podID, c.id, c.process)
|
||||
}
|
||||
|
||||
func (c *Container) fetchProcess() (Process, error) {
|
||||
return c.pod.storage.fetchContainerProcess(c.podID, c.id)
|
||||
}
|
||||
|
||||
func (c *Container) storeMounts() error {
|
||||
return c.pod.storage.storeContainerMounts(c.podID, c.id, c.mounts)
|
||||
}
|
||||
|
@ -46,13 +46,6 @@ var sysIOMMUPath = "/sys/kernel/iommu_groups"
|
||||
|
||||
var sysDevPrefix = "/sys/dev"
|
||||
|
||||
var blockPaths = []string{
|
||||
"/dev/sd", //SCSI block device
|
||||
"/dev/hd", //IDE block device
|
||||
"/dev/vd", //Virtual Block device
|
||||
"/dev/ida/", //Compaq Intelligent Drive Array devices
|
||||
}
|
||||
|
||||
const (
|
||||
vfioPath = "/dev/vfio/"
|
||||
)
|
||||
|
@ -20,7 +20,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
@ -860,28 +859,6 @@ var statusContainerCommand = cli.Command{
|
||||
},
|
||||
}
|
||||
|
||||
func startCCShim(process *vc.Process, shimPath, url string) error {
|
||||
if process.Token == "" {
|
||||
return fmt.Errorf("Token cannot be empty")
|
||||
}
|
||||
|
||||
if url == "" {
|
||||
return fmt.Errorf("URL cannot be empty")
|
||||
}
|
||||
|
||||
if shimPath == "" {
|
||||
return fmt.Errorf("Shim path cannot be empty")
|
||||
}
|
||||
|
||||
cmd := exec.Command(shimPath, "-t", process.Token, "-u", url)
|
||||
cmd.Env = os.Environ()
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
func main() {
|
||||
cli.VersionFlag = cli.BoolFlag{
|
||||
Name: "version",
|
||||
|
@ -40,10 +40,6 @@ var defaultSharedDir = "/run/hyper/shared/pods/"
|
||||
var mountTag = "hyperShared"
|
||||
var maxHostnameLen = 64
|
||||
|
||||
const (
|
||||
unixSocket = "unix"
|
||||
)
|
||||
|
||||
// HyperConfig is a structure storing information needed for
|
||||
// hyperstart agent initialization.
|
||||
type HyperConfig struct {
|
||||
|
@ -515,21 +515,6 @@ func (k *kataAgent) stopPod(pod Pod) error {
|
||||
return k.proxy.stop(pod, k.state.ProxyPid)
|
||||
}
|
||||
|
||||
func appendStorageFromMounts(storage []*grpc.Storage, mounts []*Mount) []*grpc.Storage {
|
||||
for _, m := range mounts {
|
||||
s := &grpc.Storage{
|
||||
Source: m.Source,
|
||||
MountPoint: m.Destination,
|
||||
Fstype: m.Type,
|
||||
Options: m.Options,
|
||||
}
|
||||
|
||||
storage = append(storage, s)
|
||||
}
|
||||
|
||||
return storage
|
||||
}
|
||||
|
||||
func (k *kataAgent) replaceOCIMountSource(spec *specs.Spec, guestMounts []Mount) error {
|
||||
ociMounts := spec.Mounts
|
||||
|
||||
|
@ -29,9 +29,6 @@ import (
|
||||
. "github.com/kata-containers/runtime/virtcontainers/pkg/mock"
|
||||
)
|
||||
|
||||
// These tests don't care about the format of the container ID
|
||||
const testKataContainer = "testContainer"
|
||||
|
||||
var testKataShimPath = "/usr/bin/virtcontainers/bin/test/kata-shim"
|
||||
var testKataShimProxyURL = "foo:///foo/kata-containers/proxy.sock"
|
||||
|
||||
|
@ -25,19 +25,10 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var rootfsDir = "rootfs"
|
||||
|
||||
func mountLogger() *logrus.Entry {
|
||||
return virtLog.WithField("subsystem", "mount")
|
||||
}
|
||||
|
||||
// These mounts need to be created by the agent within the VM
|
||||
var systemMounts = []string{"/proc", "/dev", "/dev/pts", "/dev/shm", "/dev/mqueue", "/sys", "/sys/fs/cgroup"}
|
||||
|
||||
var systemMountPrefixes = []string{"/proc", "/dev", "/sys"}
|
||||
|
||||
func isSystemMount(m string) bool {
|
||||
|
@ -453,7 +453,6 @@ func (n NetworkNamespace) MarshalJSON() ([]byte, error) {
|
||||
// UnmarshalJSON is the custom NetworkNamespace unmarshalling routine.
|
||||
// This is needed for unmarshalling the Endpoints interfaces array.
|
||||
func (n *NetworkNamespace) UnmarshalJSON(b []byte) error {
|
||||
type tmp NetworkNamespace
|
||||
var s struct {
|
||||
NetNsPath string
|
||||
NetNsCreated bool
|
||||
@ -1081,15 +1080,6 @@ func createNetNS() (string, error) {
|
||||
return n.Path(), nil
|
||||
}
|
||||
|
||||
func setNetNS(netNSPath string) error {
|
||||
n, err := ns.GetNS(netNSPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return n.Set()
|
||||
}
|
||||
|
||||
// doNetNS is free from any call to a go routine, and it calls
|
||||
// into runtime.LockOSThread(), meaning it won't be executed in a
|
||||
// different thread than the one expected by the caller.
|
||||
|
@ -20,8 +20,6 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
var testNoProxyVMURL = "vmURL"
|
||||
|
||||
func TestNoProxyStart(t *testing.T) {
|
||||
pod := Pod{
|
||||
agent: newAgent(NoopAgentType),
|
||||
|
@ -27,7 +27,6 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
const testContainerid = "123456789"
|
||||
const testToken = "pF56IaDpuax6hihJ5PneB8JypqmOvjkqY-wKGVYqgIM="
|
||||
|
||||
// CCProxyMock is an object mocking clearcontainers Proxy
|
||||
@ -73,10 +72,6 @@ func (proxy *CCProxyMock) GetProxyToken() string {
|
||||
return proxy.token
|
||||
}
|
||||
|
||||
func newSignalList() []ShimSignal {
|
||||
return make([]ShimSignal, 0, 5)
|
||||
}
|
||||
|
||||
// GetLastStdinStream returns the last received stdin stream
|
||||
func (proxy *CCProxyMock) GetLastStdinStream() []byte {
|
||||
return proxy.lastStdinStream
|
||||
@ -375,13 +370,6 @@ type FrameKey struct {
|
||||
opcode int
|
||||
}
|
||||
|
||||
func newFrameKey(frameType api.FrameType, opcode int) FrameKey {
|
||||
return FrameKey{
|
||||
ftype: frameType,
|
||||
opcode: opcode,
|
||||
}
|
||||
}
|
||||
|
||||
type ccProxyProtocol struct {
|
||||
cmdHandlers map[FrameKey]ccProxyProtocolHandler
|
||||
}
|
||||
|
@ -31,10 +31,7 @@ import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const (
|
||||
testPID = 12345
|
||||
testNSPath = "/foo/bar/ns"
|
||||
)
|
||||
const testPID = 12345
|
||||
|
||||
func TestGetNSPathFromPID(t *testing.T) {
|
||||
for nsType := range CloneFlagsTable {
|
||||
|
@ -1263,11 +1263,6 @@ func TestFindContainerSuccess(t *testing.T) {
|
||||
assert.True(t, c == pod.containers[0], "Container pointers should point to the same address")
|
||||
}
|
||||
|
||||
func testRemoveContainerFailure(t *testing.T, pod *Pod, cid string) {
|
||||
err := pod.removeContainer(cid)
|
||||
assert.NotNil(t, err, "Should have returned an error")
|
||||
}
|
||||
|
||||
func TestRemoveContainerPodNilFailure(t *testing.T) {
|
||||
testFindContainerFailure(t, nil, testContainerID)
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// ProxyConfig is a structure storing information needed from any
|
||||
@ -60,10 +59,6 @@ const (
|
||||
waitForProxyTimeoutSecs = 5.0
|
||||
)
|
||||
|
||||
func proxyLogger() *logrus.Entry {
|
||||
return virtLog.WithField("subsystem", "proxy")
|
||||
}
|
||||
|
||||
// Set sets a proxy type based on the input string.
|
||||
func (pType *ProxyType) Set(value string) error {
|
||||
switch value {
|
||||
|
@ -559,19 +559,6 @@ func (q *qemu) addDeviceToBridge(ID string) (string, string, error) {
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
func (q *qemu) removeDeviceFromBridge(ID string) error {
|
||||
var err error
|
||||
for _, b := range q.state.Bridges {
|
||||
err = b.removeDevice(ID)
|
||||
if err == nil {
|
||||
// device was removed correctly
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (q *qemu) hotplugBlockDevice(drive Drive, op operation) error {
|
||||
defer func(qemu *qemu) {
|
||||
if q.qmpMonitorCh.qmp != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user