1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-08 04:21:26 +02:00
sap-jenkins-library/pkg/cnbutils/user.go
Pavel Busko 26bfec19b3
feat(cnbBuild): support builders with different CNB user ids (#4625)
Co-authored-by: Ralf Pannemans <ralf.pannemans@sap.com>
2023-11-02 16:03:11 +01:00

33 lines
544 B
Go

package cnbutils
import (
"os"
"strconv"
"github.com/pkg/errors"
)
func CnbUserInfo() (int, int, error) {
uidStr, ok := os.LookupEnv("CNB_USER_ID")
if !ok {
return 0, 0, errors.New("environment variable CNB_USER_ID not found")
}
gidStr, ok := os.LookupEnv("CNB_GROUP_ID")
if !ok {
return 0, 0, errors.New("environment variable CNB_GROUP_ID not found")
}
uid, err := strconv.Atoi(uidStr)
if err != nil {
return 0, 0, err
}
gid, err := strconv.Atoi(gidStr)
if err != nil {
return 0, 0, err
}
return uid, gid, nil
}