From 2ff3b25cf3b4f9690438233bd163048664030534 Mon Sep 17 00:00:00 2001 From: Roman Dodin Date: Thu, 22 Dec 2022 10:16:25 +0100 Subject: [PATCH] register nodes once --- clab/clab.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/clab/clab.go b/clab/clab.go index 1be470992..e158648b8 100644 --- a/clab/clab.go +++ b/clab/clab.go @@ -23,6 +23,8 @@ import ( "github.com/srl-labs/containerlab/types" ) +var once sync.Once // nolint:gochecknoglobals + type CLab struct { Config *Config `json:"config,omitempty"` TopoFile *TopoFile `json:"topofile,omitempty"` @@ -111,7 +113,8 @@ func WithTopoFile(file, varsFile string) ClabOption { // NewContainerLab function defines a new container lab. func NewContainerLab(opts ...ClabOption) (*CLab, error) { - allNodes.RegisterAll() + // register all nodes just once + once.Do(allNodes.RegisterAll) c := &CLab{ Config: &Config{