mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
*: 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:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user