github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/command/v6/disable_org_isolation_command.go (about) 1 package v6 2 3 import ( 4 "code.cloudfoundry.org/cli/actor/sharedaction" 5 "code.cloudfoundry.org/cli/actor/v3action" 6 "code.cloudfoundry.org/cli/command" 7 "code.cloudfoundry.org/cli/command/flag" 8 "code.cloudfoundry.org/cli/command/v6/shared" 9 ) 10 11 //go:generate counterfeiter . DisableOrgIsolationActor 12 13 type DisableOrgIsolationActor interface { 14 DeleteIsolationSegmentOrganizationByName(isolationSegmentName string, orgName string) (v3action.Warnings, error) 15 } 16 type DisableOrgIsolationCommand struct { 17 RequiredArgs flag.OrgIsolationArgs `positional-args:"yes"` 18 usage interface{} `usage:"CF_NAME disable-org-isolation ORG_NAME SEGMENT_NAME"` 19 relatedCommands interface{} `related_commands:"enable-org-isolation, isolation-segments"` 20 21 UI command.UI 22 Config command.Config 23 SharedActor command.SharedActor 24 Actor DisableOrgIsolationActor 25 } 26 27 func (cmd *DisableOrgIsolationCommand) Setup(config command.Config, ui command.UI) error { 28 cmd.UI = ui 29 cmd.Config = config 30 cmd.SharedActor = sharedaction.NewActor(config) 31 32 client, _, err := shared.NewV3BasedClients(config, ui, true) 33 if err != nil { 34 return err 35 } 36 cmd.Actor = v3action.NewActor(client, config, nil, nil) 37 38 return nil 39 } 40 41 func (cmd DisableOrgIsolationCommand) Execute(args []string) error { 42 err := cmd.SharedActor.CheckTarget(false, false) 43 if err != nil { 44 return err 45 } 46 user, err := cmd.Config.CurrentUser() 47 if err != nil { 48 return err 49 } 50 51 cmd.UI.DisplayTextWithFlavor("Removing entitlement to isolation segment {{.SegmentName}} from org {{.OrgName}} as {{.CurrentUser}}...", map[string]interface{}{ 52 "SegmentName": cmd.RequiredArgs.IsolationSegmentName, 53 "OrgName": cmd.RequiredArgs.OrganizationName, 54 "CurrentUser": user.Name, 55 }) 56 57 warnings, err := cmd.Actor.DeleteIsolationSegmentOrganizationByName(cmd.RequiredArgs.IsolationSegmentName, cmd.RequiredArgs.OrganizationName) 58 59 cmd.UI.DisplayWarnings(warnings) 60 61 if err != nil { 62 return err 63 } 64 65 cmd.UI.DisplayOK() 66 67 return nil 68 }