MCPcopy Index your code
hub / github.com/smallstep/cli / LookPath

Function LookPath

internal/plugin/plugin.go:20–52  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
20func 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.

Callers 4

newAppFunction · 0.92
LoadCertificateFunction · 0.92
newKMSSignerFunction · 0.92
newKMSPublicKeyFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…