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

Method Execute

cf/commands/securitygroup/security_group.go:57–102  ·  view source on GitHub ↗
(c flags.FlagContext)

Source from the content-addressed store, hash-verified

55}
56
57func (cmd *ShowSecurityGroup) Execute(c flags.FlagContext) error {
58 name := c.Args()[0]
59
60 cmd.ui.Say(T("Getting info for security group {{.security_group}} as {{.username}}...",
61 map[string]interface{}{
62 "security_group": terminal.EntityNameColor(name),
63 "username": terminal.EntityNameColor(cmd.configRepo.Username()),
64 }))
65
66 securityGroup, err := cmd.securityGroupRepo.Read(name)
67 if err != nil {
68 return err
69 }
70
71 jsonEncodedBytes, err := json.MarshalIndent(securityGroup.Rules, "\t", "\t")
72 if err != nil {
73 return err
74 }
75
76 cmd.ui.Ok()
77 table := cmd.ui.Table([]string{"", ""})
78 table.Add(T("Name"), securityGroup.Name)
79 table.Add(T("Rules"), "")
80 err = table.Print()
81 if err != nil {
82 return err
83 }
84 cmd.ui.Say("\t" + string(jsonEncodedBytes))
85
86 cmd.ui.Say("")
87
88 if len(securityGroup.Spaces) > 0 {
89 table = cmd.ui.Table([]string{"", T("Organization"), T("Space")})
90
91 for index, space := range securityGroup.Spaces {
92 table.Add(fmt.Sprintf("#%d", index), space.Organization.Name, space.Name)
93 }
94 err = table.Print()
95 if err != nil {
96 return err
97 }
98 } else {
99 cmd.ui.Say(T("No spaces assigned"))
100 }
101 return nil
102}

Callers

nothing calls this directly

Calls 9

EntityNameColorFunction · 0.92
ArgsMethod · 0.65
SayMethod · 0.65
UsernameMethod · 0.65
ReadMethod · 0.65
OkMethod · 0.65
TableMethod · 0.65
AddMethod · 0.65
PrintMethod · 0.65

Tested by

no test coverage detected