Skip to content

Commit

Permalink
Fix in clearing space fields of config data on cf space-delete
Browse files Browse the repository at this point in the history
Before Fix: If cf user deleting the targeted space but with space name as
case insenstive then space fields are not deleted from the config
htipl@cf5:~/go/src/github.com/cloudfoundry/cli$ cf spaces
Getting spaces in org SriniOrg as admin...
name
No spaces found
htipl@cf5:~/go/src/github.com/cloudfoundry/cli$ cf target
API endpoint:   https://api.10.244.0.34.xip.io (API version: 2.13.0)
User:           admin
Org:            SriniOrg
Space:          SriniSpace

After Fix:If cf user does same steps
space fields are deleted from the config
htipl@cf5:~/go/src/github.com/cloudfoundry/cli$ ./out/cf spaces
Getting spaces in org SriniOrg as admin...
name
No spaces found
htipl@cf5:~/go/src/github.com/cloudfoundry/cli$ ./out/cf target
API endpoint:   https://api.10.244.0.34.xip.io (API version: 2.13.0)
User:           admin
Org:            SriniOrg
Space:          No space targeted, use 'cf target -s SPACE'

http://rnd-github.huawei.com/paas/cli/issues/28
  • Loading branch information
SrinivasChilveri authored and shashidharatd committed Dec 3, 2014
1 parent e54473d commit 5d5a8b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cf/commands/space/delete_space.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (cmd *DeleteSpace) Run(c *cli.Context) {

cmd.ui.Ok()

if cmd.config.SpaceFields().Name == spaceName {
if cmd.config.SpaceFields().Guid == space.Guid {
cmd.config.SetSpaceFields(models.SpaceFields{})
cmd.ui.Say(T("TIP: No space targeted, use '{{.CfTargetCommand}}' to target a space",
map[string]interface{}{"CfTargetCommand": cf.Name() + " target -s"}))
Expand Down
7 changes: 7 additions & 0 deletions cf/commands/space/delete_space_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,11 @@ var _ = Describe("delete-space command", func() {

Expect(config.HasSpace()).To(Equal(false))
})

It("clears the space from the config, when deleting the space currently targeted even if space name is case insensitive", func() {
config.SetSpaceFields(space.SpaceFields)
runCommand("-f", "Space-To-Delete")

Expect(config.HasSpace()).To(Equal(false))
})
})

0 comments on commit 5d5a8b4

Please sign in to comment.