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

Method Execute

cf/commands/service/service.go:71–152  ·  view source on GitHub ↗
(c flags.FlagContext)

Source from the content-addressed store, hash-verified

69}
70
71func (cmd *ShowService) Execute(c flags.FlagContext) error {
72 serviceInstance := cmd.serviceInstanceReq.GetServiceInstance()
73
74 boundApps := []string{}
75 for _, serviceBinding := range serviceInstance.ServiceBindings {
76 app, err := cmd.appRepo.GetApp(serviceBinding.AppGUID)
77 if err != nil {
78 cmd.ui.Warn(T("Unable to retrieve information for bound application GUID " + serviceBinding.AppGUID))
79 }
80 boundApps = append(boundApps, app.ApplicationFields.Name)
81 }
82
83 if cmd.pluginCall {
84 cmd.populatePluginModel(serviceInstance)
85 return nil
86 }
87
88 if c.Bool("guid") {
89 cmd.ui.Say(serviceInstance.GUID)
90 } else {
91 cmd.ui.Say("")
92 cmd.ui.Say(T("Service instance: {{.ServiceName}}", map[string]interface{}{"ServiceName": terminal.EntityNameColor(serviceInstance.Name)}))
93
94 if serviceInstance.IsUserProvided() {
95 cmd.ui.Say(T("Service: {{.ServiceDescription}}",
96 map[string]interface{}{
97 "ServiceDescription": terminal.EntityNameColor(T("user-provided")),
98 }))
99 cmd.ui.Say(T("Bound apps: {{.BoundApplications}}",
100 map[string]interface{}{
101 "BoundApplications": terminal.EntityNameColor(strings.Join(boundApps, ",")),
102 }))
103 } else {
104 cmd.ui.Say(T("Service: {{.ServiceDescription}}",
105 map[string]interface{}{
106 "ServiceDescription": terminal.EntityNameColor(serviceInstance.ServiceOffering.Label),
107 }))
108 cmd.ui.Say(T("Bound apps: {{.BoundApplications}}",
109 map[string]interface{}{
110 "BoundApplications": terminal.EntityNameColor(strings.Join(boundApps, ",")),
111 }))
112 cmd.ui.Say(T("Tags: {{.Tags}}",
113 map[string]interface{}{
114 "Tags": terminal.EntityNameColor(strings.Join(serviceInstance.Tags, ", ")),
115 }))
116 cmd.ui.Say(T("Plan: {{.ServicePlanName}}",
117 map[string]interface{}{
118 "ServicePlanName": terminal.EntityNameColor(serviceInstance.ServicePlan.Name),
119 }))
120 cmd.ui.Say(T("Description: {{.ServiceDescription}}", map[string]interface{}{"ServiceDescription": terminal.EntityNameColor(serviceInstance.ServiceOffering.Description)}))
121 cmd.ui.Say(T("Documentation url: {{.URL}}",
122 map[string]interface{}{
123 "URL": terminal.EntityNameColor(serviceInstance.ServiceOffering.DocumentationURL),
124 }))
125 cmd.ui.Say(T("Dashboard: {{.URL}}",
126 map[string]interface{}{
127 "URL": terminal.EntityNameColor(serviceInstance.DashboardURL),
128 }))

Callers

nothing calls this directly

Calls 9

populatePluginModelMethod · 0.95
EntityNameColorFunction · 0.92
InstanceStateToStatusFunction · 0.85
IsUserProvidedMethod · 0.80
GetServiceInstanceMethod · 0.65
GetAppMethod · 0.65
WarnMethod · 0.65
BoolMethod · 0.65
SayMethod · 0.65

Tested by

no test coverage detected