src/server/auth/cmds/cmds.go
func WhoamiCmd(noMetrics, noPortForwarding *bool) *cobra.Command {
	whoami := &cobra.Command{
		Short: "Print your Pachyderm identity",
		Long:  "Print your Pachyderm identity.",
		Run: cmdutil.Run(func([]string) error {
			c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user")
			if err != nil {
				return fmt.Errorf("could not connect: %v", err)
			}
			defer c.Close()
			resp, err := c.WhoAmI(c.Ctx(), &auth.WhoAmIRequest{})
			if err != nil {
				return fmt.Errorf("error: %v", grpcutil.ScrubGRPC(err))
			}
			fmt.Printf("You are \"%s\"\n", resp.Username)
			if resp.TTL > 0 {
				fmt.Printf("session expires: %v\n", time.Now().Add(time.Duration(resp.TTL)*time.Second).Format(time.RFC822))
			}
			if resp.IsAdmin {
				fmt.Println("You are an administrator of this Pachyderm cluster")
			}
			return nil
		}),
	}
	return cmdutil.CreateAlias(whoami, "auth whoami")
}
func WhoamiCmd(noMetrics, noPortForwarding *bool) *cobra.Command {
	whoami := &cobra.Command{
		Short: "Print your Pachyderm identity",
		Long:  "Print your Pachyderm identity.",
		Run: cmdutil.Run(func([]string) error {
			c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user")
			if err != nil {
				return fmt.Errorf("could not connect: %v", err)
			}
			defer c.Close()
			resp, err := c.WhoAmI(c.Ctx(), &auth.WhoAmIRequest{})
			if err != nil {
				return fmt.Errorf("error: %v", grpcutil.ScrubGRPC(err))
			}
			fmt.Printf("You are \"%s\"\n", resp.Username)
			if resp.TTL > 0 {
				fmt.Printf("session expires: %v\n", time.Now().Add(time.Duration(resp.TTL)*time.Second).Format(time.RFC822))
			}
			if resp.IsAdmin {
				fmt.Println("You are an administrator of this Pachyderm cluster")
			}
			return nil
		}),
	}
	return cmdutil.CreateAlias(whoami, "auth whoami")
}
func WhoamiCmd ( noMetrics , noPortForwarding * bool ) * cobra . Command { whoami := & cobra . Command { Short : " " , Long : " " , Run : cmdutil . Run ( func ( [ ] string ) error { c , err := client . NewOnUserMachine ( ! * noMetrics , ! * noPortForwarding , " " ) if err != nil { return fmt . Errorf ( " " , err ) } defer c . Close ( ) resp , err := c . WhoAmI ( c . Ctx ( ) , & auth . WhoAmIRequest { } ) if err != nil { return fmt . Errorf ( " " , grpcutil . ScrubGRPC ( err ) ) } fmt . Printf ( " \" \" \n " , resp . Username ) if resp . TTL > 0 { fmt . Printf ( " \n " , time . Now ( ) . Add ( time . Duration ( resp . TTL ) * time . Second ) . Format ( time . RFC822 ) ) } if resp . IsAdmin { fmt . Println ( " " ) } return nil } ) , } return cmdutil . CreateAlias ( whoami , " " ) }
// WhoamiCmd returns a cobra.Command that deletes your local Pachyderm
// credential, logging you out of your cluster. Note that this is not necessary
// to do before logging in as another user, but is useful for testing.
WhoamiCmd returns a cobra . Command that deletes your local Pachyderm credential logging you out of your cluster . Note that this is not necessary to do before logging in as another user but is useful for testing .