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 *ListSpaceQuotas) GetRequirements(requirementsFactory requirements.Factory, c *cli.Context) (reqs []requirements.Requirement, err error) { reqs = []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), } return }
func (cmd *ListSpaceQuotas) GetRequirements(requirementsFactory requirements.Factory, c *cli.Context) (reqs []requirements.Requirement, err error) { if len(c.Args()) != 0 { cmd.ui.FailWithUsage(c) } reqs = []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), } return }
func (cmd SetSpaceQuota) GetRequirements(requirementsFactory requirements.Factory, context *cli.Context) ([]requirements.Requirement, error) { if len(context.Args()) != 2 { cmd.ui.FailWithUsage(context) } return []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), }, nil }
func (cmd *CreateSpaceQuota) 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("create-space-quota")) } return []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), }, nil }
func (cmd *SetSpaceQuota) 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-NAME and SPACE-QUOTA-NAME as arguments\n\n") + command_registry.Commands.CommandUsage("set-space-quota")) } return []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), }, nil }
func (cmd *CheckRoute) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) (reqs []requirements.Requirement, err error) { if len(fc.Args()) != 2 { cmd.ui.Failed(T("Incorrect Usage. Requires host and domain as arguments\n\n") + command_registry.Commands.CommandUsage("check-route")) } reqs = []requirements.Requirement{ requirementsFactory.NewTargetedOrgRequirement(), requirementsFactory.NewLoginRequirement(), } return }
func (cmd *CheckRoute) GetRequirements(requirementsFactory requirements.Factory, c *cli.Context) (reqs []requirements.Requirement, err error) { if len(c.Args()) != 2 { cmd.ui.FailWithUsage(c) return } reqs = []requirements.Requirement{ requirementsFactory.NewTargetedOrgRequirement(), requirementsFactory.NewLoginRequirement(), } return }
func (cmd *ListSpaceQuotas) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) (reqs []requirements.Requirement, err error) { if len(fc.Args()) != 0 { cmd.ui.Failed(T("Incorrect Usage. No argument required\n\n") + command_registry.Commands.CommandUsage("space-quotas")) } reqs = []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), } return }
func (cmd *UnsetSpaceQuota) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) []requirements.Requirement { if len(fc.Args()) != 2 { cmd.ui.Failed(T("Incorrect Usage. Requires SPACE and QUOTA as arguments\n\n") + commandregistry.Commands.CommandUsage("unset-space-quota")) } reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), } return reqs }
func (cmd *CreateSpace) 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("create-space")) } reqs = []requirements.Requirement{requirementsFactory.NewLoginRequirement()} if fc.String("o") == "" { reqs = append(reqs, requirementsFactory.NewTargetedOrgRequirement()) } return }
func (cmd CreateSpace) GetRequirements(requirementsFactory requirements.Factory, c *cli.Context) (reqs []requirements.Requirement, err error) { if len(c.Args()) == 0 { cmd.ui.FailWithUsage(c) } reqs = []requirements.Requirement{requirementsFactory.NewLoginRequirement()} if c.String("o") == "" { reqs = append(reqs, requirementsFactory.NewTargetedOrgRequirement()) } return }
func (cmd *ListDomains) GetRequirements(requirementsFactory requirements.Factory, c *cli.Context) (reqs []requirements.Requirement, err error) { if len(c.Args()) > 0 { cmd.ui.FailWithUsage(c) } cmd.orgReq = requirementsFactory.NewTargetedOrgRequirement() reqs = []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), cmd.orgReq, } return }
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 *SetSpaceQuota) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 2 { cmd.ui.Failed(T("Incorrect Usage. Requires SPACE-NAME and SPACE-QUOTA-NAME as arguments\n\n") + commandregistry.Commands.CommandUsage("set-space-quota")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 2) } reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), } return reqs, nil }
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 *DeleteSharedDomain) 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("delete-shared-domain")) } loginReq := requirementsFactory.NewLoginRequirement() cmd.orgReq = requirementsFactory.NewTargetedOrgRequirement() reqs = []requirements.Requirement{ loginReq, cmd.orgReq, } return }
func (cmd *DeleteDomain) GetRequirements(requirementsFactory requirements.Factory, c *cli.Context) (reqs []requirements.Requirement, err error) { if len(c.Args()) != 1 { cmd.ui.FailWithUsage(c) } loginReq := requirementsFactory.NewLoginRequirement() cmd.orgReq = requirementsFactory.NewTargetedOrgRequirement() reqs = []requirements.Requirement{ loginReq, cmd.orgReq, } return }
func (cmd *ListSpaces) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) []requirements.Requirement { usageReq := requirements.NewUsageRequirement(commandregistry.CLICommandUsagePresenter(cmd), T("No argument required"), func() bool { return len(fc.Args()) != 0 }, ) reqs := []requirements.Requirement{ usageReq, requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), } 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 *CreateSpace) 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("create-space")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 1) } reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), } if fc.String("o") == "" { reqs = append(reqs, requirementsFactory.NewTargetedOrgRequirement()) } return reqs, nil }
func (cmd *CreateSpaceQuota) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) []requirements.Requirement { if len(fc.Args()) != 1 { cmd.ui.Failed(T("Incorrect Usage. Requires an argument\n\n") + command_registry.Commands.CommandUsage("create-space-quota")) } reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), } if fc.IsSet("a") { reqs = append(reqs, requirementsFactory.NewMinAPIVersionRequirement("Option '-a'", cf.SpaceAppInstanceLimitMinimumApiVersion)) } return reqs }
func (cmd *DeleteDomain) 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-domain")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 1) } loginReq := requirementsFactory.NewLoginRequirement() cmd.orgReq = requirementsFactory.NewTargetedOrgRequirement() reqs := []requirements.Requirement{ loginReq, cmd.orgReq, } return reqs, nil }
func (cmd *UpdateSpaceQuota) 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("update-space-quota")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 1) } reqs := []requirements.Requirement{ requirementsFactory.NewLoginRequirement(), requirementsFactory.NewTargetedOrgRequirement(), } if fc.IsSet("a") { reqs = append(reqs, requirementsFactory.NewMinAPIVersionRequirement("Option '-a'", cf.SpaceAppInstanceLimitMinimumAPIVersion)) } 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 *CheckRoute) Requirements(requirementsFactory requirements.Factory, fc flags.FlagContext) ([]requirements.Requirement, error) { if len(fc.Args()) != 2 { cmd.ui.Failed(T("Incorrect Usage. Requires host and domain as arguments\n\n") + commandregistry.Commands.CommandUsage("check-route")) return nil, fmt.Errorf("Incorrect usage: %d arguments of %d required", len(fc.Args()), 2) } var reqs []requirements.Requirement if fc.String("path") != "" { reqs = append(reqs, requirementsFactory.NewMinAPIVersionRequirement("Option '--path'", cf.RoutePathMinimumAPIVersion)) } reqs = append(reqs, []requirements.Requirement{ requirementsFactory.NewTargetedOrgRequirement(), requirementsFactory.NewLoginRequirement(), }...) return reqs, nil }