diff --git a/cmd/local.go b/cmd/local.go index a319bd9e8..75b6e0d1d 100644 --- a/cmd/local.go +++ b/cmd/local.go @@ -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", diff --git a/internal/local/service.go b/internal/local/service.go new file mode 100644 index 000000000..0608ff13f --- /dev/null +++ b/internal/local/service.go @@ -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() +}