diff --git a/README.md b/README.md index fb7409407..bb975f483 100755 --- a/README.md +++ b/README.md @@ -86,6 +86,7 @@ The mimic commands are: - `csb delete-service` - deletes a service instance - `csb create-service-key` - creates a "binding" and prints credentials - `csb service-keys` - lists service keys +- `csb service-key` - prints a service key - `csb delete-service-key` - deletes a "binding" The mimic commands build a brokerpak, start an ephemeral CSB server and send OSBAPI diff --git a/cmd/local.go b/cmd/local.go index 75b6e0d1d..f239daae0 100644 --- a/cmd/local.go +++ b/cmd/local.go @@ -89,7 +89,7 @@ func init() { createServiceKeyCmd := &cobra.Command{ Use: "create-service-key SERVICE_INSTANCE SERVICE_KEY", - Short: "EXPERIMENTAL AND SUBJECT TO BREAKING CHANGE: create a service instance", + Short: "EXPERIMENTAL AND SUBJECT TO BREAKING CHANGE: create a service key", Args: cobra.ExactArgs(2), Run: func(cmd *cobra.Command, args []string) { local.CreateServiceKey(args[0], args[1], params, viper.GetString(pakCachePath)) @@ -98,6 +98,16 @@ func init() { createServiceKeyCmd.Flags().StringVarP(¶ms, paramsFlag, paramsFlag, "", "parameters as JSON") rootCmd.AddCommand(createServiceKeyCmd) + serviceKeyCmd := &cobra.Command{ + Use: "service-key SERVICE_INSTANCE SERVICE_KEY", + Short: "EXPERIMENTAL AND SUBJECT TO BREAKING CHANGE: print a service key", + Args: cobra.ExactArgs(2), + Run: func(cmd *cobra.Command, args []string) { + local.ServiceKey(args[0], args[1]) + }, + } + rootCmd.AddCommand(serviceKeyCmd) + serviceKeysCmd := &cobra.Command{ Use: "service-keys NAME", Short: "EXPERIMENTAL AND SUBJECT TO BREAKING CHANGE: list service keys for a service instance", diff --git a/internal/local/catalog.go b/internal/local/catalog.go index 31ce6b16c..a86671eff 100644 --- a/internal/local/catalog.go +++ b/internal/local/catalog.go @@ -77,6 +77,9 @@ func lookupPlanMaintenanceInfoByGUID(clnt *client.Client, serviceID, planGUID st if s.ID == serviceID { for _, p := range s.Plans { if p.ID == planGUID { + if p.MaintenanceInfo == nil { + return domain.MaintenanceInfo{} + } return *p.MaintenanceInfo } } diff --git a/internal/local/service.go b/internal/local/service.go index 0608ff13f..7c670871d 100644 --- a/internal/local/service.go +++ b/internal/local/service.go @@ -38,7 +38,9 @@ func Service(name, cachePath string) { tfVersion, _ := deployment.TFWorkspace().StateTFVersion() tp.row("") - tp.row("Showing upgrade status: Terraform version in state is ", tfVersion.String()) - + tp.row("Showing upgrade status:") + tp.row("Terraform version in state is ", tfVersion.String()) + mInfo := lookupPlanMaintenanceInfoByGUID(broker.Client, instance.ServiceGUID, instance.PlanGUID) + tp.row("Plan version is ", mInfo.Version) tp.print() } diff --git a/internal/local/service_key.go b/internal/local/service_key.go new file mode 100644 index 000000000..6eff46b30 --- /dev/null +++ b/internal/local/service_key.go @@ -0,0 +1,16 @@ +package local + +import ( + "encoding/json" + "fmt" + "log" +) + +func ServiceKey(serviceInstanceName, serviceKeyName string) { + credentials, err := store().GetServiceBindingCredentials(nameToID(serviceKeyName), nameToID(serviceInstanceName)) + if err != nil { + log.Fatal(err) + } + bytes, _ := json.Marshal(credentials.Credentials) + fmt.Printf("\nService Key: %s\n", bytes) +}