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

cli: fix the issue of using wrong path to get version #869

Merged
merged 1 commit into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions cli/kata-env.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,32 +239,35 @@ func getProxyInfo(config oci.RuntimeConfig) (ProxyInfo, error) {
return ProxyInfo{Type: string(config.ProxyType)}, nil
}

version, err := getCommandVersion(defaultProxyPath)
proxyConfig := config.ProxyConfig
version, err := getCommandVersion(proxyConfig.Path)
if err != nil {
version = unknown
}

proxy := ProxyInfo{
Type: string(config.ProxyType),
Version: version,
Path: config.ProxyConfig.Path,
Debug: config.ProxyConfig.Debug,
Path: proxyConfig.Path,
Debug: proxyConfig.Debug,
}

return proxy, nil
}

func getNetmonInfo(config oci.RuntimeConfig) (NetmonInfo, error) {
version, err := getCommandVersion(defaultNetmonPath)
netmonConfig := config.NetmonConfig

version, err := getCommandVersion(netmonConfig.Path)
if err != nil {
version = unknown
}

netmon := NetmonInfo{
Version: version,
Path: config.NetmonConfig.Path,
Debug: config.NetmonConfig.Debug,
Enable: config.NetmonConfig.Enable,
Path: netmonConfig.Path,
Debug: netmonConfig.Debug,
Enable: netmonConfig.Enable,
}

return netmon, nil
Expand Down
11 changes: 3 additions & 8 deletions cli/kata-env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/stretchr/testify/assert"
)

const testProxyURL = "file:///proxyURL"
const testProxyVersion = "proxy version 0.1"
const testShimVersion = "shim version 0.1"
const testNetmonVersion = "netmon version 0.1"
Expand Down Expand Up @@ -69,10 +68,6 @@ func makeRuntimeConfig(prefixDir string) (configFile string, config oci.RuntimeC
hotplugVFIOOnRootBus := true
disableNewNetNs := false

// override
defaultProxyPath = proxyPath
defaultNetmonPath = netmonPath

filesToCreate := []string{
hypervisorPath,
kernelPath,
Expand Down Expand Up @@ -115,7 +110,7 @@ func makeRuntimeConfig(prefixDir string) (configFile string, config oci.RuntimeC
kernelParams,
machineType,
shimPath,
testProxyURL,
proxyPath,
netmonPath,
logPath,
disableBlock,
Expand Down Expand Up @@ -626,7 +621,7 @@ func TestEnvGetProxyInfoNoVersion(t *testing.T) {
assert.NoError(t, err)

// remove the proxy ensuring its version cannot be queried
err = os.Remove(defaultProxyPath)
err = os.Remove(config.ProxyConfig.Path)
assert.NoError(t, err)

expectedProxy.Version = unknown
Expand Down Expand Up @@ -670,7 +665,7 @@ func TestEnvGetNetmonInfoNoVersion(t *testing.T) {
assert.NoError(t, err)

// remove the netmon ensuring its version cannot be queried
err = os.Remove(defaultNetmonPath)
err = os.Remove(config.NetmonConfig.Path)
assert.NoError(t, err)

expectedNetmon.Version = unknown
Expand Down