Commit bcc515a0 authored by Simon Schürg's avatar Simon Schürg 🚀
Browse files

Improve status command

parent 10d1fc70
......@@ -17,10 +17,12 @@ var statusCmd = &cobra.Command{
Long: `Print the current state of OpenID Connect sessions`,
Run: func(cmd *cobra.Command, args []string) {
if viper.ConfigFileUsed() != "" {
fmt.Println("Using config file:", viper.ConfigFileUsed())
fmt.Printf("%26s %s\n", "Using config file:", viper.ConfigFileUsed())
} else {
fmt.Println("No actl config file found. Using only defaults, env vars and cli flags.")
fmt.Printf("%26s\n", "No actl config file found. Using only defaults, env vars and cli flags.")
}
fmt.Printf("%26s %s\n\n", "Cached data is located at:", internal.GetDbPath())
fmt.Println("JWTs:")
printTokenTable()
fmt.Println("JWKs:")
......
......@@ -28,8 +28,9 @@ const SchemaVersion = "0.0.1"
// db references the local database
var db *storm.DB
// getDbPath $HOME/.cache
func getDbPath() string {
// GetDbPath returns the file path of the boltdb file
// which is or should be used by actl.
func GetDbPath() string {
dbName := "actl.boltdb"
xdgCacheHome := os.Getenv("XDG_CACHE_HOME")
if xdgCacheHome == "" {
......@@ -51,7 +52,7 @@ func getDbPath() string {
// InitDb ensures the existence of the local database and the schema.
func InitDb() {
var err error
db, err = storm.Open(getDbPath())
db, err = storm.Open(GetDbPath())
FatalOnError(err)
if !doesSchemaVersionMatch() {
log.Fatalln("Database schma version mismatch")
......@@ -103,7 +104,7 @@ func UpsertJWT(encodedToken string) *Token {
// Be careful with this method, it is dangerous!
func ClearDb() {
CloseDb()
err := os.Remove(getDbPath())
err := os.Remove(GetDbPath())
FatalOnError(err)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment