user

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const UserHelpExample = `` /* 189-byte string literal not displayed */

Variables

View Source
var UserCmd = &cobra.Command{
	Use:     "user",
	Short:   "User manage of tenant.",
	Example: UserHelpExample,
	Run: func(cmd *cobra.Command, args []string) {
		cmd.Help()
	},
}
View Source
var UserCreateCmd = &cobra.Command{
	Use:   "create",
	Short: "Create new user.",
	Example: `
# Create user with username and password
tkeel user create <username> <password> -t <tenant-id>
`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) != 2 {
			print.WarningStatusEvent(os.Stdout, "Please specify the username and password")
			print.WarningStatusEvent(os.Stdout, "For example, tkeel user create <username> <password> -t <tenant-id>")
			os.Exit(1)
		}
		username := args[0]
		password := args[1]

		err := kubernetes.TenantUserCreate(tenant, username, password)
		if err != nil {
			print.FailureStatusEvent(os.Stdout, err.Error())
			os.Exit(1)
		}
		print.SuccessStatusEvent(os.Stdout, "Success! ")
	},
}
View Source
var UserDeleteCmd = &cobra.Command{
	Use:   "delete",
	Short: "Delete user in tenant.",
	Example: `
# Delete the user of tenant by user id
tkeel user delete <user-id> -t <tenant-id>
`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) != 1 {
			print.WarningStatusEvent(os.Stdout, "Please specify the user id")
			print.WarningStatusEvent(os.Stdout, "For example, tkeel user delete <user-id> -t <tenant-id>")
			os.Exit(1)
		}
		userID := args[0]
		err := kubernetes.TenantUserDelete(tenant, userID)
		if err != nil {
			print.FailureStatusEvent(os.Stdout, err.Error())
			os.Exit(1)
		}
		print.SuccessStatusEvent(os.Stdout, "Successfully delete!")
	},
}
View Source
var UserInfoCmd = &cobra.Command{
	Use:   "show",
	Short: "Show user info.",
	Example: `
# Show user info by user id
tkeel user show <user-id> -t <tenant-id>

`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) != 2 {
			print.WarningStatusEvent(os.Stdout, "Please specify the user id")
			print.WarningStatusEvent(os.Stdout, "For example, tkeel user show <user-id> -t <tenant-id>")
			os.Exit(1)
		}
		userID := args[0]
		data, err := kubernetes.TenantUserInfo(tenant, userID)
		if err != nil {
			print.FailureStatusEvent(os.Stdout, err.Error())
			os.Exit(1)
		}
		table, err := gocsv.MarshalString(data)
		if err != nil {
			print.FailureStatusEvent(os.Stdout, err.Error())
			os.Exit(1)
		}
		fmtutil.PrintTable(table)
	},
}
View Source
var UserListCmd = &cobra.Command{
	Use:   "list",
	Short: "List user in tenant.",
	Example: `
# List user info of tenant
tkeel user list -t <tenant-id>
`,
	Run: func(cmd *cobra.Command, args []string) {
		data, err := kubernetes.TenantUserList(tenant)
		if err != nil {
			print.FailureStatusEvent(os.Stdout, err.Error())
			os.Exit(1)
		}
		table, err := gocsv.MarshalString(data)
		if err != nil {
			print.FailureStatusEvent(os.Stdout, err.Error())
			os.Exit(1)
		}
		fmtutil.PrintTable(table)

	},
}

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