Skip to content

Commit

Permalink
Merge pull request #1399 from tailwarden/develop
Browse files Browse the repository at this point in the history
v3.1.15 release 🚀
  • Loading branch information
Azanul authored Apr 6, 2024
2 parents 77db94a + 38d4a02 commit 783b8a4
Show file tree
Hide file tree
Showing 7 changed files with 380 additions and 411 deletions.
28 changes: 3 additions & 25 deletions cmd/config.go
Original file line number Diff line number Diff line change
@@ -1,43 +1,21 @@
package cmd

import (
"os"
"log"

"github.com/BurntSushi/toml"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/tailwarden/komiser/models"
"github.com/tailwarden/komiser/internal/config"
)

var configCmd = &cobra.Command{
Use: "config",
Short: "Create configuration file",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
c := models.Config{
AWS: []models.AWSConfig{
{
Name: "Demo",
Source: "CREDENTIALS_FILE",
Profile: "default",
},
},
SQLite: models.SQLiteConfig{
File: "komiser.db",
},
}

f, err := os.Create("config.toml")
err := config.Create(nil)
if err != nil {
log.Fatal(err)
}
if err := toml.NewEncoder(f).Encode(c); err != nil {
log.Fatal(err)
}
if err := f.Close(); err != nil {
log.Fatal(err)

}
},
}

Expand Down
5 changes: 3 additions & 2 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/tailwarden/komiser/internal"
"github.com/tailwarden/komiser/internal/config"
"github.com/tailwarden/komiser/utils"
)

Expand Down Expand Up @@ -38,8 +39,8 @@ var startCmd = &cobra.Command{

if _, err := os.Stat(filename); errors.Is(err, os.ErrNotExist) {
log.Info("unable to use given config file:", err)
log.Info("Creating default config.toml")
err = os.WriteFile("config.toml", []byte{}, 0644)
log.Info("Creating default config file:", config.DefaultFileName)
err = config.Create(nil)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 783b8a4

Please sign in to comment.