From bafc25fe3d5a5caa10321c534fefd61af44f2182 Mon Sep 17 00:00:00 2001 From: Roman Dodin Date: Wed, 29 Nov 2023 21:52:15 +0200 Subject: [PATCH] remove param --- clab/clab.go | 10 ++++++---- cmd/destroy.go | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/clab/clab.go b/clab/clab.go index 1be6c9df2..ecf5e55a7 100644 --- a/clab/clab.go +++ b/clab/clab.go @@ -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 } @@ -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 } diff --git a/cmd/destroy.go b/cmd/destroy.go index 7926be5d5..d32d6ff36 100644 --- a/cmd/destroy.go +++ b/cmd/destroy.go @@ -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 }