2022-11-23 14:20:03 +00:00
|
|
|
package debug
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/databricks/bricks/bundle"
|
2023-01-27 16:05:57 +00:00
|
|
|
"github.com/databricks/bricks/cmd/root"
|
2022-11-23 14:20:03 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var whoamiCmd = &cobra.Command{
|
|
|
|
Use: "whoami",
|
|
|
|
|
2023-01-27 16:05:57 +00:00
|
|
|
PreRunE: root.MustConfigureBundle,
|
2022-11-23 14:20:03 +00:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
ctx := cmd.Context()
|
|
|
|
w := bundle.Get(ctx).WorkspaceClient()
|
|
|
|
user, err := w.CurrentUser.Me(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Fprintln(cmd.OutOrStdout(), user.UserName)
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
debugCmd.AddCommand(whoamiCmd)
|
|
|
|
}
|