Files
pmg/cmd/cloud/logout.go
T
Abhisek DattaandGitHub 887984612c feat: Add Cloud Endpoint Sync Commands (#216)
* feat: Add cloud sync command

* feat: Add pmg cloud commands

* fix: Code review fixes

* fix: Code review fixes

* fix: Code review fixes

* fix: Code review fixes

* fix: Code review fixes

* fix: Code review fixes
2026-04-13 13:40:18 +05:30

44 lines
1.1 KiB
Go

package cloud
import (
"github.com/safedep/dry/cloud"
"github.com/safedep/dry/log"
"github.com/safedep/pmg/internal/ui"
"github.com/safedep/pmg/usefulerror"
"github.com/spf13/cobra"
)
func newLogoutCommand() *cobra.Command {
return &cobra.Command{
Use: "logout",
Short: "Clear stored SafeDep Cloud credentials",
RunE: runLogout,
}
}
func runLogout(cmd *cobra.Command, args []string) error {
store, err := cloud.NewKeychainCredentialStore()
if err != nil {
ui.ErrorExit(usefulerror.Useful().
Wrap(err).
WithCode(usefulerror.ErrCodeLifecycle).
WithHumanError("Failed to initialize credential store").
WithHelp("Your system may not support secure credential storage"))
}
defer func() {
if err := store.Close(); err != nil {
log.Warnf("failed to close credential store: %v", err)
}
}()
if err := store.Clear(); err != nil {
ui.ErrorExit(usefulerror.Useful().
Wrap(err).
WithCode(usefulerror.ErrCodeLifecycle).
WithHumanError("Failed to clear credentials"))
}
ui.Successf("Credentials cleared from keychain")
return nil
}