// CmdLogout logs a user out from a Docker registry.
//
// If no server is specified, the user will be logged out from the registry's index server.
//
// Usage: hyperctl logout [SERVER]
175184
func (cli *HyperClient) HyperCmdLogout(args ...string) error {
	var parser = gflag.NewParser(nil, gflag.Default)
	parser.Usage = "logout [SERVER]\n\nLog out from a Docker registry, if no server is\nspecified \"" + registry.IndexServer + "\" is the default."
	args, err := parser.ParseArgs(args)
	if err != nil {
		if !strings.Contains(err.Error(), "Usage") {
			return err
		} else {
			return nil
		}
	}
	serverAddress := registry.IndexServer
	if len(args) > 0 {
		serverAddress = args[0]
	}

	if _, ok := cli.configFile.AuthConfigs[serverAddress]; !ok {
		fmt.Fprintf(cli.out, "Not logged in to %s\n", serverAddress)
	} else {
		fmt.Fprintf(cli.out, "Remove login credentials for %s\n", serverAddress)
		delete(cli.configFile.AuthConfigs, serverAddress)

		if err := cli.configFile.Save(); err != nil {
			return fmt.Errorf("Failed to save docker config: %v", err)
		}
	}
	return nil
}
250586
func NewCmdLogin(fullName string, f kcmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
	o := NewLoginOptions(streams)
	cmds := &cobra.Command{
		Use:     "login [URL]",
		Short:   "Log in to a server",
		Long:    loginLong,
		Example: fmt.Sprintf(loginExample, fullName),
		Run: func(cmd *cobra.Command, args []string) {
			kcmdutil.CheckErr(o.Complete(f, cmd, args, fullName))
			kcmdutil.CheckErr(o.Validate(cmd, kcmdutil.GetFlagString(cmd, "server"), args))

			if err := o.Run(); kapierrors.IsUnauthorized(err) {
				fmt.Fprintln(streams.Out, "Login failed (401 Unauthorized)")
				fmt.Fprintln(streams.Out, "Verify you have provided correct credentials.")

				if err, isStatusErr := err.(*kapierrors.StatusError); isStatusErr {
					if details := err.Status().Details; details != nil {
						for _, cause := range details.Causes {
							fmt.Fprintln(streams.Out, cause.Message)
						}
					}
				}

				os.Exit(1)

			} else {
				kcmdutil.CheckErr(err)
			}
		},
	}

	// Login is the only command that can negotiate a session token against the auth server using basic auth
	cmds.Flags().StringVarP(&o.Username, "username", "u", o.Username, "Username, will prompt if not provided")
	cmds.Flags().StringVarP(&o.Password, "password", "p", o.Password, "Password, will prompt if not provided")

	return cmds
}
441378
func (cli *Client) BackupctlGet(appname string) (*pb.BackupctlReply, error) {
	req := &pb.BackupctlRequest{Appname: appname}
	ctx, cancel := context.WithTimeout(context.Background(), cli.timeout)
	defer cancel()
	rpl, err := cli.backupctlClient.Get(ctx, req)
	return rpl, err
}
107863
func (inst *Instagram) Logout() error {
	_, err := inst.sendSimpleRequest(urlLogout)
	inst.c.Jar = nil
	inst.c = nil
	return err
}
119242
func (d *domainClient) SnapshotCommandLog(ctx context.Context, args *SnapshotCommandLogArgs) (reply *SnapshotCommandLogReply, err error) {
	reply = new(SnapshotCommandLogReply)
	if args != nil {
		err = rpcc.Invoke(ctx, "LayerTree.snapshotCommandLog", args, reply, d.conn)
	} else {
		err = rpcc.Invoke(ctx, "LayerTree.snapshotCommandLog", nil, reply, d.conn)
	}
	if err != nil {
		err = &internal.OpError{Domain: "LayerTree", Op: "SnapshotCommandLog", Err: err}
	}
	return
}
445730
func (cli *HyperClient) HyperCmdRun(args ...string) error {
	var (
		parser *gflag.Parser
		opts   = &RunFlags{}
		err    error
	)
	parser = gflag.NewParser(opts, gflag.Default|gflag.IgnoreUnknown|gflag.PassAfterNonOption)
	parser.Usage = "run [OPTIONS] IMAGE [COMMAND] [ARG...]\n\nCreate and start a pod"
	args, err = parser.ParseArgs(args)
	if err != nil {
		if !strings.Contains(err.Error(), "Usage") {
			return err
		} else {
			return nil
		}
	}

	specjson, err := cli.ParseCommonOptions(&opts.CommonFlags, false, args...)
	if err != nil {
		return err
	}

	var (
		podId  string
		spec   apitype.UserPod
		code   int
		attach = opts.Attach
		tty    = false
		res    chan error
	)

	t1 := time.Now()

	err = json.Unmarshal([]byte(specjson), &spec)
	if err != nil {
		return err
	}

	podId, code, err = cli.client.CreatePod(&spec)
	if err != nil {
		if code == http.StatusNotFound {
			err = cli.PullImages(&spec)
			if err != nil {
				return err
			}
			podId, code, err = cli.client.CreatePod(&spec)
		}
		if err != nil {
			return err
		}
	}
	if opts.PodFile == "" {
		attach = !opts.Detach
	}
	if !attach {
		fmt.Printf("POD id is %s\n", podId)
	}

	if opts.Remove {
		defer func() {
			rmerr := cli.client.RmPod(podId)
			if rmerr != nil {
				fmt.Fprintf(cli.out, "failed to rm pod, %v\n", rmerr)
			}
		}()
	}

	if attach && len(spec.Containers) > 0 {
		res = make(chan error, 1)
		tty = spec.Tty || spec.Containers[0].Tty
		p, err := cli.client.GetPodInfo(podId)
		if err != nil {
			fmt.Fprintf(cli.err, "failed to get pod info: %v", err)
			return err
		}
		if tty {
			cli.monitorTtySize(p.Spec.Containers[0].ContainerID, "")
			oldState, err := term.SetRawTerminal(cli.inFd)
			if err != nil {
				return err
			}
			defer term.RestoreTerminal(cli.inFd, oldState)
		}
		cname := spec.Containers[0].Name

		go func() {
			res <- cli.client.Attach(cname, tty, cli.in, cli.out, cli.err)
		}()
	}

	err = cli.client.StartPod(podId)
	if err != nil {
		return err
	}

	if !attach {
		t2 := time.Now()
		fmt.Printf("Time to run a POD is %d ms\n", (t2.UnixNano()-t1.UnixNano())/1000000)
	}

	if res != nil {
		err = <-res
		// a container having tty may detach from the terminal, don't wait
		return cli.client.GetExitCode(spec.Containers[0].Name, "", !tty)
	}

	return nil
}
573806
func (service *Service) Logout(w http.ResponseWriter, request *http.Request) {
	service.SetLoggedInUser(w, request, "")
	sessions.Save(request, w)
	http.Redirect(w, request, "", http.StatusFound)
}
726794
func LogSetOutputFunction(f LogOutputFunction, data interface{}) {
	ctx := &logOutputFunctionCtx{
		f: f,
		d: data,
	}

	C.LogSetOutputFunction(unsafe.Pointer(ctx))

	logOutputFunctionCache = f
	logOutputDataCache = data
}
559941
func CmdMethod(cmd interface{}) (string, error) {
	// Look up the cmd type and error out if not registered.
	rt := reflect.TypeOf(cmd)
	registerLock.RLock()
	method, ok := concreteTypeToMethod[rt]
	registerLock.RUnlock()
	if !ok {
		str := fmt.Sprintf("%q is not registered", method)
		return "", makeError(ErrUnregisteredMethod, str)
	}

	return method, nil
}
182408
func LogoutHandler(c *gin.Context) {
	session := sessions.Default(c)
	session.Clear()
	err := session.Save()
	if err != nil {
		c.AbortWithError(http.StatusInternalServerError, err)
		return
	}
	c.String(http.StatusOK, "You have successfully logged out.")
}
731750
func (l *Logger) LogCmd(cmd *exec.Cmd, format string, a ...interface{}) (int, error) {
	code := -1
	f := func() error {
		cmdLine := QuotedCmd(cmd)
		l.Debug("executing: %s", cmdLine)

		stdout := &bytes.Buffer{}
		stderr := &bytes.Buffer{}
		cmd.Stdout = stdout
		cmd.Stderr = stderr
		if err := cmd.Run(); err != nil {
			if exitErr, ok := err.(*exec.ExitError); ok {
				code = exitErr.Sys().(syscall.WaitStatus).ExitStatus()
			}
			return fmt.Errorf("%v: Cmd: %s Stdout: %q Stderr: %q", err, cmdLine, stdout.Bytes(), stderr.Bytes())
		}
		return nil
	}
	err := l.LogOp(f, format, a...)
	return code, err
}
777397
func (tc *TeleportClient) Logout() error {
	err := tc.localAgent.DeleteKey()
	if err != nil {
		return trace.Wrap(err)
	}

	return nil
}
377060
func (c *ServicedCli) cmdServiceConfigList(ctx *cli.Context) {
	args := ctx.Args()
	if len(args) < 1 {
		fmt.Printf("Incorrect Usage.\n\n")
		cli.ShowCommandHelp(ctx, "list")
		c.exit(1)
		return
	}

	svcDetails, _, err := c.searchForService(args[0], ctx.Bool("no-prefix-match"))
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		c.exit(1)
		return
	}

	service, err := c.driver.GetService(svcDetails.ID)
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		c.exit(1)
		return
	}

	configs := service.ConfigFiles

	if len(args) < 2 {
		configList := make([]string, 0)

		for filename := range configs {
			configList = append(configList, filename)
		}
		configJson := map[string]([]string){
			"ConfigFiles": configList,
		}
		if configJsonOut, err := json.MarshalIndent(configJson, " ", "  "); err != nil {
			fmt.Fprintln(os.Stderr, err)
			c.exit(1)
			return
		} else {
			fmt.Printf("%s\n\n", configJsonOut)
			return
		}
	} else {
		filename := args[1]
		if _, found := configs[filename]; found {
			fmt.Printf("%s", configs[filename].Content)
		} else {
			fmt.Printf("Config file %s not found.\n", filename)
			c.exit(1)
			return
		}
	}
	return
}
1157061
func (f *Form) Logout(ctx web.Context) error {
	c := &http.Cookie{
		Name:   f.CookieName,
		MaxAge: -1,
	}
	ctx.SetCookie(c)
	return ctx.Redirect(f.DefaultURL)
}
947147
func (n *nessusImpl) Logout() error {
	if n.authCookie == "" {
		log.Println("Not logged in, nothing to do to logout...")
		return nil
	}
	if n.verbose {
		log.Println("Logout...")
	}

	if _, err := n.doRequest("DELETE", "/session", nil, []int{http.StatusOK}); err != nil {
		return err
	}
	n.authCookie = ""
	return nil
}
318340
func Logout(nextURL, basepath string, routes AuthRoutes) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		ctx := r.Context()
		principal, err := getPrincipal(ctx)
		if err != nil {
			http.Redirect(w, r, path.Join(basepath, nextURL), http.StatusTemporaryRedirect)
			return
		}
		route, ok := routes.Lookup(principal.Issuer)
		if !ok {
			http.Redirect(w, r, path.Join(basepath, nextURL), http.StatusTemporaryRedirect)
			return
		}
		http.Redirect(w, r, route.Logout, http.StatusTemporaryRedirect)
	}
}
772888
func (c *ServicedCli) cmdHealthCheck(ctx *cli.Context) error {
	if ctx.Bool("help") {
		return nil
	}

	if results, err := c.driver.ServicedHealthCheck(ctx.Args()); err != nil {
		fmt.Fprintln(os.Stderr, err)
		return c.exit(2)
	} else {

		exitStatus := 0
		t := NewTable("Service Name,Container Name,Container ID,Health Check,Status")
		t.Padding = 2
		for _, serviceHealth := range results {
			for _, status := range serviceHealth.HealthStatuses {
				if status.Status != "passed" {
					exitStatus = 1
				}
				if serviceHealth.ContainerID == "" {
					serviceHealth.ContainerID = "<none>"
				}

				t.AddRow(map[string]interface{}{
					"Service Name":   serviceHealth.ServiceName,
					"Container Name": serviceHealth.ContainerName,
					"Container ID":   serviceHealth.ContainerID[:min(12, len(serviceHealth.ContainerID))],
					"Health Check":   status.Name,
					"Status":         getCombinedStatus(status.Status, status.Failure),
				})
			}
		}
		t.Print()
		return c.exit(exitStatus)
	}
}