Skip to content

Commit

Permalink
Skip binds path check option for destroy operation (#2334)
Browse files Browse the repository at this point in the history
skip binds path check option
  • Loading branch information
hellt authored Dec 6, 2024
1 parent c71d7ba commit c25b2f4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ tests/out
**/*.y*ml.bak

.python-version

.devcontainer/private-*
22 changes: 17 additions & 5 deletions clab/clab.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ type CLab struct {
// nodeFilter is a list of node names to be deployed,
// names are provided exactly as they are listed in the topology file.
nodeFilter []string
// checkBindsPaths toggle enables or disables binds paths checks
// when set to true, bind sources are verified to exist on the host.
checkBindsPaths bool
}

type ClabOption func(c *CLab) error
Expand All @@ -79,6 +82,14 @@ func WithLabName(n string) ClabOption {
}
}

// WithSkippedBindsPathsCheck skips the binds paths checks.
func WithSkippedBindsPathsCheck() ClabOption {
return func(c *CLab) error {
c.checkBindsPaths = false
return nil
}
}

// WithManagementNetworkName sets the name of the
// management network that is to be used.
func WithManagementNetworkName(n string) ClabOption {
Expand Down Expand Up @@ -333,11 +344,12 @@ func NewContainerLab(opts ...ClabOption) (*CLab, error) {
Mgmt: new(types.MgmtNet),
Topology: types.NewTopology(),
},
m: new(sync.RWMutex),
Nodes: make(map[string]nodes.Node),
Links: make(map[int]links.Link),
Runtimes: make(map[string]runtime.ContainerRuntime),
Cert: &cert.Cert{},
m: new(sync.RWMutex),
Nodes: make(map[string]nodes.Node),
Links: make(map[int]links.Link),
Runtimes: make(map[string]runtime.ContainerRuntime),
Cert: &cert.Cert{},
checkBindsPaths: true,
}

// init a new NodeRegistry
Expand Down
3 changes: 3 additions & 0 deletions cmd/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ func destroyFn(_ *cobra.Command, _ []string) error {
},
),
clab.WithDebug(debug),
// during destroy we don't want to check bind paths
// as it is irrelevant for this command.
clab.WithSkippedBindsPathsCheck(),
}

if keepMgmtNet {
Expand Down

0 comments on commit c25b2f4

Please sign in to comment.