cmd

package
v0.0.1-alpha.9 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:               "pimctl",
	Short:             "CLI to manage Azure PIM roles and assignments",
	Long:              "A CLI tool to manage Azure Privileged Identity Management (PIM) roles and assignments",
	Version:           fmt.Sprintf("%s (%s)", build.Version, build.Date),
	DisableAutoGenTag: true,
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
		command := getCommand(cmd.CommandPath())
		switch {
		case slices.Contains([]string{"login", "account clear", "account show", "account token"}, command):
			return nil
		case strings.HasPrefix(command, "help"):
			return nil
		case strings.HasPrefix(command, "completion"):
			return nil
		case strings.HasPrefix(command, "group"):
			if !isLoggedInMSGraph(cmd.Context()) {
				return fmt.Errorf("not logged in, run 'login' to continue")
			}
		case strings.Contains(command, "role entra"):
			if !isLoggedInMSGraph(cmd.Context()) {
				return fmt.Errorf("not logged in, run 'login' to continue")
			}
		case strings.Contains(command, "role azure"):
			if !isLoggedInARM(cmd.Context()) {
				return fmt.Errorf("not logged in, run 'login' to continue")
			}
		default:
			return fmt.Errorf("unknown command: %s", command)
		}

		return nil
	},
}

Functions

func Execute

func Execute()

Types

This section is empty.

Jump to

Keyboard shortcuts

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