本文整理匯總了Golang中code/cloudfoundry/org/cli/cf/requirements.Factory類的典型用法代碼示例。如果您正苦於以下問題:Golang Factory類的具體用法?Golang Factory怎麽用?Golang Factory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Factory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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
}
示例2: Requirements
func (cmd *Password) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
reqs := []requirements.Requirement{
requirementsFactory.NewLoginRequirement(),
}
return reqs, nil
}
示例3: 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
}
示例4: 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
}
示例5: 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
}
示例6: 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
}
示例7: 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
}
示例8: 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
}
示例9: Requirements
func (cmd *ShowFeatureFlag) 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("feature-flag"))
return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 1)
}
reqs := []requirements.Requirement{
requirementsFactory.NewLoginRequirement(),
}
return reqs, nil
}
示例10: 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
}
示例11: 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
}
示例12: Requirements
func (cmd *Curl) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
if len(fc.Args()) != 1 {
cmd.ui.Failed(T("Incorrect Usage. An argument is missing or not correctly enclosed.\n\n") + commandregistry.Commands.CommandUsage("curl"))
return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 1)
}
reqs := []requirements.Requirement{
requirementsFactory.NewAPIEndpointRequirement(),
}
return reqs, nil
}
示例13: 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
}
示例14: Requirements
func (cmd *DeleteServiceKey) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
if len(fc.Args()) != 2 {
cmd.ui.Failed(T("Incorrect Usage. Requires SERVICE_INSTANCE SERVICE_KEY as arguments\n\n") + commandregistry.Commands.CommandUsage("delete-service-key"))
return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 2)
}
loginRequirement := requirementsFactory.NewLoginRequirement()
targetSpaceRequirement := requirementsFactory.NewTargetedSpaceRequirement()
reqs := []requirements.Requirement{loginRequirement, targetSpaceRequirement}
return reqs, nil
}
示例15: Requirements
func (cmd *Authenticate) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
if len(fc.Args()) != 2 {
cmd.ui.Failed(T("Incorrect Usage. Requires 'username password' as arguments\n\n") + commandregistry.Commands.CommandUsage("auth"))
return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 2)
}
reqs := []requirements.Requirement{
requirementsFactory.NewAPIEndpointRequirement(),
}
return reqs, nil
}