LookPath searches for an executable named step- -plugin in the $(step path)/plugins directory or in the directories named by the PATH environment variable. On Windows, files with the .com, .exe, .bat and .cmd extension will be checked to exist in the $(step path)/plugins directory first, after
(name string)
| 18 | // will be checked to exist in the $(step path)/plugins directory first, after |
| 19 | // which the directories in the PATH environment variable will be inspected. |
| 20 | func LookPath(name string) (string, error) { |
| 21 | fileName := "step-" + name + "-plugin" |
| 22 | switch runtime.GOOS { |
| 23 | case "windows": |
| 24 | var exts []string |
| 25 | x := os.Getenv(`PATHEXT`) |
| 26 | if x != "" { |
| 27 | for _, e := range strings.Split(strings.ToLower(x), `;`) { |
| 28 | if e == "" { |
| 29 | continue |
| 30 | } |
| 31 | if e[0] != '.' { |
| 32 | e = "." + e |
| 33 | } |
| 34 | exts = append(exts, e) |
| 35 | } |
| 36 | } else { |
| 37 | exts = []string{".com", ".exe", ".bat", ".cmd", ".ps1"} |
| 38 | } |
| 39 | for _, ext := range exts { |
| 40 | path := filepath.Join(step.BasePath(), "plugins", fileName+ext) |
| 41 | if _, err := os.Stat(path); err == nil { // #nosec G703 -- path to stat intentionally relies on (partial) user configuration |
| 42 | return path, nil |
| 43 | } |
| 44 | } |
| 45 | default: |
| 46 | path := filepath.Join(step.BasePath(), "plugins", fileName) |
| 47 | if _, err := os.Stat(path); err == nil { |
| 48 | return path, nil |
| 49 | } |
| 50 | } |
| 51 | return exec.LookPath(fileName) |
| 52 | } |
| 53 | |
| 54 | // Run starts the given command with the arguments in the context and waits for |
| 55 | // it to complete. |
no outgoing calls
no test coverage detected
searching dependent graphs…