Skip to content

Commit

Permalink
Backwards compatibility for getCurrentOrg and getCurrentSpace
Browse files Browse the repository at this point in the history
getCurrentOrg returns Organization
getOrg returns OrganizationDetails
getOrgs returns OrganizationSummary
getCurrentSpace returns Space
getSpace returns SpaceDetails
getSpaces returns SpaceSummary

[#97159474]

Signed-off-by: Andrew Edgar <aedgar@ca.ibm.com>
  • Loading branch information
markstgodard authored and andrew-edgar committed Jun 19, 2015
1 parent 9f62637 commit 271069d
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 60 deletions.
4 changes: 2 additions & 2 deletions cf/command_registry/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ type pluginModels struct {
Application *plugin_models.Application
AppsSummary *[]plugin_models.ApplicationSummary
Organizations *[]plugin_models.OrganizationSummary
Organization *plugin_models.Organization
Organization *plugin_models.OrganizationDetails
Spaces *[]plugin_models.SpaceSummary
Space *plugin_models.Space
Space *plugin_models.SpaceDetails
Users *[]plugin_models.User
ServiceInstances *[]plugin_models.ServiceInstance
}
Expand Down
2 changes: 1 addition & 1 deletion cf/commands/organization/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type ShowOrg struct {
ui terminal.UI
config core_config.Reader
orgReq requirements.OrganizationRequirement
pluginModel *plugin_models.Organization
pluginModel *plugin_models.OrganizationDetails
pluginCall bool
}

Expand Down
4 changes: 2 additions & 2 deletions cf/commands/organization/org_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ var _ = Describe("org command", func() {

Context("when invoked by a plugin", func() {
var (
pluginModel plugin_models.Organization
pluginModel plugin_models.OrganizationDetails
)
BeforeEach(func() {
pluginModel = plugin_models.Organization{}
pluginModel = plugin_models.OrganizationDetails{}
deps.PluginModels.Organization = &pluginModel
updateCommandDependency(true)
})
Expand Down
2 changes: 1 addition & 1 deletion cf/commands/space/space.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type ShowSpace struct {
config core_config.Reader
spaceReq requirements.SpaceRequirement
quotaRepo space_quotas.SpaceQuotaRepository
pluginModel *plugin_models.Space
pluginModel *plugin_models.SpaceDetails
pluginCall bool
}

Expand Down
4 changes: 2 additions & 2 deletions cf/commands/space/space_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ var _ = Describe("space command", func() {

Context("When called as a plugin", func() {
var (
pluginModel plugin_models.Space
pluginModel plugin_models.SpaceDetails
)
BeforeEach(func() {
pluginModel = plugin_models.Space{}
pluginModel = plugin_models.SpaceDetails{}
deps.PluginModels.Space = &pluginModel
updateCommandDependency(true)
})
Expand Down
24 changes: 12 additions & 12 deletions plugin/cli_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,25 @@ func (cliConnection *cliConnection) pingCLI() {
}
}

func (cliConnection *cliConnection) GetCurrentOrg() (plugin_models.OrganizationSummary, error) {
func (cliConnection *cliConnection) GetCurrentOrg() (plugin_models.Organization, error) {
client, err := rpc.Dial("tcp", "127.0.0.1:"+cliConnection.cliServerPort)
if err != nil {
return plugin_models.OrganizationSummary{}, err
return plugin_models.Organization{}, err
}

var result plugin_models.OrganizationSummary
var result plugin_models.Organization

err = client.Call("CliRpcCmd.GetCurrentOrg", "", &result)
return result, err
}

func (cliConnection *cliConnection) GetCurrentSpace() (plugin_models.SpaceSummary, error) {
func (cliConnection *cliConnection) GetCurrentSpace() (plugin_models.Space, error) {
client, err := rpc.Dial("tcp", "127.0.0.1:"+cliConnection.cliServerPort)
if err != nil {
return plugin_models.SpaceSummary{}, err
return plugin_models.Space{}, err
}

var result plugin_models.SpaceSummary
var result plugin_models.Space

err = client.Call("CliRpcCmd.GetCurrentSpace", "", &result)
return result, err
Expand Down Expand Up @@ -314,13 +314,13 @@ func (cliConnection *cliConnection) GetOrgs() ([]plugin_models.OrganizationSumma
return result, err
}

func (cliConnection *cliConnection) GetSpaces() ([]plugin_models.Space, error) {
func (cliConnection *cliConnection) GetSpaces() ([]plugin_models.SpaceSummary, error) {
client, err := rpc.Dial("tcp", "127.0.0.1:"+cliConnection.cliServerPort)
if err != nil {
return []plugin_models.Space{}, err
return []plugin_models.SpaceSummary{}, err
}

var result []plugin_models.Space
var result []plugin_models.SpaceSummary

err = client.Call("CliRpcCmd.GetSpaces", "", &result)
return result, err
Expand Down Expand Up @@ -366,13 +366,13 @@ func (cliConnection *cliConnection) GetSpaceUsers(orgName string, spaceName stri
return result, err
}

func (cliConnection *cliConnection) GetOrg(orgName string) (plugin_models.Organization, error) {
func (cliConnection *cliConnection) GetOrg(orgName string) (plugin_models.OrganizationDetails, error) {
client, err := rpc.Dial("tcp", "127.0.0.1:"+cliConnection.cliServerPort)
if err != nil {
return plugin_models.Organization{}, err
return plugin_models.OrganizationDetails{}, err
}

var result plugin_models.Organization
var result plugin_models.OrganizationDetails

err = client.Call("CliRpcCmd.GetOrg", orgName, &result)
return result, err
Expand Down
40 changes: 20 additions & 20 deletions plugin/fakes/fake_cli_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ type FakeCliConnection struct {
result1 []string
result2 error
}
GetCurrentOrgStub func() (plugin_models.OrganizationSummary, error)
GetCurrentOrgStub func() (plugin_models.Organization, error)
getCurrentOrgMutex sync.RWMutex
getCurrentOrgArgsForCall []struct{}
getCurrentOrgReturns struct {
result1 plugin_models.OrganizationSummary
result1 plugin_models.Organization
result2 error
}
GetCurrentSpaceStub func() (plugin_models.SpaceSummary, error)
GetCurrentSpaceStub func() (plugin_models.Space, error)
getCurrentSpaceMutex sync.RWMutex
getCurrentSpaceArgsForCall []struct{}
getCurrentSpaceReturns struct {
result1 plugin_models.SpaceSummary
result1 plugin_models.Space
result2 error
}
UsernameStub func() (string, error)
Expand Down Expand Up @@ -155,11 +155,11 @@ type FakeCliConnection struct {
result1 []plugin_models.OrganizationSummary
result2 error
}
GetSpacesStub func() ([]plugin_models.Space, error)
GetSpacesStub func() ([]plugin_models.SpaceSummary, error)
getSpacesMutex sync.RWMutex
getSpacesArgsForCall []struct{}
getSpacesReturns struct {
result1 []plugin_models.Space
result1 []plugin_models.SpaceSummary
result2 error
}
GetOrgUsersStub func(string, ...string) ([]plugin_models.User, error)
Expand Down Expand Up @@ -189,13 +189,13 @@ type FakeCliConnection struct {
result1 []plugin_models.ServiceInstance
result2 error
}
GetOrgStub func(string) (plugin_models.Organization, error)
GetOrgStub func(string) (plugin_models.OrganizationDetails, error)
getOrgMutex sync.RWMutex
getOrgArgsForCall []struct {
arg1 string
}
getOrgReturns struct {
result1 plugin_models.Organization
result1 plugin_models.OrganizationDetails
result2 error
}
}
Expand Down Expand Up @@ -266,7 +266,7 @@ func (fake *FakeCliConnection) CliCommandReturns(result1 []string, result2 error
}{result1, result2}
}

func (fake *FakeCliConnection) GetCurrentOrg() (plugin_models.OrganizationSummary, error) {
func (fake *FakeCliConnection) GetCurrentOrg() (plugin_models.Organization, error) {
fake.getCurrentOrgMutex.Lock()
fake.getCurrentOrgArgsForCall = append(fake.getCurrentOrgArgsForCall, struct{}{})
fake.getCurrentOrgMutex.Unlock()
Expand All @@ -283,15 +283,15 @@ func (fake *FakeCliConnection) GetCurrentOrgCallCount() int {
return len(fake.getCurrentOrgArgsForCall)
}

func (fake *FakeCliConnection) GetCurrentOrgReturns(result1 plugin_models.OrganizationSummary, result2 error) {
func (fake *FakeCliConnection) GetCurrentOrgReturns(result1 plugin_models.Organization, result2 error) {
fake.GetCurrentOrgStub = nil
fake.getCurrentOrgReturns = struct {
result1 plugin_models.OrganizationSummary
result1 plugin_models.Organization
result2 error
}{result1, result2}
}

func (fake *FakeCliConnection) GetCurrentSpace() (plugin_models.SpaceSummary, error) {
func (fake *FakeCliConnection) GetCurrentSpace() (plugin_models.Space, error) {
fake.getCurrentSpaceMutex.Lock()
fake.getCurrentSpaceArgsForCall = append(fake.getCurrentSpaceArgsForCall, struct{}{})
fake.getCurrentSpaceMutex.Unlock()
Expand All @@ -308,10 +308,10 @@ func (fake *FakeCliConnection) GetCurrentSpaceCallCount() int {
return len(fake.getCurrentSpaceArgsForCall)
}

func (fake *FakeCliConnection) GetCurrentSpaceReturns(result1 plugin_models.SpaceSummary, result2 error) {
func (fake *FakeCliConnection) GetCurrentSpaceReturns(result1 plugin_models.Space, result2 error) {
fake.GetCurrentSpaceStub = nil
fake.getCurrentSpaceReturns = struct {
result1 plugin_models.SpaceSummary
result1 plugin_models.Space
result2 error
}{result1, result2}
}
Expand Down Expand Up @@ -724,7 +724,7 @@ func (fake *FakeCliConnection) GetOrgsReturns(result1 []plugin_models.Organizati
}{result1, result2}
}

func (fake *FakeCliConnection) GetSpaces() ([]plugin_models.Space, error) {
func (fake *FakeCliConnection) GetSpaces() ([]plugin_models.SpaceSummary, error) {
fake.getSpacesMutex.Lock()
fake.getSpacesArgsForCall = append(fake.getSpacesArgsForCall, struct{}{})
fake.getSpacesMutex.Unlock()
Expand All @@ -741,10 +741,10 @@ func (fake *FakeCliConnection) GetSpacesCallCount() int {
return len(fake.getSpacesArgsForCall)
}

func (fake *FakeCliConnection) GetSpacesReturns(result1 []plugin_models.Space, result2 error) {
func (fake *FakeCliConnection) GetSpacesReturns(result1 []plugin_models.SpaceSummary, result2 error) {
fake.GetSpacesStub = nil
fake.getSpacesReturns = struct {
result1 []plugin_models.Space
result1 []plugin_models.SpaceSummary
result2 error
}{result1, result2}
}
Expand Down Expand Up @@ -842,7 +842,7 @@ func (fake *FakeCliConnection) GetServicesReturns(result1 []plugin_models.Servic
}{result1, result2}
}

func (fake *FakeCliConnection) GetOrg(arg1 string) (plugin_models.Organization, error) {
func (fake *FakeCliConnection) GetOrg(arg1 string) (plugin_models.OrganizationDetails, error) {
fake.getOrgMutex.Lock()
fake.getOrgArgsForCall = append(fake.getOrgArgsForCall, struct {
arg1 string
Expand All @@ -867,10 +867,10 @@ func (fake *FakeCliConnection) GetOrgArgsForCall(i int) string {
return fake.getOrgArgsForCall[i].arg1
}

func (fake *FakeCliConnection) GetOrgReturns(result1 plugin_models.Organization, result2 error) {
func (fake *FakeCliConnection) GetOrgReturns(result1 plugin_models.OrganizationDetails, result2 error) {
fake.GetOrgStub = nil
fake.getOrgReturns = struct {
result1 plugin_models.Organization
result1 plugin_models.OrganizationDetails
result2 error
}{result1, result2}
}
Expand Down
9 changes: 5 additions & 4 deletions plugin/models/organization.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package plugin_models

type Organization struct {
type OrganizationFields struct {
Guid string
Name string
QuotaDefinition QuotaFields
Spaces []SpaceFields
Domains []DomainFields
SpaceQuotas []SpaceQuotaFields
}

type Organization struct {
OrganizationFields
}
10 changes: 10 additions & 0 deletions plugin/models/organization_details.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package plugin_models

type OrganizationDetails struct {
Guid string
Name string
QuotaDefinition QuotaFields
Spaces []SpaceFields
Domains []DomainFields
SpaceQuotas []SpaceQuotaFields
}
6 changes: 0 additions & 6 deletions plugin/models/space.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,4 @@ type SpaceFields struct {

type Space struct {
SpaceFields
Organization OrganizationSummary
Applications []ApplicationSummary
//ServiceInstances []ServiceInstances
Domains []DomainFields
SecurityGroups []SecurityGroupFields
SpaceQuotaGuid string
}
11 changes: 11 additions & 0 deletions plugin/models/space_details.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package plugin_models

type SpaceDetails struct {
SpaceFields
Organization OrganizationSummary
Applications []ApplicationSummary
//ServiceInstances []ServiceInstances
Domains []DomainFields
SecurityGroups []SecurityGroupFields
SpaceQuotaGuid string
}
8 changes: 4 additions & 4 deletions plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ type Plugin interface {
type CliConnection interface {
CliCommandWithoutTerminalOutput(args ...string) ([]string, error)
CliCommand(args ...string) ([]string, error)
GetCurrentOrg() (plugin_models.OrganizationSummary, error)
GetCurrentSpace() (plugin_models.SpaceSummary, error)
GetCurrentOrg() (plugin_models.Organization, error)
GetCurrentSpace() (plugin_models.Space, error)
Username() (string, error)
UserGuid() (string, error)
UserEmail() (string, error)
Expand All @@ -34,11 +34,11 @@ type CliConnection interface {
GetApp(string) (plugin_models.Application, error)
GetApps() ([]plugin_models.ApplicationSummary, error)
GetOrgs() ([]plugin_models.OrganizationSummary, error)
GetSpaces() ([]plugin_models.Space, error)
GetSpaces() ([]plugin_models.SpaceSummary, error)
GetOrgUsers(string, ...string) ([]plugin_models.User, error)
GetSpaceUsers(string, string) ([]plugin_models.User, error)
GetServices() ([]plugin_models.ServiceInstance, error)
GetOrg(string) (plugin_models.Organization, error)
GetOrg(string) (plugin_models.OrganizationDetails, error)
}

type VersionType struct {
Expand Down
13 changes: 10 additions & 3 deletions plugin/rpc/cli_rpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,21 @@ func (cmd *CliRpcCmd) GetOutputAndReset(args bool, retVal *[]string) error {
return nil
}

func (cmd *CliRpcCmd) GetCurrentOrg(args string, retVal *plugin_models.OrganizationSummary) error {
func (cmd *CliRpcCmd) GetCurrentOrg(args string, retVal *plugin_models.Organization) error {
retVal.Name = cmd.cliConfig.OrganizationFields().Name
retVal.Guid = cmd.cliConfig.OrganizationFields().Guid
retVal.QuotaDefinition.Guid = cmd.cliConfig.OrganizationFields().QuotaDefinition.Guid
retVal.QuotaDefinition.Name = cmd.cliConfig.OrganizationFields().QuotaDefinition.Name
retVal.QuotaDefinition.MemoryLimit = cmd.cliConfig.OrganizationFields().QuotaDefinition.MemoryLimit
retVal.QuotaDefinition.InstanceMemoryLimit = cmd.cliConfig.OrganizationFields().QuotaDefinition.InstanceMemoryLimit
retVal.QuotaDefinition.RoutesLimit = cmd.cliConfig.OrganizationFields().QuotaDefinition.RoutesLimit
retVal.QuotaDefinition.ServicesLimit = cmd.cliConfig.OrganizationFields().QuotaDefinition.ServicesLimit
retVal.QuotaDefinition.NonBasicServicesAllowed = cmd.cliConfig.OrganizationFields().QuotaDefinition.NonBasicServicesAllowed

return nil
}

func (cmd *CliRpcCmd) GetCurrentSpace(args string, retVal *plugin_models.SpaceSummary) error {
func (cmd *CliRpcCmd) GetCurrentSpace(args string, retVal *plugin_models.Space) error {
retVal.Name = cmd.cliConfig.SpaceFields().Name
retVal.Guid = cmd.cliConfig.SpaceFields().Guid

Expand Down Expand Up @@ -368,7 +375,7 @@ func (cmd *CliRpcCmd) GetSpaceUsers(args []string, retVal *[]plugin_models.User)
return cmd.newCmdRunner.Command(append([]string{"space-users"}, args...), deps, true)
}

func (cmd *CliRpcCmd) GetOrg(orgName string, retVal *plugin_models.Organization) error {
func (cmd *CliRpcCmd) GetOrg(orgName string, retVal *plugin_models.OrganizationDetails) error {
defer func() {
recover()
}()
Expand Down
Loading

0 comments on commit 271069d

Please sign in to comment.