-
Notifications
You must be signed in to change notification settings - Fork 2
/
vars.go
33 lines (26 loc) · 863 Bytes
/
vars.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
27
28
29
30
31
32
33
package vars
import (
"fmt"
"strings"
"go.autokitteh.dev/autokitteh/sdk/sdktypes"
)
var (
UserAppID = varKey("app_id")
UserInstallID = varKey("install_id")
PATKey = sdktypes.NewSymbol("pat_key")
PATSecret = sdktypes.NewSymbol("pat_secret")
PAT = sdktypes.NewSymbol("pat")
PATUser = sdktypes.NewSymbol("pat_user")
)
func varKey(kind string) func(string) sdktypes.Symbol {
return func(user string) sdktypes.Symbol {
return sdktypes.NewSymbol(fmt.Sprintf("%s__%s", kind, encodeUser(user)))
}
}
func encodeUser(user string) string {
// Username may only contain alphanumeric characters or single hyphens, and cannot begin or end with a hyphen.
return strings.ReplaceAll(user, "-", "_")
}
func InstallKey(appID, installID string) sdktypes.Symbol {
return sdktypes.NewSymbol(fmt.Sprintf("install_key__%s__%s", appID, installID))
}