1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-30 05:59:39 +02:00

33 lines
544 B
Go
Raw Normal View History

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
}