func (cmd *CreateRoute) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 2 { cmd.ui.Failed(T("Incorrect Usage. Requires SPACE and DOMAIN as arguments\n\n") + command_registry.Commands.CommandUsage("create-route")) } domainName := fc.Args()[1] cmd.spaceReq = requirementsFactory.NewSpaceRequirement(fc.Args()[0]) cmd.domainReq = requirementsFactory.NewDomainRequirement(domainName) requiredVersion, err := semver.Make("2.36.0") if err != nil { panic(err.Error()) } var reqs []requirements.Requirement if fc.String("path") != "" { reqs = append(reqs, requirementsFactory.NewMinAPIVersionRequirement("Option '--path'", requiredVersion)) } reqs = append(reqs, []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), cmd.spaceReq, cmd.domainReq, }...) return reqs, nil }
func (cmd *RenameSpace) GetRequirements(requirementsFactory requirements.Factory, c *cli.Context) (reqs []requirements.Requirement, err error) { if len(c.Args()) != 2 { cmd.ui.FailWithUsage(c) } cmd.spaceReq = requirementsFactory.NewSpaceRequirement(c.Args()[0]) reqs = []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), cmd.spaceReq, } return }
func (cmd *ShowSpace) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) (reqs []requirements.Requirement, err error) { if len(fc.Args()) != 1 { cmd.ui.Failed(T("Incorrect Usage. Requires an argument\n\n") + command_registry.Commands.CommandUsage("space")) } cmd.spaceReq = requirementsFactory.NewSpaceRequirement(fc.Args()[0]) reqs = []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), cmd.spaceReq, } return }
func (cmd *SpaceSSHAllowed) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) []requirements.Requirement { if len(fc.Args()) != 1 { cmd.ui.Failed(T("Incorrect Usage. Requires SPACE_NAME as argument\n\n") + commandregistry.Commands.CommandUsage("space-ssh-allowed")) } cmd.spaceReq = requirementsFactory.NewSpaceRequirement(fc.Args()[0]) reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), cmd.spaceReq, } return reqs }
func (cmd *RenameSpace) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) []requirements.Requirement { if len(fc.Args()) != 2 { cmd.ui.Failed(T("Incorrect Usage. Requires SPACE_NAME NEW_SPACE_NAME as arguments\n\n") + command_registry.Commands.CommandUsage("rename-space")) } cmd.spaceReq = requirementsFactory.NewSpaceRequirement(fc.Args()[0]) reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), cmd.spaceReq, } return reqs }
func (cmd *ShowSpace) 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("space")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 1) } cmd.spaceReq = requirementsFactory.NewSpaceRequirement(fc.Args()[0]) reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), cmd.spaceReq, } return reqs, nil }
func (cmd *ShowSpace) GetRequirements(requirementsFactory requirements.Factory, c *cli.Context) (reqs []requirements.Requirement, err error) { if len(c.Args()) != 1 { cmd.ui.FailWithUsage(c) } if cmd.spaceReq == nil { cmd.spaceReq = requirementsFactory.NewSpaceRequirement(c.Args()[0]) } else { cmd.spaceReq.SetSpaceName(c.Args()[0]) } reqs = []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), cmd.spaceReq, } return }
func (cmd *CreateRoute) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) (reqs []requirements.Requirement, err error) { if len(fc.Args()) != 2 { cmd.ui.Failed(T("Incorrect Usage. Requires SPACE and DOMAIN as arguments\n\n") + command_registry.Commands.CommandUsage("create-route")) } domainName := fc.Args()[1] cmd.spaceReq = requirementsFactory.NewSpaceRequirement(fc.Args()[0]) cmd.domainReq = requirementsFactory.NewDomainRequirement(domainName) reqs = []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), cmd.spaceReq, cmd.domainReq, } return }
func (cmd *CreateRoute) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) []requirements.Requirement { if len(fc.Args()) != 2 { cmd.ui.Failed(T("Incorrect Usage. Requires SPACE and DOMAIN as arguments\n\n") + commandregistry.Commands.CommandUsage("create-route")) } if fc.IsSet("port") && (fc.IsSet("hostname") || fc.IsSet("path")) { cmd.ui.Failed(T("Cannot specify port together with hostname and/or path.")) } if fc.IsSet("random-port") && (fc.IsSet("port") || fc.IsSet("hostname") || fc.IsSet("path")) { cmd.ui.Failed(T("Cannot specify random-port together with port, hostname and/or path.")) } domainName := fc.Args()[1] cmd.spaceReq = requirementsFactory.NewSpaceRequirement(fc.Args()[0]) cmd.domainReq = requirementsFactory.NewDomainRequirement(domainName) reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), cmd.spaceReq, cmd.domainReq, } if fc.IsSet("path") { requiredVersion, err := semver.Make("2.36.0") if err != nil { panic(err.Error()) } reqs = append(reqs, requirementsFactory.NewMinAPIVersionRequirement("Option '--path'", requiredVersion)) } if fc.IsSet("port") { reqs = append(reqs, requirementsFactory.NewMinAPIVersionRequirement("Option '--port'", cf.TCPRoutingMinimumAPIVersion)) } if fc.IsSet("random-port") { reqs = append(reqs, requirementsFactory.NewMinAPIVersionRequirement("Option '--random-port'", cf.TCPRoutingMinimumAPIVersion)) } return reqs }
func (cmd *CreateRoute) GetRequirements(requirementsFactory requirements.Factory, c *cli.Context) (reqs []requirements.Requirement, err error) { if len(c.Args()) != 2 { cmd.ui.FailWithUsage(c) } spaceName := c.Args()[0] domainName := c.Args()[1] cmd.spaceReq = requirementsFactory.NewSpaceRequirement(spaceName) cmd.domainReq = requirementsFactory.NewDomainRequirement(domainName) reqs = []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), cmd.spaceReq, cmd.domainReq, } return }