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

Method quotaString

cf/commands/space/space.go:152–178  ·  view source on GitHub ↗
(space models.Space)

Source from the content-addressed store, hash-verified

150}
151
152func (cmd *ShowSpace) quotaString(space models.Space) (string, error) {
153 if space.SpaceQuotaGUID == "" {
154 return "", nil
155 }
156
157 quota, err := cmd.quotaRepo.FindByGUID(space.SpaceQuotaGUID)
158 if err != nil {
159 return "", err
160 }
161
162 spaceQuotaFields := []string{}
163 spaceQuotaFields = append(spaceQuotaFields, T("{{.MemoryLimit}} memory limit", map[string]interface{}{"MemoryLimit": quota.FormattedMemoryLimit()}))
164 spaceQuotaFields = append(spaceQuotaFields, T("{{.InstanceMemoryLimit}} instance memory limit", map[string]interface{}{"InstanceMemoryLimit": quota.FormattedInstanceMemoryLimit()}))
165 spaceQuotaFields = append(spaceQuotaFields, T("{{.RoutesLimit}} routes", map[string]interface{}{"RoutesLimit": quota.RoutesLimit}))
166 spaceQuotaFields = append(spaceQuotaFields, T("{{.ServicesLimit}} services", map[string]interface{}{"ServicesLimit": quota.ServicesLimit}))
167 spaceQuotaFields = append(spaceQuotaFields, T("paid services {{.NonBasicServicesAllowed}}", map[string]interface{}{"NonBasicServicesAllowed": formatters.Allowed(quota.NonBasicServicesAllowed)}))
168 spaceQuotaFields = append(spaceQuotaFields, T("{{.AppInstanceLimit}} app instance limit", map[string]interface{}{"AppInstanceLimit": quota.FormattedAppInstanceLimit()}))
169
170 routePorts := quota.FormattedRoutePortsLimit()
171 if routePorts != "" {
172 spaceQuotaFields = append(spaceQuotaFields, T("{{.ReservedRoutePorts}} route ports", map[string]interface{}{"ReservedRoutePorts": routePorts}))
173 }
174
175 spaceQuota := fmt.Sprintf("%s (%s)", quota.Name, strings.Join(spaceQuotaFields, ", "))
176
177 return spaceQuota, nil
178}
179
180func (cmd *ShowSpace) populatePluginModel(space models.Space) {
181 cmd.pluginModel.Name = space.Name

Callers 1

ExecuteMethod · 0.95

Calls 6

AllowedFunction · 0.92
FormattedMemoryLimitMethod · 0.80
FindByGUIDMethod · 0.65

Tested by

no test coverage detected