diff --git a/ChangeLog b/ChangeLog index ee17e98..257e37c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +# v2.1.0 (2019-02-12) + +* Added template import support +* Added new config parameter: `tpl.recursion_limit` + # v2.0.0 (2019-01-23) * Added dynamic discovery agent diff --git a/cmd/run.go b/cmd/run.go index 7057396..ff5f28f 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -83,6 +83,7 @@ var runCmd = &cobra.Command{ params.TLSCertFile = config.GetString("tls.cert") params.TLSKeyFile = config.GetString("tls.key") params.DefaultKeepalive = config.GetDuration("keepalive") + params.RecursionLimit = config.GetInt("tpl.recursion_limit") params.CengCtx = cengCtx runLog.Infof("Base directory: %s", params.BaseTplDir) diff --git a/pkg/config/default.go b/pkg/config/default.go index 8cbe4de..ee58774 100644 --- a/pkg/config/default.go +++ b/pkg/config/default.go @@ -35,6 +35,7 @@ keepalive = "2m" base_dir = "." ws_dir = "/tmp/xenvman/ws" mount_dir = "/tmp/xenvman/mount" +recursion_limit = 1000 [log] config = "=trace" diff --git a/pkg/conteng/conteng_docker.go b/pkg/conteng/conteng_docker.go index 61c73c6..cc048fb 100644 --- a/pkg/conteng/conteng_docker.go +++ b/pkg/conteng/conteng_docker.go @@ -110,7 +110,7 @@ func (de *DockerEngine) CreateNetwork(ctx context.Context, r, err := de.cl.NetworkCreate(ctx, name, netParams) if err != nil { - return "", "", errors.Wrapf(err, "Error creating docker network") + return "", "", errors.Wrapf(err, "Error creating docker network: %s", sub) } dockerLog.Debugf("Network created: %s - %s :: %s", name, r.ID, sub) @@ -367,6 +367,8 @@ func (de *DockerEngine) getSubNet() (string, error) { var nets []*net.IPNet for _, addr := range addrs { + dockerLog.Debugf("Inspecting interface %s", addr.String()) + _, n, err := net.ParseCIDR(addr.String()) if err != nil { diff --git a/pkg/def/output_env.go b/pkg/def/output_env.go index 4cc1e6f..c4e64ed 100644 --- a/pkg/def/output_env.go +++ b/pkg/def/output_env.go @@ -25,6 +25,10 @@ package def import ( + "fmt" + "strconv" + "strings" + "github.com/pkg/errors" ) @@ -46,6 +50,8 @@ func NewContainerData(id, hostname string) *ContainerData { type TplData struct { // Container name -> -> ":" Containers map[string]*ContainerData `json:"containers"` + // Imported templates -> tpl name -> [TplData] + Templates map[string][]*TplData `json:"templates"` } type OutputEnv struct { @@ -63,18 +69,53 @@ type OutputEnv struct { func (e *OutputEnv) GetContainer(tplName string, tplIdx int, contName string) (*ContainerData, error) { - tpls, ok := e.Templates[tplName] - if !ok { - return nil, errors.Errorf("Template not found: %s", tplName) - } + return e.GetContainerByPath([]string{ + fmt.Sprintf("%s|%d", tplName, tplIdx), + }, contName) +} + +// Path element must be defined in the format: