Ai
1 Star 0 Fork 0

ryancartoon/sensu-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
logout.go 909 Bytes
一键复制 编辑 原始数据 按行查看 历史
Simon Plourde 提交于 2019-05-31 02:05 +08:00 . Fix sensuctl logout message (#3009)
package logout
import (
"errors"
"fmt"
"github.com/sensu/sensu-go/cli"
"github.com/sensu/sensu-go/types"
"github.com/spf13/cobra"
)
// Command defines new configuration command
func Command(cli *cli.SensuCli) *cobra.Command {
return &cobra.Command{
Use: "logout",
Short: "Logout from sensuctl",
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 0 {
_ = cmd.Help()
return errors.New("invalid argument(s) received")
}
// Logout from the configured Sensu instance
tokens := cli.Config.Tokens()
if err := cli.Client.Logout(tokens.Refresh); err != nil {
return err
}
// Remove the configured tokens from the local configuration file
if err := cli.Config.SaveTokens(&types.Tokens{}); err != nil {
return err
}
fmt.Fprintln(cmd.OutOrStdout(), "You have been logged out")
return nil
},
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ryancartoon/sensu-go.git
git@gitee.com:ryancartoon/sensu-go.git
ryancartoon
sensu-go
sensu-go
v5.10.1

搜索帮助