-
Notifications
You must be signed in to change notification settings - Fork 565
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5470 from snyk/feat/CLI-509_configurableTmpDir
chore(GAF): bump gaf version
- Loading branch information
Showing
8 changed files
with
17 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,9 @@ | ||
package utils | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path" | ||
|
||
"github.com/pkg/errors" | ||
) | ||
|
||
const CACHEDIR_PERMISSION = 0755 | ||
|
||
// The directory structure used to cache things into | ||
// - Base cache directory (user definable, default depends on OS, exmple: /Users/username/Library/Caches/snyk/) | ||
// |- Version cache directory (example: /Users/username/Library/Caches/snyk/snyk-cli/1.1075.0/) | ||
// |- Temp directory (example: /Users/username/Library/Caches/snyk/snyk-cli/1.1075.0/tmp/) | ||
|
||
func GetTemporaryDirectory(baseCacheDirectory string, versionNumber string) string { | ||
pid := os.Getpid() | ||
return path.Join(GetVersionCacheDirectory(baseCacheDirectory, versionNumber), "tmp", fmt.Sprintf("pid%d", pid)) | ||
} | ||
|
||
func GetVersionCacheDirectory(baseCacheDirectory string, versionNumber string) string { | ||
return path.Join(baseCacheDirectory, versionNumber) | ||
} | ||
|
||
func CreateAllDirectories(baseCacheDirectory string, versionNumber string) error { | ||
directoryList := []string{ | ||
GetTemporaryDirectory(baseCacheDirectory, versionNumber), | ||
} | ||
|
||
for _, dir := range directoryList { | ||
err := os.MkdirAll(dir, CACHEDIR_PERMISSION) | ||
if err != nil { | ||
return errors.Wrap(err, "failed to create all directories.") | ||
} | ||
} | ||
|
||
return 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