This repository has been archived by the owner on Nov 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(SDI-2475) Configure the TempDir where the API loads plugins.
- Loading branch information
1 parent
a429f3e
commit 9b06cc8
Showing
11 changed files
with
78 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package common | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"path" | ||
"runtime" | ||
|
||
log "github.com/Sirupsen/logrus" | ||
"github.com/intelsdi-x/snap/control" | ||
) | ||
|
||
func WriteFile(filename string, b []byte) (string, error) { | ||
// Create temporary directory | ||
dir, err := ioutil.TempDir(control.GetDefaultConfig().TempDirPath, "snap-plugin-") | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
f, err := os.Create(path.Join(dir, filename)) | ||
if err != nil { | ||
return "", err | ||
} | ||
// Close before load | ||
defer f.Close() | ||
|
||
n, err := f.Write(b) | ||
log.Debugf("wrote %v to %v", n, f.Name()) | ||
if err != nil { | ||
return "", err | ||
} | ||
if runtime.GOOS != "windows" { | ||
err = f.Chmod(0700) | ||
if err != nil { | ||
return "", err | ||
} | ||
} | ||
return f.Name(), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters