user

package
v0.0.0-...-2f4df1c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WhoamiCmd = &cobra.Command{
	Use:   "whoami",
	Short: "Print information about the auth token",
	Run: func(cmd *cobra.Command, args []string) {
		client, err := egapi.NewClient(config.C.AuthURI)
		if err != nil {
			fmt.Fprintln(os.Stderr, "error preparing API client: ", err)
			os.Exit(1)
		}

		iam, err := egiam.NewClient(client)
		if err != nil {
			fmt.Fprintln(os.Stderr, "error preparing API client: ", err)
			os.Exit(1)
		}

		whoami, err := iam.WhoamiWithResponse(cmd.Context())
		if err != nil {
			fmt.Fprintln(os.Stderr, "error making whoami API request: ", err)
			os.Exit(1)
		}

		if whoami.JSON200 == nil {
			fmt.Fprintln(os.Stderr, "unexpected response from server: ", string(whoami.Body))
			return
		}

		err = json.NewEncoder(os.Stdout).Encode(whoami.JSON200)
		if err != nil {
			fmt.Fprintln(os.Stderr, "error encoding response to json: ", err)
			os.Exit(1)
		}
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL