Updates before synching with new host-repo.
This commit is contained in:
46
logger.go
Normal file
46
logger.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Logger struct {
|
||||
logpath string
|
||||
logfile []byte
|
||||
}
|
||||
|
||||
// write to our file, if it exists
|
||||
func (l *Logger) Log(str string) {
|
||||
|
||||
CheckLogPath(l.logpath)
|
||||
|
||||
var msg string
|
||||
msg = str
|
||||
os.WriteFile(l.logpath, []byte(msg), os.ModeAppend)
|
||||
}
|
||||
|
||||
// dump the err into a string, write to our log file, then pass off the error to the log package
|
||||
func (l *Logger) Fatal(err error) {
|
||||
l.Log(fmt.Sprintf("%v\n", err))
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
func NewLogger(logpath string) *Logger {
|
||||
CheckLogPath(logpath)
|
||||
|
||||
return &Logger{
|
||||
logpath: logpath,
|
||||
}
|
||||
}
|
||||
|
||||
// checks for existence of given logpath file, creates if it doesn't
|
||||
func CheckLogPath(logpath string) {
|
||||
_, err := os.Stat(logpath)
|
||||
if os.IsNotExist(err) {
|
||||
os.Create(logpath)
|
||||
} else if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
BIN
resources/images/crown.png
Normal file
BIN
resources/images/crown.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
BIN
resources/images/ebiten.png
Normal file
BIN
resources/images/ebiten.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 72 KiB |
19
resources/settings/config.json
Normal file
19
resources/settings/config.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"labels": {
|
||||
"title": "PI-8 Dashboard",
|
||||
"completion": "PHASE B COMPLETE"
|
||||
},
|
||||
"expiry": "2023-11-24T04:00:00.000Z",
|
||||
"jira": {
|
||||
"url": "https://jirawms.mda.ca",
|
||||
"teamfield": "customfield_14580",
|
||||
"project": "GERSSW",
|
||||
"epics": ["GERSSW-4971", "GERSSW-3759"]
|
||||
},
|
||||
"teams": ["devops","gaia", "igaluk", "orion", "pulsar", "solaris", "supernova"],
|
||||
"productowners": ["dbenavid", "el076320", "em031838", "ktsui", "ma031420"],
|
||||
"criteria": {
|
||||
"pattern": "POB: (\\d+)",
|
||||
"matchid": 1
|
||||
}
|
||||
}
|
||||
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