Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.
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
16 changes: 11 additions & 5 deletions pkg/katautils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,13 @@ func (h hypervisor) getInitrdAndImage() (initrd string, image string, err error)
return
}

func (p proxy) path() string {
if p.Path == "" {
return defaultProxyPath
func (p proxy) path() (string, error) {
path := p.Path
if path == "" {
path = defaultProxyPath
}

return p.Path
return ResolvePath(path)
}

func (p proxy) debug() bool {
Expand Down Expand Up @@ -606,8 +607,13 @@ func updateRuntimeConfigProxy(configPath string, tomlConf tomlConfig, config *oc
config.ProxyType = vc.KataProxyType
}

path, err := proxy.path()
if err != nil {
return err
}

config.ProxyConfig = vc.ProxyConfig{
Path: proxy.path(),
Path: path,
Debug: proxy.debug(),
}
}
Expand Down
38 changes: 34 additions & 4 deletions pkg/katautils/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1122,13 +1122,43 @@ func TestHypervisorDefaultsGuestHookPath(t *testing.T) {
}

func TestProxyDefaults(t *testing.T) {
assert := assert.New(t)

tmpdir, err := ioutil.TempDir(testDir, "")
assert.NoError(err)
defer os.RemoveAll(tmpdir)

testProxyPath := filepath.Join(tmpdir, "proxy")
testProxyLinkPath := filepath.Join(tmpdir, "proxy-link")

err = createEmptyFile(testProxyPath)
assert.NoError(err)

err = syscall.Symlink(testProxyPath, testProxyLinkPath)
assert.NoError(err)

savedProxyPath := defaultProxyPath

defer func() {
defaultProxyPath = savedProxyPath
}()

defaultProxyPath = testProxyPath
p := proxy{}
path, err := p.path()
assert.NoError(err)
assert.Equal(path, defaultProxyPath, "default proxy path wrong")

assert.Equal(t, p.path(), defaultProxyPath, "default proxy path wrong")
// test path resolution
defaultProxyPath = testProxyLinkPath
p = proxy{}
path, err = p.path()
assert.NoError(err)
assert.Equal(path, testProxyPath)

path := "/foo/bar/baz/proxy"
p.Path = path
assert.Equal(t, p.path(), path, "custom proxy path wrong")
assert.False(p.debug())
p.Debug = true
assert.True(p.debug())
}

func TestShimDefaults(t *testing.T) {
Expand Down