github.com/sleungcy-sap/cli@v7.1.0+incompatible/command/v7/reset_space_isolation_segment_command.go (about) 1 package v7 2 3 import ( 4 "code.cloudfoundry.org/cli/command/flag" 5 ) 6 7 type ResetSpaceIsolationSegmentCommand struct { 8 BaseCommand 9 10 RequiredArgs flag.ResetSpaceIsolationArgs `positional-args:"yes"` 11 usage interface{} `usage:"CF_NAME reset-space-isolation-segment SPACE_NAME"` 12 relatedCommands interface{} `related_commands:"org, restart, space"` 13 } 14 15 func (cmd ResetSpaceIsolationSegmentCommand) Execute(args []string) error { 16 err := cmd.SharedActor.CheckTarget(true, false) 17 if err != nil { 18 return err 19 } 20 21 user, err := cmd.Config.CurrentUser() 22 if err != nil { 23 return err 24 } 25 26 cmd.UI.DisplayTextWithFlavor("Resetting isolation segment assignment of space {{.SpaceName}} in org {{.OrgName}} as {{.CurrentUser}}...", map[string]interface{}{ 27 "SpaceName": cmd.RequiredArgs.SpaceName, 28 "OrgName": cmd.Config.TargetedOrganization().Name, 29 "CurrentUser": user.Name, 30 }) 31 32 space, warnings, err := cmd.Actor.GetSpaceByNameAndOrganization(cmd.RequiredArgs.SpaceName, cmd.Config.TargetedOrganization().GUID) 33 cmd.UI.DisplayWarnings(warnings) 34 if err != nil { 35 return err 36 } 37 38 newIsolationSegmentName, warnings, err := cmd.Actor.ResetSpaceIsolationSegment(cmd.Config.TargetedOrganization().GUID, space.GUID) 39 cmd.UI.DisplayWarnings(warnings) 40 if err != nil { 41 return err 42 } 43 44 cmd.UI.DisplayOK() 45 46 if newIsolationSegmentName == "" { 47 cmd.UI.DisplayText("TIP: Restart applications in this space to relocate them to the platform default.") 48 } else { 49 cmd.UI.DisplayText("TIP: Restart applications in this space to relocate them to this organization's default isolation segment.") 50 } 51 52 return nil 53 }