Skip to content

Commit

Permalink
Merge pull request #1148 from srl-labs/reg-once
Browse files Browse the repository at this point in the history
register nodes once
  • Loading branch information
hellt authored Dec 22, 2022
2 parents 782e78a + 2ff3b25 commit f961b64
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 f961b64

Please sign in to comment.