Skip to content

Commit

Permalink
[SVCMGR-510] Adjust broker names when they are overtaken from SM (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzahariev authored May 9, 2019
1 parent 1752c94 commit 33981ad
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions pkg/sbproxy/reconcile/reconcile_brokers.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (r *ReconciliationTask) createBrokerRegistration(broker *platform.ServiceBr
logger.WithFields(logBroker(broker)).Info("ReconciliationTask task attempting to create proxy for broker in platform...")

createRequest := &platform.CreateServiceBrokerRequest{
Name: r.options.BrokerPrefix + broker.GUID,
Name: r.options.BrokerPrefix + broker.Name,
BrokerURL: r.proxyPath + "/" + broker.GUID,
}

Expand All @@ -160,7 +160,7 @@ func (r *ReconciliationTask) updateBrokerRegistration(brokerGUID string, broker

updateRequest := &platform.UpdateServiceBrokerRequest{
GUID: brokerGUID,
Name: r.options.BrokerPrefix + broker.GUID,
Name: r.options.BrokerPrefix + broker.Name,
BrokerURL: r.proxyPath + "/" + broker.GUID,
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/sbproxy/reconcile/reconcile_brokers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@ var _ = Describe("Reconcile brokers", func() {

platformbroker1 = platform.ServiceBroker{
GUID: "platformBrokerID1",
Name: brokerPrefix + "smBrokerID1",
Name: brokerPrefix + "smBroker1",
BrokerURL: fakeAppHost + "/" + smbroker1.ID,
}

platformbroker2 = platform.ServiceBroker{
GUID: "platformBrokerID2",
Name: brokerPrefix + "smBrokerID2",
Name: brokerPrefix + "smBroker2",
BrokerURL: fakeAppHost + "/" + smbroker2.ID,
}

Expand All @@ -205,7 +205,7 @@ var _ = Describe("Reconcile brokers", func() {

platformBrokerProxy = platform.ServiceBroker{
GUID: platformbrokerNonProxy.GUID,
Name: "sm-proxy-" + smbroker3.ID,
Name: "sm-proxy-" + smbroker3.Name,
BrokerURL: fakeAppHost + "/" + smbroker3.ID,
}
})
Expand Down
10 changes: 5 additions & 5 deletions pkg/sbproxy/reconcile/reconcile_visibilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (r *ReconciliationTask) getPlatformVisibilitiesByBrokersFromPlatform(broker
func (r *ReconciliationTask) brokerNames(brokers []platform.ServiceBroker) []string {
names := make([]string, 0, len(brokers))
for _, broker := range brokers {
names = append(names, r.options.BrokerPrefix+broker.GUID)
names = append(names, r.options.BrokerPrefix+broker.Name)
}
return names
}
Expand Down Expand Up @@ -253,7 +253,7 @@ func (r *ReconciliationTask) getSMVisibilities(smPlansMap map[brokerPlanKey]*typ
if !found {
continue
}
converted := r.convertSMVisibility(visibility, smPlan, broker.GUID)
converted := r.convertSMVisibility(visibility, smPlan, broker.Name)
result = append(result, converted...)
}
}
Expand All @@ -262,15 +262,15 @@ func (r *ReconciliationTask) getSMVisibilities(smPlansMap map[brokerPlanKey]*typ
return result, nil
}

func (r *ReconciliationTask) convertSMVisibility(visibility *types.Visibility, smPlan *types.ServicePlan, brokerGUID string) []*platform.ServiceVisibilityEntity {
func (r *ReconciliationTask) convertSMVisibility(visibility *types.Visibility, smPlan *types.ServicePlan, brokerNAME string) []*platform.ServiceVisibilityEntity {
scopeLabelKey := r.platformClient.Visibility().VisibilityScopeLabelKey()

if visibility.PlatformID == "" || scopeLabelKey == "" {
return []*platform.ServiceVisibilityEntity{
{
Public: true,
CatalogPlanID: smPlan.CatalogID,
PlatformBrokerName: r.options.BrokerPrefix + brokerGUID,
PlatformBrokerName: r.options.BrokerPrefix + brokerNAME,
Labels: map[string]string{},
},
}
Expand All @@ -282,7 +282,7 @@ func (r *ReconciliationTask) convertSMVisibility(visibility *types.Visibility, s
result = append(result, &platform.ServiceVisibilityEntity{
Public: false,
CatalogPlanID: smPlan.CatalogID,
PlatformBrokerName: r.options.BrokerPrefix + brokerGUID,
PlatformBrokerName: r.options.BrokerPrefix + brokerNAME,
Labels: map[string]string{scopeLabelKey: scope},
})
}
Expand Down
48 changes: 24 additions & 24 deletions pkg/sbproxy/reconcile/reconcile_visibilities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,13 @@ var _ = Describe("Reconcile visibilities", func() {

platformbroker1 = platform.ServiceBroker{
GUID: "platformBrokerID1",
Name: brokerPrefix + "smBrokerID1",
Name: brokerPrefix + "smBroker1",
BrokerURL: fakeAppHost + "/" + smbroker1.ID,
}

platformbroker2 = platform.ServiceBroker{
GUID: "platformBrokerID2",
Name: brokerPrefix + "smBrokerID2",
Name: brokerPrefix + "smBroker2",
BrokerURL: fakeAppHost + "/" + smbroker2.ID,
}

Expand Down Expand Up @@ -345,12 +345,12 @@ var _ = Describe("Reconcile visibilities", func() {
return expectations{
enablePlanVisibilityCalledFor: []*platform.ServiceVisibilityEntity{
{
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[0].CatalogID,
Labels: map[string]string{"key": "value0"},
},
{
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[0].CatalogID,
Labels: map[string]string{"key": "value1"},
},
Expand All @@ -366,12 +366,12 @@ var _ = Describe("Reconcile visibilities", func() {
{
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[0].CatalogID,
Labels: map[string]string{"key": "value0"},
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
{
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[0].CatalogID,
Labels: map[string]string{"key": "value1"},
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
}, nil
},
Expand Down Expand Up @@ -403,12 +403,12 @@ var _ = Describe("Reconcile visibilities", func() {
{
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[0].CatalogID,
Labels: map[string]string{"key": "value2"},
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
{
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[0].CatalogID,
Labels: map[string]string{"key": "value3"},
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
}, nil
},
Expand All @@ -432,24 +432,24 @@ var _ = Describe("Reconcile visibilities", func() {
{
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[0].CatalogID,
Labels: map[string]string{"key": "value0"},
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
{
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[0].CatalogID,
Labels: map[string]string{"key": "value1"},
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
},
disablePlanVisibilityCalledFor: []*platform.ServiceVisibilityEntity{
{
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[0].CatalogID,
Labels: map[string]string{"key": "value2"},
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
{
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[0].CatalogID,
Labels: map[string]string{"key": "value3"},
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
},
}
Expand Down Expand Up @@ -492,12 +492,12 @@ var _ = Describe("Reconcile visibilities", func() {
{
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[0].CatalogID,
Labels: map[string]string{"key": "value0"},
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
{
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[1].CatalogID,
Labels: map[string]string{"key": "value1"},
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
},
}
Expand All @@ -513,12 +513,12 @@ var _ = Describe("Reconcile visibilities", func() {
{
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[0].CatalogID,
Labels: map[string]string{"key": "value0"},
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
{
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[1].CatalogID,
Labels: map[string]string{"key": "value1"},
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
}, nil
},
Expand All @@ -532,12 +532,12 @@ var _ = Describe("Reconcile visibilities", func() {
{
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[0].CatalogID,
Labels: map[string]string{"key": "value0"},
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
{
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[1].CatalogID,
Labels: map[string]string{"key": "value1"},
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
},
}
Expand Down Expand Up @@ -595,7 +595,7 @@ var _ = Describe("Reconcile visibilities", func() {
Public: true,
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[0].CatalogID,
Labels: map[string]string{},
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
},
}
Expand All @@ -608,7 +608,7 @@ var _ = Describe("Reconcile visibilities", func() {
{
Public: true,
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[1].CatalogID,
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
}, nil
},
Expand All @@ -627,15 +627,15 @@ var _ = Describe("Reconcile visibilities", func() {
Public: true,
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[0].CatalogID,
Labels: map[string]string{},
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
},
disablePlanVisibilityCalledFor: []*platform.ServiceVisibilityEntity{
{
Public: true,
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[1].CatalogID,
Labels: map[string]string{},
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
},
}
Expand All @@ -648,7 +648,7 @@ var _ = Describe("Reconcile visibilities", func() {
{
Public: true,
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[1].CatalogID,
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
}, nil
},
Expand All @@ -672,7 +672,7 @@ var _ = Describe("Reconcile visibilities", func() {
{
Public: true,
CatalogPlanID: smbroker1.ServiceOfferings[0].Plans[1].CatalogID,
PlatformBrokerName: brokerPrefix + smbroker1.ID,
PlatformBrokerName: brokerPrefix + smbroker1.Name,
},
}, nil
},
Expand Down

0 comments on commit 33981ad

Please sign in to comment.