-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli/cmd: add commands for viewing the cache location and clearing it (#…
…384) * cli/cmd: add commands for viewing the cache location and clearing it * extract function * extract cache paths
- Loading branch information
1 parent
42aa453
commit 012055f
Showing
3 changed files
with
81 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Package cache contains functions for working with caches. | ||
package cache | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
// Clear clears the cache. | ||
func Clear() error { | ||
root, err := RootPath() | ||
if err != nil { | ||
return err | ||
} | ||
return os.RemoveAll(root) | ||
} | ||
|
||
// RootPath returns the root cache path. | ||
func RootPath() (string, error) { | ||
root, err := os.UserCacheDir() | ||
if err != nil { | ||
return "", err | ||
} | ||
return filepath.Join(root, "pomerium-cli"), nil | ||
} | ||
|
||
// ExecCredentialsPath returns the path to the exec credentials. | ||
func ExecCredentialsPath() (string, error) { | ||
root, err := RootPath() | ||
if err != nil { | ||
return "", err | ||
} | ||
return filepath.Join(root, "exec-credential"), nil | ||
} | ||
|
||
// JWTsPath returns the path to the jwts. | ||
func JWTsPath() (string, error) { | ||
root, err := RootPath() | ||
if err != nil { | ||
return "", err | ||
} | ||
return filepath.Join(root, "jwts"), 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