mirror of
https://github.com/FairwindsOps/polaris.git
synced 2026-05-21 08:33:55 +00:00
implement token and status print
This commit is contained in:
@@ -55,12 +55,10 @@ var statusCmd = &cobra.Command{
|
||||
Short: "View authentication status.",
|
||||
Long: `View authentication status.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
/*
|
||||
✓ Logged in to github.com as vitorvezani (keyring)
|
||||
✓ Git operations for github.com configured to use ssh protocol.
|
||||
✓ Token: ghp_************************************
|
||||
✓ Token scopes: admin:public_key, read:org, repo
|
||||
*/
|
||||
err := auth.PrintStatus()
|
||||
if err != nil {
|
||||
logrus.Fatalf("printing status")
|
||||
}
|
||||
},
|
||||
PersistentPostRunE: func(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
|
||||
24
pkg/auth/status.go
Normal file
24
pkg/auth/status.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package auth
|
||||
|
||||
import "fmt"
|
||||
|
||||
func PrintStatus() error {
|
||||
|
||||
if content, err := readPolarisHostsFile(); err == nil {
|
||||
if len(content) > 0 {
|
||||
for k, h := range content {
|
||||
fmt.Println(k, h)
|
||||
// TODO: Vitor - implement this
|
||||
/*
|
||||
✓ Logged in to github.com as vitorvezani (keyring)
|
||||
✓ Git operations for github.com configured to use ssh protocol.
|
||||
✓ Token: ghp_************************************
|
||||
✓ Token scopes: admin:public_key, read:org, repo
|
||||
*/
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
fmt.Println("You are not logged into Fairwinds Insights. Run polaris auth login to authenticate.")
|
||||
return nil
|
||||
}
|
||||
@@ -1,6 +1,20 @@
|
||||
package auth
|
||||
|
||||
import "fmt"
|
||||
|
||||
func PrintToken() error {
|
||||
// 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
|
||||
if content, err := readPolarisHostsFile(); err == nil {
|
||||
if len(content) > 0 {
|
||||
for k, h := range content {
|
||||
if len(content) == 1 {
|
||||
fmt.Println(h.Token)
|
||||
} else {
|
||||
fmt.Printf("%s: %s\n", k, h.Token)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
fmt.Println("no oauth token")
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user