Initial commit

This commit is contained in:
2022-08-12 14:49:16 +02:00
commit b9b0c10e1c
22 changed files with 3737 additions and 0 deletions

35
storage/storage.go Normal file
View File

@@ -0,0 +1,35 @@
package storage
import (
"fmt"
"github.com/spf13/viper"
)
type Storage interface {
//Vehicles management
CreateVehicle(Vehicle) error
GetVehicle(id string) (*Vehicle, error)
GetVehicles(namespaces []string) ([]Vehicle, error)
//Bookings management
CreateBooking(Booking) error
GetBooking(id string) (*Booking, error)
GetBookingsForVehicle(vehicleid string) ([]Booking, error)
DeleteBooking(id string) error
}
func NewStorage(cfg *viper.Viper) (Storage, error) {
var (
storage_type = cfg.GetString("storage.db.type")
)
switch storage_type {
case "mongodb":
s, err := NewMongoDBStorage(cfg)
return s, err
default:
return nil, fmt.Errorf("storage type %v is not supported", storage_type)
}
}