From 28d7aeb27ea3818cc446a7abe193d567682861d9 Mon Sep 17 00:00:00 2001 From: Marcela Campo Date: Thu, 9 Nov 2023 13:13:19 +0000 Subject: [PATCH] chore(csb): csb update command supports upgrades enabled (#899) * 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 --------- Co-authored-by: Andrea Zucchini --- README.md | 4 +++- internal/local/update_service.go | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 19749b908..fb7409407 100755 --- a/README.md +++ b/README.md @@ -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 diff --git a/internal/local/update_service.go b/internal/local/update_service.go index 3ae0b4a8d..166b02e4d 100644 --- a/internal/local/update_service.go +++ b/internal/local/update_service.go @@ -1,8 +1,11 @@ package local import ( + "fmt" "log" + "github.com/pivotal-cf/brokerapi/v10/domain" + "github.com/cloudfoundry/cloud-service-broker/internal/testdrive" ) @@ -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))