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{