-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
872d21a
commit 02035b1
Showing
3 changed files
with
38 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package connection | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"time" | ||
|
||
"github.com/patrickmn/go-cache" | ||
) | ||
|
||
// caches cloud tokens. eg: EKS token, GKE token, ... | ||
var tokenCache = cache.New(time.Hour, time.Hour) | ||
|
||
func tokenCacheKey(cloud string, cred any, identifiers string) string { | ||
switch v := cred.(type) { | ||
case string: | ||
return fmt.Sprintf("%s-%s-%s", cloud, v, identifiers) | ||
default: | ||
m, _ := json.Marshal(v) | ||
return fmt.Sprintf("%s-%s", m, identifiers) | ||
} | ||
} |
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