28 lines
411 B
Go
28 lines
411 B
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"gitnet.fr/deblan/borgmatic-monitor/pkg/borgmatic"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Info struct {
|
|
gorm.Model
|
|
|
|
HostID uint
|
|
Host Host `gorm:"many2one:info"`
|
|
Data string `gorm:"type:text;not null"`
|
|
}
|
|
|
|
func (i *Info) Infos() *borgmatic.Infos {
|
|
var infos borgmatic.Infos
|
|
|
|
err := json.Unmarshal([]byte(i.Data), &infos)
|
|
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
|
|
return &infos
|
|
}
|