added flags for writing template config to file or stdout
This commit is contained in:
parent
f9a9a87a31
commit
58539471cd
3 changed files with 66 additions and 3 deletions
37
config.tmpl
Normal file
37
config.tmpl
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
notifiers:
|
||||||
|
Apprise: # See: https://github.com/caronc/apprise-api#api-details
|
||||||
|
type: "apprise"
|
||||||
|
url: "http://apprise/notify"
|
||||||
|
title: "GoWatch notification through Apprise"
|
||||||
|
mtype: "info" # Note 'mtype' to avoid conflict with 'type'
|
||||||
|
format: "text"
|
||||||
|
urls:
|
||||||
|
- "tgram://<bot_token>/<chat_id>/"
|
||||||
|
- "discord://<WebhookID>/<WebhookToken>/"
|
||||||
|
Shoutrrr: # See: https://containrrr.dev/shoutrrr/v0.5/services/overview/
|
||||||
|
type: "shoutrrr"
|
||||||
|
urls:
|
||||||
|
- "telegram://<token>@telegram?chats=<channel-1-id>,<chat-2-id>"
|
||||||
|
Telegram:
|
||||||
|
token: "<token>" # See: https://core.telegram.org/bots#how-do-i-create-a-bot
|
||||||
|
chat: "<chatID>" # See: https://www.alphr.com/find-chat-id-telegram/
|
||||||
|
debug: false
|
||||||
|
Discord:
|
||||||
|
type: "discord"
|
||||||
|
token: "<token>" # See: https://www.writebots.com/discord-bot-token/
|
||||||
|
userID: "<userID>" # See: https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID-
|
||||||
|
server:
|
||||||
|
ID: "<serverID>"
|
||||||
|
channel: "<channelID>"
|
||||||
|
debug: false
|
||||||
|
Email:
|
||||||
|
type: "email"
|
||||||
|
server: "smtp.relay.com"
|
||||||
|
port: "465"
|
||||||
|
from: "from@email.com"
|
||||||
|
user: "<user>"
|
||||||
|
password: "<password>"
|
||||||
|
to: "to@email.com"
|
||||||
|
database:
|
||||||
|
dsn: "./watch.db"
|
||||||
|
prune: "@every 1h"
|
29
main.go
29
main.go
|
@ -3,12 +3,14 @@ package main
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -27,7 +29,7 @@ import (
|
||||||
_ "embed"
|
_ "embed"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed templates static watchTemplates
|
//go:embed templates static watchTemplates config.tmpl
|
||||||
var EMBED_FS embed.FS
|
var EMBED_FS embed.FS
|
||||||
|
|
||||||
type Web struct {
|
type Web struct {
|
||||||
|
@ -700,6 +702,31 @@ func (web *Web) importWatch(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
writeConfFlag := flag.String("writeConfig", "-", "Path to write template config to")
|
||||||
|
var printConfigFlag bool
|
||||||
|
flag.BoolVar(&printConfigFlag, "printConfig", false, "Print the template config to stdout")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
if *writeConfFlag != "-" {
|
||||||
|
conf, err := EMBED_FS.ReadFile("config.tmpl")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln("Could not read config.tmpl")
|
||||||
|
}
|
||||||
|
os.WriteFile(*writeConfFlag, conf, 0666)
|
||||||
|
log.Println("Wrote template config to:", *writeConfFlag)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if printConfigFlag {
|
||||||
|
conf, err := EMBED_FS.ReadFile("config.tmpl")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln("Could not read config.tmpl")
|
||||||
|
}
|
||||||
|
log.SetFlags(0)
|
||||||
|
log.Println(string(conf))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
viper.SetConfigName("config")
|
viper.SetConfigName("config")
|
||||||
viper.SetConfigType("yaml")
|
viper.SetConfigType("yaml")
|
||||||
viper.AddConfigPath(".")
|
viper.AddConfigPath(".")
|
||||||
|
|
3
todo.md
3
todo.md
|
@ -7,5 +7,4 @@
|
||||||
- add browserless support ?
|
- add browserless support ?
|
||||||
- file output notifier?
|
- file output notifier?
|
||||||
- show startup warnings on page?
|
- show startup warnings on page?
|
||||||
- try to make docker image smaller
|
- try to make docker image smaller
|
||||||
- add config template output param
|
|
Loading…
Add table
Reference in a new issue