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

Commit

Permalink
Merge pull request #57 from clearcontainers/sboeuf/add_proxy_config
Browse files Browse the repository at this point in the history
config: Update proxy config according to virtcontainers
  • Loading branch information
Samuel Ortiz committed Mar 9, 2017
2 parents d02c072 + 090d43e commit c1ca9db
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
14 changes: 12 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type hypervisor struct {
}

type proxy struct {
RuntimeSockPath string `toml:"runtime_sock"`
URL string `toml:"url"`
}

type shim struct {
Expand Down Expand Up @@ -103,6 +103,14 @@ func (h hypervisor) image() string {
return h.Image
}

func (p proxy) url() string {
if p.URL == "" {
return defaultProxyURL
}

return p.URL
}

func (s shim) path() string {
if s.Path == "" {
return defaultShimPath
Expand Down Expand Up @@ -178,8 +186,10 @@ func loadConfiguration(configPath string) (oci.RuntimeConfig, ShimConfig, error)
switch k {
case ccProxy:
pConfig := vc.CCProxyConfig{
URL: proxy.RuntimeSockPath,
URL: proxy.url(),
}

config.ProxyType = vc.CCProxyType
config.ProxyConfig = pConfig
break
}
Expand Down
11 changes: 5 additions & 6 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
const hypervisorPath = "/foo/qemu-lite-system-x86_64"
const kernelPath = "/foo/clear-containers/vmlinux.container"
const imagePath = "/foo/clear-containers/clear-containers.img"
const runtimePath = "/foo/clear-containers/runtime.sock"
const proxyURL = "foo:///foo/clear-containers/proxy.sock"
const shimPath = "/foo/clear-containers/cc-shim"

const runtimeConfig = `
Expand All @@ -41,7 +41,7 @@ kernel = "` + kernelPath + `"
image = "` + imagePath + `"
[proxy.cc]
runtime_sock = "` + runtimePath + `"
url = "` + proxyURL + `"
[shim.cc]
path = "` + shimPath + `"
Expand All @@ -51,8 +51,7 @@ const runtimeMinimalConfig = `
# Clear Containers runtime configuration file
[proxy.cc]
runtime_sock = "` + runtimePath + `"
shim_sock = "` + shimPath + `"
url = "` + proxyURL + `"
`

const tempRuntimePath = "/tmp/cc-runtime/"
Expand Down Expand Up @@ -87,7 +86,7 @@ func TestRuntimeConfig(t *testing.T) {
}

expectedProxyConfig := vc.CCProxyConfig{
URL: runtimePath,
URL: proxyURL,
}

expectedConfig := oci.RuntimeConfig{
Expand Down Expand Up @@ -135,7 +134,7 @@ func TestMinimalRuntimeConfig(t *testing.T) {
}

expectedProxyConfig := vc.CCProxyConfig{
URL: runtimePath,
URL: proxyURL,
}

expectedConfig := oci.RuntimeConfig{
Expand Down

0 comments on commit c1ca9db

Please sign in to comment.