Skip to content
Snippets Groups Projects
Commit 2bef1b83 authored by Tulir Asokan's avatar Tulir Asokan :cat2:
Browse files

Make token path configurable

parent cd24b8e6
No related branches found
No related tags found
No related merge requests found
......@@ -17,4 +17,4 @@ FROM scratch
COPY --from=builder /usr/bin/maulabbot /usr/bin/maulabbot
COPY --from=builder /etc/ssl/certs/ /etc/ssl/certs
CMD ["/usr/bin/maulabbot"]
CMD ["/usr/bin/maulabbot", "-c", "/etc/maulabbot/config.json", "-t", "/etc/maulabbot/tokens.json"]
......@@ -28,11 +28,11 @@ var gitlabTokens = make(map[string]string)
func saveGitlabTokens() {
data, _ := json.MarshalIndent(gitlabTokens, "", " ")
ioutil.WriteFile("tokens.json", data, 0600)
ioutil.WriteFile(*tokensPath, data, 0600)
}
func loadGitlabTokens() {
data, err := ioutil.ReadFile("tokens.json")
data, err := ioutil.ReadFile(*tokensPath)
if err != nil {
return
}
......
......@@ -28,9 +28,10 @@ import (
var wantHelp, _ = flag.MakeHelpFlag()
var configPath = flag.MakeFull("c", "config", "The path to the config file.", "config.json").String()
var tokensPath = flag.MakeFull("t", "tokens", "The path to the tokens file.", "tokens.json").String()
func main() {
flag.SetHelpTitles("maulabbot - A GitLab bot for Matrix", "maulabbot [-h] [-c /path/to/config]")
flag.SetHelpTitles("maulabbot - A GitLab bot for Matrix", "maulabbot [-h] [-c /path/to/config] [-t /path/to/tokens]")
err := flag.Parse()
if err != nil {
fmt.Println(err)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment