Skip to content

Commit

Permalink
chore(csb): csb update command supports upgrades enabled (#899)
Browse files Browse the repository at this point in the history
* chore(csb): update command works when upgrades enabled

Command was failing when upgrades enabled as we were not passing
in maintenance info version.

* chore(docs): Add new csb commands to README

* chore: format code

* chore(csb): log errors if unable to find deployment on update command

Co-authored-by: Andrea Zucchini <[email protected]>

---------

Co-authored-by: Andrea Zucchini <[email protected]>
  • Loading branch information
pivotal-marcela-campo and zucchinidev authored Nov 9, 2023
1 parent 04e2c86 commit 28d7aeb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ By using the make target `make install` you can install the CSB as a local comma
The mimic commands are:
- `csb create-service` - creates a service instance
- `csb services` - lists created service instances
- `csb update-service` - updates a serivce instance
- `csb service` - displays information on an existing service instance
- `csb update-service` - updates a service instance
- `csb upgrade-service` - upgrades a service instance
- `csb delete-service` - deletes a service instance
- `csb create-service-key` - creates a "binding" and prints credentials
- `csb service-keys` - lists service keys
Expand Down
18 changes: 16 additions & 2 deletions internal/local/update_service.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package local

import (
"fmt"
"log"

"github.com/pivotal-cf/brokerapi/v10/domain"

"github.com/cloudfoundry/cloud-service-broker/internal/testdrive"
)

Expand All @@ -11,11 +14,22 @@ func UpdateService(name, plan, params, cachePath string) {
defer cleanup()

serviceInstance := lookupServiceInstanceByGUID(nameToID(name))

deployment, err := store().GetTerraformDeployment(fmt.Sprintf("tf:%s:", serviceInstance.GUID))
if err != nil {
log.Fatal(err)
}
tfVersion, err := deployment.TFWorkspace().StateTFVersion()
if err != nil {
log.Fatal(err)
}
broker := startBroker(pakDir)
defer broker.Stop()

opts := []testdrive.UpdateOption{testdrive.WithUpdateParams(params)}
opts := []testdrive.UpdateOption{
testdrive.WithUpdateParams(params),
testdrive.WithUpdatePreviousValues(domain.PreviousValues{MaintenanceInfo: &domain.MaintenanceInfo{Version: tfVersion.String()}}),
}

if plan != "" {
planID := lookupPlanIDByName(broker.Client, serviceInstance.ServiceOfferingGUID, plan)
opts = append(opts, testdrive.WithUpdatePlan(planID))
Expand Down

0 comments on commit 28d7aeb

Please sign in to comment.