當前位置: 首頁>>代碼示例>>Golang>>正文


Golang user.IsUserAllowed函數代碼示例

本文整理匯總了Golang中github.com/openshift/source-to-image/pkg/util/user.IsUserAllowed函數的典型用法代碼示例。如果您正苦於以下問題:Golang IsUserAllowed函數的具體用法?Golang IsUserAllowed怎麽用?Golang IsUserAllowed使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了IsUserAllowed函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: isOnbuildAllowed

// isOnbuildAllowed checks a list of Docker ONBUILD instructions for
// user directives. It ensures that any users specified by the directives
// falls within the specified range list of users.
func isOnbuildAllowed(directives []string, allowed *user.RangeList) bool {
	for _, line := range directives {
		parts := dockerLineDelim.Split(line, 2)
		if strings.ToLower(parts[0]) != "user" {
			continue
		}
		uname := extractUser(parts[1])
		if !user.IsUserAllowed(uname, allowed) {
			return false
		}
	}
	return true
}
開發者ID:abhgupta,項目名稱:origin,代碼行數:16,代碼來源:util.go

示例2: checkAllowedUser

func checkAllowedUser(d docker.Docker, config *api.Config, isOnbuild bool) error {
	if config.AllowedUIDs == nil || config.AllowedUIDs.Empty() {
		return nil
	}
	user, err := d.GetImageUser(config.BuilderImage)
	if err != nil {
		return err
	}
	if !userutil.IsUserAllowed(user, &config.AllowedUIDs) {
		return errors.NewBuilderUserNotAllowedError(config.BuilderImage, false)
	}
	if isOnbuild {
		cmds, err := d.GetOnBuild(config.BuilderImage)
		if err != nil {
			return err
		}
		if !userutil.IsOnbuildAllowed(cmds, &config.AllowedUIDs) {
			return errors.NewBuilderUserNotAllowedError(config.BuilderImage, true)
		}
	}
	return nil
}
開發者ID:jhadvig,項目名稱:origin,代碼行數:22,代碼來源:strategies.go

示例3: CheckAllowedUser

// CheckAllowedUser checks if the Docker image contains allowed users
// FIXME: @cswong this need better godoc
func CheckAllowedUser(d Docker, imageName string, uids user.RangeList, isOnbuild bool) error {
	if uids == nil || uids.Empty() {
		return nil
	}
	imageUser, err := d.GetImageUser(imageName)
	if err != nil {
		return err
	}
	if !user.IsUserAllowed(imageUser, &uids) {
		return errors.NewBuilderUserNotAllowedError(imageName, false)
	}
	if isOnbuild {
		cmds, err := d.GetOnBuild(imageName)
		if err != nil {
			return err
		}
		if !user.IsOnbuildAllowed(cmds, &uids) {
			return errors.NewBuilderUserNotAllowedError(imageName, true)
		}
	}
	return nil
}
開發者ID:andybrucenet,項目名稱:origin,代碼行數:24,代碼來源:util.go


注:本文中的github.com/openshift/source-to-image/pkg/util/user.IsUserAllowed函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。