本文整理汇总了Golang中code/cloudfoundry/org/cli/cf/requirements.Factory.NewLoginRequirement方法的典型用法代码示例。如果您正苦于以下问题:Golang Factory.NewLoginRequirement方法的具体用法?Golang Factory.NewLoginRequirement怎么用?Golang Factory.NewLoginRequirement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类code/cloudfoundry/org/cli/cf/requirements.Factory
的用法示例。
在下文中一共展示了Factory.NewLoginRequirement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Requirements
func (cmd *Password) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
reqs := []requirements.Requirement{
requirementsFactory.NewLoginRequirement(),
}
return reqs, nil
}
示例2: Requirements
func (cmd *UnsetOrgRole) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
if len(fc.Args()) != 3 {
cmd.ui.Failed(T("Incorrect Usage. Requires USERNAME, ORG, ROLE as arguments\n\n") + commandregistry.Commands.CommandUsage("unset-org-role"))
return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 3)
}
var wantGUID bool
if cmd.config.IsMinAPIVersion(cf.SetRolesByUsernameMinimumAPIVersion) {
setRolesByUsernameFlag, err := cmd.flagRepo.FindByName("unset_roles_by_username")
wantGUID = (err != nil || !setRolesByUsernameFlag.Enabled)
} else {
wantGUID = true
}
cmd.userReq = requirementsFactory.NewUserRequirement(fc.Args()[0], wantGUID)
cmd.orgReq = requirementsFactory.NewOrganizationRequirement(fc.Args()[1])
reqs := []requirements.Requirement{
requirementsFactory.NewLoginRequirement(),
cmd.userReq,
cmd.orgReq,
}
return reqs, nil
}
示例3: Requirements
func (cmd *Push) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
var reqs []requirements.Requirement
usageReq := requirementsFactory.NewUsageRequirement(commandregistry.CLICommandUsagePresenter(cmd), "",
func() bool {
return len(fc.Args()) > 1
},
)
reqs = append(reqs, usageReq)
if fc.String("route-path") != "" {
reqs = append(reqs, requirementsFactory.NewMinAPIVersionRequirement("Option '--route-path'", cf.RoutePathMinimumAPIVersion))
}
if fc.String("app-ports") != "" {
reqs = append(reqs, requirementsFactory.NewMinAPIVersionRequirement("Option '--app-ports'", cf.MultipleAppPortsMinimumAPIVersion))
}
reqs = append(reqs, []requirements.Requirement{
requirementsFactory.NewLoginRequirement(),
requirementsFactory.NewTargetedSpaceRequirement(),
}...)
return reqs, nil
}
示例4: Requirements
func (cmd *UnmapRoute) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
if len(fc.Args()) != 2 {
cmd.ui.Failed(T("Incorrect Usage. Requires app_name, domain_name as arguments\n\n") + commandregistry.Commands.CommandUsage("unmap-route"))
return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 2)
}
if fc.IsSet("port") && (fc.IsSet("hostname") || fc.IsSet("path")) {
cmd.ui.Failed(T("Cannot specify port together with hostname and/or path."))
return nil, fmt.Errorf("Cannot specify port together with hostname and/or path.")
}
domainName := fc.Args()[1]
cmd.appReq = requirementsFactory.NewApplicationRequirement(fc.Args()[0])
cmd.domainReq = requirementsFactory.NewDomainRequirement(domainName)
var reqs []requirements.Requirement
if fc.String("path") != "" {
reqs = append(reqs, requirementsFactory.NewMinAPIVersionRequirement("Option '--path'", cf.RoutePathMinimumAPIVersion))
}
if fc.IsSet("port") {
reqs = append(reqs, requirementsFactory.NewMinAPIVersionRequirement("Option '--port'", cf.TCPRoutingMinimumAPIVersion))
}
reqs = append(reqs, []requirements.Requirement{
requirementsFactory.NewLoginRequirement(),
cmd.appReq,
cmd.domainReq,
}...)
return reqs, nil
}
示例5: Requirements
func (cmd *BindRouteService) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
if len(fc.Args()) != 2 {
cmd.ui.Failed(T("Incorrect Usage. Requires DOMAIN and SERVICE_INSTANCE as arguments\n\n") + commandregistry.Commands.CommandUsage("bind-route-service"))
return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 2)
}
domainName := fc.Args()[0]
cmd.domainReq = requirementsFactory.NewDomainRequirement(domainName)
serviceName := fc.Args()[1]
cmd.serviceInstanceReq = requirementsFactory.NewServiceInstanceRequirement(serviceName)
minAPIVersionRequirement := requirementsFactory.NewMinAPIVersionRequirement(
"bind-route-service",
cf.MultipleAppPortsMinimumAPIVersion,
)
reqs := []requirements.Requirement{
requirementsFactory.NewLoginRequirement(),
cmd.domainReq,
cmd.serviceInstanceReq,
minAPIVersionRequirement,
}
return reqs, nil
}
示例6: Requirements
func (cmd *SSH) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
if len(fc.Args()) != 1 {
cmd.ui.Failed(T("Incorrect Usage. Requires APP_NAME as argument") + "\n\n" + commandregistry.Commands.CommandUsage("ssh"))
return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 1)
}
if fc.IsSet("i") && fc.Int("i") < 0 {
cmd.ui.Failed(fmt.Sprintf(T("Incorrect Usage:")+" %s\n\n%s", T("Value for flag 'app-instance-index' cannot be negative"), commandregistry.Commands.CommandUsage("ssh")))
return nil, fmt.Errorf("Incorrect usage: app-instance-index cannot be negative")
}
var err error
cmd.opts, err = options.NewSSHOptions(fc)
if err != nil {
cmd.ui.Failed(fmt.Sprintf(T("Incorrect Usage:")+" %s\n\n%s", err.Error(), commandregistry.Commands.CommandUsage("ssh")))
return nil, err
}
cmd.appReq = requirementsFactory.NewApplicationRequirement(cmd.opts.AppName)
reqs := []requirements.Requirement{
requirementsFactory.NewLoginRequirement(),
requirementsFactory.NewTargetedSpaceRequirement(),
cmd.appReq,
}
return reqs, nil
}
示例7: Requirements
func (cmd *UpdateSecurityGroup) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
if len(fc.Args()) != 2 {
cmd.ui.Failed(T("Incorrect Usage. Requires SECURITY_GROUP and PATH_TO_JSON_RULES_FILE as arguments\n\n") + commandregistry.Commands.CommandUsage("update-security-group"))
return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 2)
}
reqs := []requirements.Requirement{requirementsFactory.NewLoginRequirement()}
return reqs, nil
}
示例8: Requirements
func (cmd *DeleteSecurityGroup) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
if len(fc.Args()) != 1 {
cmd.ui.Failed(T("Incorrect Usage. Requires an argument\n\n") + commandregistry.Commands.CommandUsage("delete-security-group"))
return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 1)
}
reqs := []requirements.Requirement{requirementsFactory.NewLoginRequirement()}
return reqs, nil
}
示例9: Requirements
func (cmd *BindSecurityGroup) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
if len(fc.Args()) != 2 && len(fc.Args()) != 3 {
cmd.ui.Failed(T("Incorrect Usage. Requires SECURITY_GROUP and ORG, optional SPACE as arguments\n\n") + commandregistry.Commands.CommandUsage("bind-security-group"))
return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 3)
}
reqs := []requirements.Requirement{}
reqs = append(reqs, requirementsFactory.NewLoginRequirement())
return reqs, nil
}
示例10: Requirements
func (cmd *UnbindSecurityGroup) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
argLength := len(fc.Args())
if argLength != 1 && argLength != 3 {
cmd.ui.Failed(T("Incorrect Usage. Requires SECURITY_GROUP, ORG and SPACE as arguments\n\n") + commandregistry.Commands.CommandUsage("unbind-security-group"))
return nil, fmt.Errorf("Incorrect usage: %d arguments of 1 or 3 required", len(fc.Args()))
}
reqs := []requirements.Requirement{requirementsFactory.NewLoginRequirement()}
return reqs, nil
}
示例11: Requirements
func (cmd *SetRunningEnvironmentVariableGroup) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
if len(fc.Args()) != 1 {
cmd.ui.Failed(T("Incorrect Usage. Requires an argument\n\n") + commandregistry.Commands.CommandUsage("set-running-environment-variable-group"))
return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 1)
}
reqs := []requirements.Requirement{
requirementsFactory.NewLoginRequirement(),
}
return reqs, nil
}
示例12: Requirements
func (cmd *RouterGroups) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
return []requirements.Requirement{
requirementsFactory.NewUsageRequirement(commandregistry.CLICommandUsagePresenter(cmd),
T("No argument required"),
func() bool {
return len(fc.Args()) != 0
},
),
requirementsFactory.NewLoginRequirement(),
requirementsFactory.NewRoutingAPIRequirement(),
}, nil
}
示例13: Requirements
func (cmd *CreateBuildpack) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
if len(fc.Args()) != 3 {
cmd.ui.Failed(T("Incorrect Usage. Requires buildpack_name, path and position as arguments\n\n") + commandregistry.Commands.CommandUsage("create-buildpack"))
return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 3)
}
reqs := []requirements.Requirement{
requirementsFactory.NewLoginRequirement(),
}
return reqs, nil
}
示例14: Requirements
func (cmd *UpdateServiceBroker) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
if len(fc.Args()) != 4 {
cmd.ui.Failed(T("Incorrect Usage. Requires SERVICE_BROKER, USERNAME, PASSWORD, URL as arguments\n\n") + commandregistry.Commands.CommandUsage("update-service-broker"))
return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 4)
}
reqs := []requirements.Requirement{
requirementsFactory.NewLoginRequirement(),
}
return reqs, nil
}
示例15: Requirements
func (cmd *RenameBuildpack) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
if len(fc.Args()) != 2 {
cmd.ui.Failed(T("Incorrect Usage. Requires BUILDPACK_NAME, NEW_BUILDPACK_NAME as arguments\n\n") + commandregistry.Commands.CommandUsage("rename-buildpack"))
return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 2)
}
reqs := []requirements.Requirement{
requirementsFactory.NewLoginRequirement(),
}
return reqs, nil
}