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


Golang api.ToPolicy函數代碼示例

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


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

示例1: getReferencedRole

func (m *VirtualStorage) getReferencedRole(roleRef kapi.ObjectReference) (*authorizationapi.Role, error) {
	ctx := kapi.WithNamespace(kapi.NewContext(), roleRef.Namespace)

	var policy *authorizationapi.Policy
	var err error
	switch {
	case len(roleRef.Namespace) == 0:
		var clusterPolicy *authorizationapi.ClusterPolicy
		clusterPolicy, err = m.ClusterPolicyRegistry.GetClusterPolicy(ctx, authorizationapi.PolicyName)
		policy = authorizationapi.ToPolicy(clusterPolicy)
	default:
		policy, err = m.PolicyRegistry.GetPolicy(ctx, authorizationapi.PolicyName)
	}

	if err != nil {
		return nil, err
	}

	role, exists := policy.Roles[roleRef.Name]
	if !exists {
		return nil, kapierrors.NewNotFound("Role", roleRef.Name)
	}

	return role, nil
}
開發者ID:jhadvig,項目名稱:origin,代碼行數:25,代碼來源:virtual_storage.go

示例2: Describe

// Describe returns the description of a policy
// TODO make something a lot prettier
func (d *ClusterPolicyDescriber) Describe(namespace, name string) (string, error) {
	c := d.ClusterPolicies()
	policy, err := c.Get(name)
	if err != nil {
		return "", err
	}

	return DescribePolicy(authorizationapi.ToPolicy(policy))
}
開發者ID:dctse,項目名稱:openshift-cucumber,代碼行數:11,代碼來源:describer.go

示例3: GetPolicy

// GetPolicy retrieves a specific policy.  It conforms to rulevalidation.PolicyGetter.
func (c readOnlyAuthorizationCache) GetPolicy(ctx kapi.Context, name string) (*authorizationapi.Policy, error) {
	namespace, _ := kapi.NamespaceFrom(ctx)

	if namespaceRefersToCluster(namespace) {
		clusterPolicy, err := c.ReadOnlyClusterPolicies().Get(name)
		if err != nil {
			return &authorizationapi.Policy{}, err
		}
		return authorizationapi.ToPolicy(clusterPolicy), nil
	} else {
		policy, err := c.ReadOnlyPolicies(namespace).Get(name)
		if err != nil {
			return &authorizationapi.Policy{}, err
		}
		return policy, nil
	}
}
開發者ID:jhadvig,項目名稱:origin,代碼行數:18,代碼來源:readonlycache.go

示例4: printClusterPolicy

func printClusterPolicy(policy *authorizationapi.ClusterPolicy, w io.Writer, opts kctl.PrintOptions) error {
	return printPolicy(authorizationapi.ToPolicy(policy), w, opts)
}
開發者ID:sgallagher,項目名稱:origin,代碼行數:3,代碼來源:printer.go

示例5: ValidateClusterPolicyUpdate

func ValidateClusterPolicyUpdate(policy *authorizationapi.ClusterPolicy, oldPolicy *authorizationapi.ClusterPolicy) fielderrors.ValidationErrorList {
	return ValidatePolicyUpdate(authorizationapi.ToPolicy(policy), authorizationapi.ToPolicy(oldPolicy), false)
}
開發者ID:dctse,項目名稱:openshift-cucumber,代碼行數:3,代碼來源:validation.go

示例6: GetPolicy

func (s *simulatedStorage) GetPolicy(ctx kapi.Context, name string) (*authorizationapi.Policy, error) {
	ret, err := s.clusterRegistry.GetClusterPolicy(ctx, name)
	return authorizationapi.ToPolicy(ret), err
}
開發者ID:RomainVabre,項目名稱:origin,代碼行數:4,代碼來源:registry.go

示例7: printClusterPolicy

func printClusterPolicy(policy *authorizationapi.ClusterPolicy, w io.Writer, withNamespace, wide bool, columnLabels []string) error {
	return printPolicy(authorizationapi.ToPolicy(policy), w, withNamespace, wide, columnLabels)
}
開發者ID:patrykattc,項目名稱:origin,代碼行數:3,代碼來源:printer.go

示例8: ValidateClusterPolicy

func ValidateClusterPolicy(policy *authorizationapi.ClusterPolicy) field.ErrorList {
	return ValidatePolicy(authorizationapi.ToPolicy(policy), false)
}
開發者ID:php-coder,項目名稱:origin,代碼行數:3,代碼來源:validation.go

示例9: printClusterPolicy

func printClusterPolicy(policy *authorizationapi.ClusterPolicy, w io.Writer, withNamespace bool) error {
	return printPolicy(authorizationapi.ToPolicy(policy), w, withNamespace)
}
開發者ID:cjnygard,項目名稱:origin,代碼行數:3,代碼來源:printer.go


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