2022-11-23 14:20:03 +00:00
|
|
|
package debug
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/databricks/bricks/bundle"
|
2023-05-15 09:34:05 +00:00
|
|
|
bundleCmd "github.com/databricks/bricks/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)
|
|
|
|
}
|