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

Method Execute

command/v7/security_group_command.go:16–62  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

14}
15
16func (cmd SecurityGroupCommand) Execute(args []string) error {
17 err := cmd.SharedActor.CheckTarget(false, false)
18 if err != nil {
19 return err
20 }
21
22 user, err := cmd.Actor.GetCurrentUser()
23 if err != nil {
24 return err
25 }
26
27 cmd.UI.DisplayTextWithFlavor("Getting info for security group {{.GroupName}} as {{.Username}}...", map[string]interface{}{
28 "GroupName": cmd.RequiredArgs.SecurityGroup,
29 "Username": user.Name,
30 })
31 cmd.UI.DisplayNewline()
32
33 securityGroupSummary, warnings, err := cmd.Actor.GetSecurityGroupSummary(cmd.RequiredArgs.SecurityGroup)
34 cmd.UI.DisplayWarnings(warnings)
35 if err != nil {
36 return err
37 }
38
39 cmd.UI.DisplayKeyValueTable("", [][]string{
40 {cmd.UI.TranslateText("name:"), securityGroupSummary.Name},
41 {cmd.UI.TranslateText("rules:"), ""},
42 }, 3)
43
44 err = cmd.UI.DisplayJSON("", securityGroupSummary.Rules)
45 if err != nil {
46 return err
47 }
48
49 cmd.UI.DisplayNewline()
50
51 if len(securityGroupSummary.SecurityGroupSpaces) > 0 {
52 table := [][]string{{"organization", "space"}}
53 for _, securityGroupSpace := range securityGroupSummary.SecurityGroupSpaces {
54 table = append(table, []string{securityGroupSpace.OrgName, securityGroupSpace.SpaceName})
55 }
56 cmd.UI.DisplayTableWithHeader("", table, ui.DefaultTableSpacePadding)
57 } else {
58 cmd.UI.DisplayText("No spaces assigned")
59 }
60
61 return nil
62}

Callers

nothing calls this directly

Calls 11

CheckTargetMethod · 0.65
GetCurrentUserMethod · 0.65
DisplayTextWithFlavorMethod · 0.65
DisplayNewlineMethod · 0.65
DisplayWarningsMethod · 0.65
DisplayKeyValueTableMethod · 0.65
TranslateTextMethod · 0.65
DisplayJSONMethod · 0.65
DisplayTextMethod · 0.65

Tested by

no test coverage detected