MCPcopy Index your code
hub / github.com/cloudfoundry/cli / Execute

Method Execute

command/v7/env_command.go:19–90  ·  view source on GitHub ↗
(_ []string)

Source from the content-addressed store, hash-verified

17}
18
19func (cmd EnvCommand) Execute(_ []string) error {
20 err := cmd.SharedActor.CheckTarget(true, true)
21 if err != nil {
22 return err
23 }
24
25 user, err := cmd.Actor.GetCurrentUser()
26 if err != nil {
27 return err
28 }
29
30 appName := cmd.RequiredArgs.AppName
31 cmd.UI.DisplayTextWithFlavor("Getting env variables for app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...", map[string]interface{}{
32 "AppName": appName,
33 "OrgName": cmd.Config.TargetedOrganization().Name,
34 "SpaceName": cmd.Config.TargetedSpace().Name,
35 "Username": user.Name,
36 })
37
38 envGroups, warnings, err := cmd.Actor.GetEnvironmentVariablesByApplicationNameAndSpace(
39 appName,
40 cmd.Config.TargetedSpace().GUID,
41 )
42 cmd.UI.DisplayWarnings(warnings)
43 if err != nil {
44 return err
45 }
46
47 if len(envGroups.System) > 0 || len(envGroups.Application) > 0 {
48 cmd.UI.DisplayHeader("System-Provided:")
49 err = cmd.displaySystem(envGroups.System)
50 if err != nil {
51 log.Errorln("error formatting system provided:", err)
52 }
53 if len(envGroups.Application) > 0 {
54 cmd.UI.DisplayNewline()
55 err = cmd.displaySystem(envGroups.Application)
56 if err != nil {
57 log.Errorln("error formatting application:", err)
58 }
59 }
60 } else {
61 cmd.UI.DisplayText("No system-provided env variables have been set")
62 }
63 cmd.UI.DisplayNewline()
64
65 if len(envGroups.EnvironmentVariables) > 0 {
66 cmd.UI.DisplayHeader("User-Provided:")
67 cmd.displayEnvGroup(envGroups.EnvironmentVariables)
68 } else {
69 cmd.UI.DisplayText("No user-provided env variables have been set")
70 }
71 cmd.UI.DisplayNewline()
72
73 if len(envGroups.Running) > 0 {
74 cmd.UI.DisplayHeader("Running Environment Variable Groups:")
75 cmd.displayEnvGroup(envGroups.Running)
76 } else {

Callers

nothing calls this directly

Calls 12

displaySystemMethod · 0.95
displayEnvGroupMethod · 0.95
CheckTargetMethod · 0.65
GetCurrentUserMethod · 0.65
DisplayTextWithFlavorMethod · 0.65
TargetedOrganizationMethod · 0.65
TargetedSpaceMethod · 0.65
DisplayWarningsMethod · 0.65
DisplayHeaderMethod · 0.65
DisplayNewlineMethod · 0.65
DisplayTextMethod · 0.65

Tested by

no test coverage detected