mirror of https://github.com/kubernetes/kops.git
Update to use sha224 and base62 text.
This commit is contained in:
parent
969bd8f0b5
commit
00a0deb8e6
|
@ -24,6 +24,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/big"
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
|
@ -173,7 +174,11 @@ func cacheFilePath(kopsStateStore string, clusterName string) string {
|
|||
b.WriteString(clusterName)
|
||||
b.WriteByte(0)
|
||||
|
||||
hash := fmt.Sprintf("%x", sha256.Sum256(b.Bytes()))
|
||||
var i big.Int
|
||||
hb := sha256.Sum224(b.Bytes())
|
||||
i.SetBytes(hb[:])
|
||||
|
||||
hash := i.Text(62)
|
||||
return filepath.Join(homedir.HomeDir(), ".kube", "cache", "kops-authentication", hash)
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ func Test_cacheFilePath(t *testing.T) {
|
|||
output1 := cacheFilePath(inputs[0].kopsStateStore, inputs[0].clusterName)
|
||||
_, file := path.Split(output1)
|
||||
|
||||
if len(file) > 64 {
|
||||
if len(file) > 38 {
|
||||
t.Errorf("cacheFilePath() got %v, too long(%v)", output1, len(file))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue