(args []string)
| 14 | } |
| 15 | |
| 16 | func (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 | } |
nothing calls this directly
no test coverage detected