Skip to content

Commit

Permalink
remove param
Browse files Browse the repository at this point in the history
  • Loading branch information
hellt committed Nov 29, 2023
1 parent 7ec535d commit bafc25f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions clab/clab.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func WithKeepMgmtNet() ClabOption {

func WithTopoPath(path, varsFile string) ClabOption {
return func(c *CLab) error {
file, err := ProcessTopoPath(path, c.TopoPaths.ClabTmpDir())
file, err := c.ProcessTopoPath(path)
if err != nil {
return err
}
Expand All @@ -140,19 +140,21 @@ func WithTopoPath(path, varsFile string) ClabOption {
}
}

func ProcessTopoPath(path string, tmpDir string) (string, error) {
// ProcessTopoPath takes a topology path, which might be the path to a directory or a file
// or stdin or a URL and returns the topology file name if found.
func (c *CLab) ProcessTopoPath(path string) (string, error) {
var file string
var err error

switch {
case path == "-" || path == "stdin":
file, err = readFromStdin(tmpDir)
file, err = readFromStdin(c.TopoPaths.ClabTmpDir())
if err != nil {
return "", err
}
// if the path is not a local file and a URL, download the file and store it in the tmp dir
case !utils.FileOrDirExists(path) && utils.IsHttpURL(path, true):
file, err = downloadTopoFile(path, tmpDir)
file, err = downloadTopoFile(path, c.TopoPaths.ClabTmpDir())
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func listContainers(ctx context.Context, topo string) ([]runtime.GenericContaine

// when topo file is provided, filter containers by lab name
if topo != "" {
topo, err = clab.ProcessTopoPath(topo, c.TopoPaths.ClabTmpDir())
topo, err = c.ProcessTopoPath(topo)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit bafc25f

Please sign in to comment.