-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.go
26 lines (21 loc) · 996 Bytes
/
helpers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package util
import (
kapi "k8s.io/kubernetes/pkg/api"
"github.com/openshift/origin/pkg/util/namer"
)
const (
// These constants are here to create a name that is short enough to survive chopping by generate name
maxNameLength = 63
randomLength = 5
maxSecretPrefixNameLength = maxNameLength - randomLength
)
func GetDockercfgSecretNamePrefix(serviceAccount *kapi.ServiceAccount) string {
return namer.GetName(serviceAccount.Name, "dockercfg-", maxSecretPrefixNameLength)
}
// GetTokenSecretNamePrefix creates the prefix used for the generated SA token secret. This is compatible with kube up until
// long names, at which point we hash the SA name and leave the "token-" intact. Upstream clips the value and generates a random
// string.
// TODO fix the upstream implementation to be more like this.
func GetTokenSecretNamePrefix(serviceAccount *kapi.ServiceAccount) string {
return namer.GetName(serviceAccount.Name, "token-", maxSecretPrefixNameLength)
}