MCPcopy
hub / github.com/cloudfoundry/cli / getAppParamsFromContext

Method getAppParamsFromContext

cf/commands/application/push.go:684–806  ·  view source on GitHub ↗
(c flags.FlagContext)

Source from the content-addressed store, hash-verified

682}
683
684func (cmd *Push) getAppParamsFromContext(c flags.FlagContext) (models.AppParams, error) {
685 noHostBool := c.Bool("no-hostname")
686 appParams := models.AppParams{
687 NoRoute: c.Bool("no-route"),
688 UseRandomRoute: c.Bool("random-route"),
689 NoHostname: &noHostBool,
690 }
691
692 if len(c.Args()) > 0 {
693 appParams.Name = &c.Args()[0]
694 }
695
696 if c.String("n") != "" {
697 appParams.Hosts = []string{c.String("n")}
698 }
699
700 if c.String("route-path") != "" {
701 routePath := c.String("route-path")
702 appParams.RoutePath = &routePath
703 }
704
705 if c.String("b") != "" {
706 buildpack := c.String("b")
707 if buildpack == "null" || buildpack == "default" {
708 buildpack = ""
709 }
710 appParams.BuildpackURL = &buildpack
711 }
712
713 if c.String("c") != "" {
714 command := c.String("c")
715 if command == "null" || command == "default" {
716 command = ""
717 }
718 appParams.Command = &command
719 }
720
721 if c.String("d") != "" {
722 appParams.Domains = []string{c.String("d")}
723 }
724
725 if c.IsSet("i") {
726 instances := c.Int("i")
727 if instances < 1 {
728 return models.AppParams{}, errors.New(T("Invalid instance count: {{.InstancesCount}}\nInstance count must be a positive integer",
729 map[string]interface{}{"InstancesCount": instances}))
730 }
731 appParams.InstanceCount = &instances
732 }
733
734 if c.String("k") != "" {
735 diskQuota, err := formatters.ToMegabytes(c.String("k"))
736 if err != nil {
737 return models.AppParams{}, errors.New(T("Invalid disk quota: {{.DiskQuota}}\n{{.Err}}",
738 map[string]interface{}{"DiskQuota": c.String("k"), "Err": err.Error()}))
739 }
740 appParams.DiskQuota = &diskQuota
741 }

Callers 1

ExecuteMethod · 0.95

Calls 10

NewFunction · 0.92
ToMegabytesFunction · 0.92
BoolMethod · 0.65
ArgsMethod · 0.65
StringMethod · 0.65
IsSetMethod · 0.65
IntMethod · 0.65
ErrorMethod · 0.65
SayMethod · 0.65
AskForPasswordMethod · 0.65

Tested by

no test coverage detected