Skip to content

Commit

Permalink
chore: add service csb command
Browse files Browse the repository at this point in the history
  • Loading branch information
pivotal-marcela-campo committed Nov 9, 2023
1 parent 101d24f commit 55e41e4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ func init() {
}
rootCmd.AddCommand(servicesCmd)

serviceCmd := &cobra.Command{
Use: "service",
Short: "EXPERIMENTAL AND SUBJECT TO BREAKING CHANGE: provides information on a service instance",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
local.Service(args[0], viper.GetString(pakCachePath))
},
}
rootCmd.AddCommand(serviceCmd)

const planFlag = "p"
updateServiceCmd := &cobra.Command{
Use: "update-service NAME",
Expand Down
44 changes: 44 additions & 0 deletions internal/local/service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package local

import (
"fmt"
"log"
)

func Service(name, cachePath string) {
instance, err := store().GetServiceInstanceDetails(nameToID(name))
if err != nil {
log.Fatal(err)
}

pakDir, cleanup := pack(cachePath)
defer cleanup()

broker := startBroker(pakDir)
defer broker.Stop()

lastOperationFinalValue, _ := broker.LastOperationFinalValue(instance.GUID)

tp := newTablePrinter("")
serviceName, planName := lookupServiceNamesByID(broker.Client, instance.ServiceGUID, instance.PlanGUID)
tp.row("name:", name)
tp.row("guid:", instance.GUID)
tp.row("offering:", serviceName)

tp.row("plan:", planName)
tp.row("")
tp.row("Showing status of last operation:")
tp.row("status:", string(lastOperationFinalValue.State))
tp.row("message:", lastOperationFinalValue.Description)

tp.row("")
tp.row("Showing bindings: not implemented")

deployment, _ := store().GetTerraformDeployment(fmt.Sprintf("tf:%s:", instance.GUID))
tfVersion, _ := deployment.TFWorkspace().StateTFVersion()

tp.row("")
tp.row("Showing upgrade status: Terraform version in state is ", tfVersion.String())

tp.print()
}

0 comments on commit 55e41e4

Please sign in to comment.