本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/models.ServicePlanFields.OrgHasVisibility方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServicePlanFields.OrgHasVisibility方法的具體用法?Golang ServicePlanFields.OrgHasVisibility怎麽用?Golang ServicePlanFields.OrgHasVisibility使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/cli/cf/models.ServicePlanFields
的用法示例。
在下文中一共展示了ServicePlanFields.OrgHasVisibility方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: UpdatePlanAndOrgForService
func (actor ServicePlanHandler) UpdatePlanAndOrgForService(serviceName, planName, orgName string, setPlanVisibility bool) (PlanAccess, error) {
service, err := actor.serviceBuilder.GetServiceByName(serviceName)
if err != nil {
return PlanAccessError, err
}
org, err := actor.orgRepo.FindByName(orgName)
if err != nil {
return PlanAccessError, err
}
found := false
var servicePlan models.ServicePlanFields
for i, val := range service.Plans {
if val.Name == planName {
found = true
servicePlan = service.Plans[i]
}
}
if !found {
return PlanAccessError, errors.New(fmt.Sprintf("Service plan %s not found", planName))
}
if !servicePlan.Public && setPlanVisibility {
if servicePlan.OrgHasVisibility(orgName) {
return Limited, nil
}
// Enable service access
err = actor.servicePlanVisibilityRepo.Create(servicePlan.Guid, org.Guid)
if err != nil {
return PlanAccessError, err
}
} else if !servicePlan.Public && !setPlanVisibility {
// Disable service access
if servicePlan.OrgHasVisibility(org.Name) {
err = actor.deleteServicePlanVisibilities(map[string]string{"organization_guid": org.Guid, "service_plan_guid": servicePlan.Guid})
if err != nil {
return PlanAccessError, err
}
}
}
access := actor.findPlanAccess(servicePlan)
return access, nil
}