*: add a new API and command for checking auth status (#11536)

This changes have started at etcdctl under auth.go, and make changes to stub out everything down into the internal raft.  Made changes to the .proto files and regenerated them so that the local version would build successfully.
This commit is contained in:
Vern Burton
2020-02-05 21:27:42 -06:00
committed by GitHub
parent 74d5ba5777
commit 071e70cdc4
21 changed files with 1013 additions and 465 deletions

View File

@@ -30,10 +30,35 @@ func NewAuthCommand() *cobra.Command {
ac.AddCommand(newAuthEnableCommand())
ac.AddCommand(newAuthDisableCommand())
ac.AddCommand(newAuthStatusCommand())
return ac
}
func newAuthStatusCommand() *cobra.Command {
return &cobra.Command{
Use: "status",
Short: "Returns authentication status",
Run: authStatusCommandFunc,
}
}
// authStatusCommandFunc executes the "auth status" command.
func authStatusCommandFunc(cmd *cobra.Command, args []string) {
if len(args) != 0 {
ExitWithError(ExitBadArgs, fmt.Errorf("auth status command does not accept any arguments"))
}
ctx, cancel := commandCtx(cmd)
result, err := mustClientFromCmd(cmd).Auth.AuthStatus(ctx)
cancel()
if err != nil {
ExitWithError(ExitError, err)
}
fmt.Println("Authentication Status:", result.Enabled)
}
func newAuthEnableCommand() *cobra.Command {
return &cobra.Command{
Use: "enable",