Skip to content

Commit

Permalink
register nodes once
Browse files Browse the repository at this point in the history
  • Loading branch information
hellt committed Dec 22, 2022
1 parent 3efab9a commit 2ff3b25
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion clab/clab.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 2ff3b25

Please sign in to comment.