k8s: add flush-credentials command (#2379)

* k8s: add flush-credentials command

* Update cmd/pomerium-cli/kubernetes.go

Co-authored-by: Travis Groth <travisgroth@users.noreply.github.com>

Co-authored-by: Travis Groth <travisgroth@users.noreply.github.com>
This commit is contained in:
Caleb Doxsey 2021-07-20 15:51:55 -06:00 committed by GitHub
parent 8a74fae2e7
commit 8be71800c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 0 deletions

View file

@ -5,6 +5,7 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"io/fs"
"os"
"path/filepath"
"time"
@ -36,6 +37,25 @@ func cachedCredentialPath(serverURL string) string {
return filepath.Join(cachePath(), id+".json")
}
func clearAllCachedCredentials() {
_ = filepath.Walk(cachePath(), func(p string, fi fs.FileInfo, err error) error {
if err != nil {
return err
}
if fi.IsDir() {
return nil
}
return os.Remove(p)
})
}
func clearCachedCredential(serverURL string) {
fn := cachedCredentialPath(serverURL)
_ = os.Remove(fn)
}
func loadCachedCredential(serverURL string) *ExecCredential {
fn := cachedCredentialPath(serverURL)