Updates before synching with new host-repo.
This commit is contained in:
49
settings.go
Normal file
49
settings.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
type DashSettingsJira struct {
|
||||
Url string `json:"url"`
|
||||
Teamfield string `json:"teamfield"`
|
||||
Project string `json:"project"`
|
||||
Epics []string `json:"epics"`
|
||||
}
|
||||
|
||||
type DashSettingsSearch struct {
|
||||
Pattern string `json:"pattern"`
|
||||
MatchId int `json:"matchid"`
|
||||
}
|
||||
|
||||
type DashSettingsLabels struct {
|
||||
Title string `json:"title"`
|
||||
Completion string `json:"completion"`
|
||||
}
|
||||
|
||||
type DashSettings struct {
|
||||
Labels DashSettingsLabels `json:"labels"`
|
||||
Expiry time.Time `json:"expiry"`
|
||||
Jira DashSettingsJira `json:"jira"`
|
||||
Teams []string `json:"teams"`
|
||||
ProductOwners []string `json:"productowners"`
|
||||
Criteria DashSettingsSearch `json:"criteria"`
|
||||
}
|
||||
|
||||
func LoadSettings(path string) (*DashSettings, error) {
|
||||
var err error
|
||||
var settings *DashSettings = &DashSettings{}
|
||||
|
||||
//check file exists, load, deserialize
|
||||
_, err = os.Stat(path)
|
||||
if err == nil {
|
||||
rawbytes, err := os.ReadFile(path)
|
||||
|
||||
if err == nil {
|
||||
err = json.Unmarshal(rawbytes, settings)
|
||||
}
|
||||
}
|
||||
return settings, err
|
||||
}
|
||||
Reference in New Issue
Block a user