MCPcopy Create free account
hub / github.com/cloudfoundry/cli / Requirements

Method Requirements

cf/commands/route/map_route.go:63–96  ·  view source on GitHub ↗
(requirementsFactory requirements.Factory, fc flags.FlagContext)

Source from the content-addressed store, hash-verified

61}
62
63func (cmd *MapRoute) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) {
64 if len(fc.Args()) != 2 {
65 cmd.ui.Failed(T("Incorrect Usage. Requires APP_NAME and DOMAIN as arguments\n\n") + commandregistry.Commands.CommandUsage("map-route"))
66 return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 2)
67 }
68
69 if fc.IsSet("port") && (fc.IsSet("hostname") || fc.IsSet("path")) {
70 cmd.ui.Failed(T("Cannot specify port together with hostname and/or path."))
71 return nil, fmt.Errorf("Cannot specify port together with hostname and/or path.")
72 }
73
74 if fc.IsSet("random-port") && (fc.IsSet("port") || fc.IsSet("hostname") || fc.IsSet("path")) {
75 cmd.ui.Failed(T("Cannot specify random-port together with port, hostname and/or path."))
76 return nil, fmt.Errorf("Cannot specify random-port together with port, hostname and/or path.")
77 }
78
79 appName := fc.Args()[0]
80 domainName := fc.Args()[1]
81
82 requirement := requirementsFactory.NewApplicationRequirement(appName)
83 cmd.appReq = requirement
84
85 cmd.domainReq = requirementsFactory.NewDomainRequirement(domainName)
86
87 var reqs []requirements.Requirement
88
89 reqs = append(reqs, []requirements.Requirement{
90 requirementsFactory.NewLoginRequirement(),
91 cmd.appReq,
92 cmd.domainReq,
93 }...)
94
95 return reqs, nil
96}
97
98func (cmd *MapRoute) SetDependency(deps commandregistry.Dependency, pluginCall bool) commandregistry.Command {
99 cmd.ui = deps.UI

Callers

nothing calls this directly

Calls 7

CommandUsageMethod · 0.80
ArgsMethod · 0.65
FailedMethod · 0.65
IsSetMethod · 0.65
NewDomainRequirementMethod · 0.65
NewLoginRequirementMethod · 0.65

Tested by

no test coverage detected