forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelpers.go
22 lines (18 loc) · 958 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
package serviceaccount
import "github.com/openshift/origin/pkg/api/apihelpers"
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(serviceAccountName string) string {
return apihelpers.GetName(serviceAccountName, "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(serviceAccountName string) string {
return apihelpers.GetName(serviceAccountName, "token-", maxSecretPrefixNameLength)
}