Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a way to specify a github oauth token
- Loading branch information
Showing
5 changed files
with
106 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package models | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/Depado/gomonit/conf" | ||
) | ||
|
||
// ParseConf parses the configuration and returns the appropriate Services | ||
func ParseConf() error { | ||
All = make(Services, len(conf.C.Services)) | ||
conf.C.CIURL = strings.TrimSuffix(conf.C.CIURL, "/") | ||
for i, s := range conf.C.Services { | ||
if s.CIType != "" && s.CIType != "drone" { | ||
return fmt.Errorf("Unable to use %s as CI, currently only drone is supported.", s.CIType) | ||
} | ||
if s.RepoType != "" && s.RepoType != "github" { | ||
return fmt.Errorf("Unable to use %s as repository, currently only github is supported.", s.RepoType) | ||
} | ||
repoURL := "" | ||
if s.Repo != "" { | ||
repoURL = fmt.Sprintf("https://github.com/%s", s.Repo) | ||
} | ||
buildAPI := "" | ||
buildURL := "" | ||
if s.CIType != "" { | ||
buildAPI = fmt.Sprintf("%s/api/repos/%s/builds", conf.C.CIURL, s.Repo) | ||
buildURL = fmt.Sprintf("%s/%s", conf.C.CIURL, s.Repo) | ||
} | ||
short := strings.TrimPrefix(s.URL, "http://") | ||
short = strings.TrimPrefix(short, "https://") | ||
All[i] = &Service{ | ||
Name: s.Name, | ||
URL: s.URL, | ||
ShortURL: short, | ||
Host: s.Host, | ||
BuildAPI: buildAPI, | ||
BuildURL: buildURL, | ||
RepoURL: repoURL, | ||
Icon: "/static/custom/" + s.Icon, | ||
Own: s.Own, | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters