cmd

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2018 License: NCSA Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "rai-keygen",
	Short: "Generates profiles to be used with the rai client",
	Long: "Generates a profile file that needs to be placed in `~/.rai_profile` (linux/OSX) or " +
		"`%USERPROFILE%/.rai_profile` (Windows -- for me this is `C:\\Users\\abduld\\.rai_profile`). " +
		"The rai client reads these configuration files to authenticate the user. " +
		"A seed (specified by `secret`) is used to generate secure credentials",
	SilenceUsage:  true,
	SilenceErrors: true,
	PreRunE: func(cmd *cobra.Command, args []string) error {
		if username == "" {
			return errors.New("empty username")
		}
		if email == "" {
			return errors.New("empty email")
		}
		if roleString == "" {
			return errors.New("empty role")
		}
		role = acl.Role(roleString)
		if !role.Validate() {
			return errors.Errorf("The role %s is not valid. Valid roles are %v", role, acl.Roles)
		}
		return nil
	},
	RunE: func(cmd *cobra.Command, args []string) error {
		prof, err := provider.New(
			auth.Username(username),
			auth.Email(email),
			auth.Firstname(firstname),
			auth.Lastname(lastname),
			auth.TeamName(teamname),
			auth.Role(role),
		)
		if err != nil {
			return err
		}

		if err := prof.Create(); err != nil {
			return err
		}

		fmt.Print(prof.Info().String())

		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
⌂ 换网址