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

Method Execute

cf/commands/service/services.go:66–137  ·  view source on GitHub ↗
(fc flags.FlagContext)

Source from the content-addressed store, hash-verified

64}
65
66func (cmd *ListServices) Execute(fc flags.FlagContext) error {
67 cmd.ui.Say(T("Getting services in org {{.OrgName}} / space {{.SpaceName}} as {{.CurrentUser}}...",
68 map[string]interface{}{
69 "OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
70 "SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
71 "CurrentUser": terminal.EntityNameColor(cmd.config.Username()),
72 }))
73
74 serviceInstances, err := cmd.serviceSummaryRepo.GetSummariesInCurrentSpace()
75
76 if err != nil {
77 return err
78 }
79
80 cmd.ui.Ok()
81 cmd.ui.Say("")
82
83 if len(serviceInstances) == 0 {
84 cmd.ui.Say(T("No services found"))
85 return nil
86 }
87
88 table := cmd.ui.Table([]string{T("name"), T("service"), T("plan"), T("bound apps"), T("last operation")})
89
90 for _, instance := range serviceInstances {
91 var serviceColumn string
92 var serviceStatus string
93
94 if instance.IsUserProvided() {
95 serviceColumn = T("user-provided")
96 } else {
97 serviceColumn = instance.ServiceOffering.Label
98 }
99 serviceStatus = InstanceStateToStatus(instance.LastOperation.Type, instance.LastOperation.State, instance.IsUserProvided())
100
101 table.Add(
102 instance.Name,
103 serviceColumn,
104 instance.ServicePlan.Name,
105 strings.Join(instance.ApplicationNames, ", "),
106 serviceStatus,
107 )
108 if cmd.pluginCall {
109 s := plugin_models.GetServices_Model{
110 Name: instance.Name,
111 Guid: instance.GUID,
112 ServicePlan: plugin_models.GetServices_ServicePlan{
113 Name: instance.ServicePlan.Name,
114 Guid: instance.ServicePlan.GUID,
115 },
116 Service: plugin_models.GetServices_ServiceFields{
117 Name: instance.ServiceOffering.Label,
118 },
119 ApplicationNames: instance.ApplicationNames,
120 LastOperation: plugin_models.GetServices_LastOperation{
121 Type: instance.LastOperation.Type,
122 State: instance.LastOperation.State,
123 },

Callers

nothing calls this directly

Calls 12

EntityNameColorFunction · 0.92
InstanceStateToStatusFunction · 0.85
IsUserProvidedMethod · 0.80
SayMethod · 0.65
OrganizationFieldsMethod · 0.65
SpaceFieldsMethod · 0.65
UsernameMethod · 0.65
OkMethod · 0.65
TableMethod · 0.65
AddMethod · 0.65
PrintMethod · 0.65

Tested by

no test coverage detected