2022-11-23 14:20:03 +00:00
|
|
|
package debug
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2023-05-16 16:35:39 +00:00
|
|
|
"github.com/databricks/cli/bundle"
|
|
|
|
bundleCmd "github.com/databricks/cli/cmd/bundle"
|
2022-11-23 14:20:03 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var whoamiCmd = &cobra.Command{
|
|
|
|
Use: "whoami",
|
|
|
|
|
2023-05-15 09:34:05 +00:00
|
|
|
PreRunE: bundleCmd.ConfigureBundleWithVariables,
|
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)
|
|
|
|
}
|