-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathlogout.go
More file actions
35 lines (31 loc) · 1.02 KB
/
logout.go
File metadata and controls
35 lines (31 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package logout
import (
"fmt"
"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
"github.com/stackitcloud/stackit-cli/internal/pkg/auth"
"github.com/stackitcloud/stackit-cli/internal/pkg/examples"
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
)
func NewCmd(p *types.CmdParams) *cobra.Command {
cmd := &cobra.Command{
Use: "logout",
Short: "Logs out from the STACKIT Terraform Provider and SDK",
Long: "Logs out from the STACKIT Terraform Provider and SDK. This does not affect CLI authentication.",
Args: args.NoArgs,
Example: examples.Build(
examples.NewExample(
`Log out from the STACKIT Terraform Provider and SDK`,
"$ stackit auth api logout"),
),
RunE: func(_ *cobra.Command, _ []string) error {
err := auth.LogoutUserWithContext(auth.StorageContextAPI)
if err != nil {
return fmt.Errorf("log out failed: %w", err)
}
p.Printer.Outputln("Successfully logged out from STACKIT Terraform Provider and SDK.")
return nil
},
}
return cmd
}