MCPcopy
hub / github.com/cloudfoundry/cli / CreateExecutableCopy

Method CreateExecutableCopy

actor/pluginaction/install.go:34–58  ·  view source on GitHub ↗

CreateExecutableCopy makes a temporary copy of a plugin binary and makes it executable. config.PluginHome() + /temp is used as the temp dir instead of the system temp for security reasons.

(path string, tempPluginDir string)

Source from the content-addressed store, hash-verified

32// config.PluginHome() + /temp is used as the temp dir instead of the system
33// temp for security reasons.
34func (actor Actor) CreateExecutableCopy(path string, tempPluginDir string) (string, error) {
35 tempFile, err := makeTempFile(tempPluginDir)
36 if err != nil {
37 return "", err
38 }
39
40 // add '.exe' to the temp file if on Windows
41 executablePath := generic.ExecutableFilename(tempFile.Name())
42 err = os.Rename(tempFile.Name(), executablePath)
43 if err != nil {
44 return "", err
45 }
46
47 err = fileutils.CopyPathToPath(path, executablePath)
48 if err != nil {
49 return "", err
50 }
51
52 err = os.Chmod(executablePath, 0700)
53 if err != nil {
54 return "", err
55 }
56
57 return executablePath, nil
58}
59
60// DownloadExecutableBinaryFromURL fetches a plugin binary from the specified
61// URL, if it exists.

Callers

nothing calls this directly

Implementers 1

FakeActorcommand/v7/v7fakes/fake_actor.go

Calls 4

ExecutableFilenameFunction · 0.92
makeTempFileFunction · 0.85
NameMethod · 0.80
RenameMethod · 0.65

Tested by

no test coverage detected