fix(pkg/config): use storage endpoints
changes: - Only one storage endpoint can be defined. This consists of a URL which can be used to specify whether the data is to be stored in a file or in a database.
This commit is contained in:
52
cmd/db/db.go
52
cmd/db/db.go
@ -1,13 +1,7 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/Masterminds/semver"
|
||||
"github.com/go-flucky/flucky/pkg/config"
|
||||
database "github.com/go-flucky/flucky/pkg/storage/db"
|
||||
"github.com/go-flucky/flucky/pkg/types"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@ -22,33 +16,33 @@ var dbCmd = &cobra.Command{
|
||||
Short: "Operates with the configured database",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
// read configuration
|
||||
cnf, err := config.Read(*configFile)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
// // read configuration
|
||||
// cnf, err := config.Read(*configFile)
|
||||
// if err != nil {
|
||||
// log.Fatalln(err)
|
||||
// }
|
||||
|
||||
postgresDB, err := database.New(cnf.DatabaseSettings)
|
||||
if err != nil {
|
||||
log.Fatalf("%v", err)
|
||||
}
|
||||
// postgresDB, err := database.New(cnf.DatabaseSettings)
|
||||
// if err != nil {
|
||||
// log.Fatalf("%v", err)
|
||||
// }
|
||||
|
||||
ctx := context.Background()
|
||||
// ctx := context.Background()
|
||||
|
||||
devices := []*types.Device{
|
||||
&types.Device{
|
||||
DeviceID: "1684df26-bc72-4435-a4f9-74b24bdb286c",
|
||||
DeviceName: "raspberr-pi",
|
||||
},
|
||||
&types.Device{
|
||||
DeviceID: "1684df26-bc72-4435-a4f9-74b24bdb286c",
|
||||
DeviceName: "raspberr-pi",
|
||||
},
|
||||
}
|
||||
// devices := []*types.Device{
|
||||
// &types.Device{
|
||||
// DeviceID: "1684df26-bc72-4435-a4f9-74b24bdb286c",
|
||||
// DeviceName: "raspberr-pi",
|
||||
// },
|
||||
// &types.Device{
|
||||
// DeviceID: "1684df26-bc72-4435-a4f9-74b24bdb286c",
|
||||
// DeviceName: "raspberr-pi",
|
||||
// },
|
||||
// }
|
||||
|
||||
if err := postgresDB.InsertDevices(ctx, devices); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
// if err := postgresDB.InsertDevices(ctx, devices); err != nil {
|
||||
// log.Fatalln(err)
|
||||
// }
|
||||
},
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user