Detailed changes
@@ -193,7 +193,12 @@ Listen = "%s"`, defaultDBConn, defaultFetchInterval, defaultFetchInterval, defau
}
if config.FetchInterval < defaultFetchInterval {
- fmt.Println("Fetch interval is set to", strconv.Itoa(config.FetchInterval), "seconds, but the minimum is", defaultFetchInterval, "seconds, using", strconv.Itoa(defaultFetchInterval)+"s")
+ fmt.Println("Fetch interval is set to",
+ strconv.Itoa(config.FetchInterval),
+ "seconds, but the minimum is",
+ defaultFetchInterval,
+ "seconds, using",
+ strconv.Itoa(defaultFetchInterval)+"s")
config.FetchInterval = defaultFetchInterval
}
@@ -38,7 +38,8 @@ func generateAndInsertProjectIDs(tx *sql.Tx) error {
id := fmt.Sprintf("%x", sha256.Sum256([]byte(url+name+forge+createdAt)))
_, err = tx.Exec(
- "INSERT INTO projects (id, url, name, forge, version, created_at) VALUES (@id, @url, @name, @forge, @version, @created_at)",
+ "INSERT INTO projects (id, url, name, forge, version, created_at) "+
+ "VALUES (@id, @url, @name, @forge, @version, @created_at)",
sql.Named("id", id),
sql.Named("url", url),
sql.Named("name", name),
@@ -32,7 +32,10 @@ func DeleteProject(db *sql.DB, mu *sync.Mutex, id string) error {
func GetProject(db *sql.DB, id string) (map[string]string, error) {
var name, forge, url, version string
- err := db.QueryRow("SELECT name, forge, url, version FROM projects WHERE id = ?", id).Scan(&name, &forge, &url, &version)
+ err := db.QueryRow(
+ "SELECT name, forge, url, version FROM projects WHERE id = ?",
+ id,
+ ).Scan(&name, &forge, &url, &version)
if err != nil {
return nil, fmt.Errorf("failed to scan row: %w", err)
}
@@ -119,7 +119,12 @@ func CreateSession(db *sql.DB, username, token string, expiry time.Time) error {
mutex.Lock()
defer mutex.Unlock()
- _, err := db.Exec("INSERT INTO sessions (token, username, expires) VALUES (?, ?, ?)", token, username, expiry.Format(time.RFC3339))
+ _, err := db.Exec(
+ "INSERT INTO sessions (token, username, expires) VALUES (?, ?, ?)",
+ token,
+ username,
+ expiry.Format(time.RFC3339),
+ )
if err != nil {
return fmt.Errorf("failed to execute SQL: %w", err)
}
@@ -32,7 +32,14 @@ func argonHash(password, salt string) (string, error) {
return "", fmt.Errorf("failed to decode base64: %w", err)
}
- return base64.StdEncoding.EncodeToString(argon2.IDKey([]byte(password), decodedSalt, argon2Time, argon2Memory, argon2Threads, argon2KeyLen)), nil
+ return base64.StdEncoding.EncodeToString(argon2.IDKey(
+ []byte(password),
+ decodedSalt,
+ argon2Time,
+ argon2Memory,
+ argon2Threads,
+ argon2KeyLen,
+ )), nil
}
// generateSalt generates a random salt and returns it as a base64-encoded
@@ -66,7 +66,13 @@ func (h Handler) RootHandler(w http.ResponseWriter, r *http.Request) {
IsDashboard: true,
}
- tmpl := template.Must(template.ParseFS(fs, "static/dashboard.html.tmpl", "static/head.html.tmpl", "static/header.html.tmpl", "static/footer.html.tmpl"))
+ tmpl := template.Must(template.ParseFS(
+ fs,
+ "static/dashboard.html.tmpl",
+ "static/head.html.tmpl",
+ "static/header.html.tmpl",
+ "static/footer.html.tmpl",
+ ))
if err := tmpl.Execute(w, data); err != nil {
fmt.Println(err)
}
@@ -85,7 +91,13 @@ func (h Handler) NewHandler(w http.ResponseWriter, r *http.Request) {
if action == "" {
data := struct{ Version string }{Version: *h.Version}
- tmpl := template.Must(template.ParseFS(fs, "static/new.html.tmpl", "static/head.html.tmpl", "static/header.html.tmpl", "static/footer.html.tmpl"))
+ tmpl := template.Must(template.ParseFS(
+ fs,
+ "static/new.html.tmpl",
+ "static/head.html.tmpl",
+ "static/header.html.tmpl",
+ "static/footer.html.tmpl",
+ ))
if err := tmpl.Execute(w, data); err != nil {
fmt.Println(err)
}
@@ -167,7 +179,13 @@ func (h Handler) NewHandler(w http.ResponseWriter, r *http.Request) {
Project: proj,
}
- tmpl := template.Must(template.ParseFS(fs, "static/select-release.html.tmpl", "static/head.html.tmpl", "static/header.html.tmpl", "static/footer.html.tmpl"))
+ tmpl := template.Must(template.ParseFS(
+ fs,
+ "static/select-release.html.tmpl",
+ "static/head.html.tmpl",
+ "static/header.html.tmpl",
+ "static/footer.html.tmpl",
+ ))
if err := tmpl.Execute(w, data); err != nil {
fmt.Println(err)
}
@@ -211,7 +229,15 @@ func (h Handler) NewHandler(w http.ResponseWriter, r *http.Request) {
// If releaseValue is empty, we're creating a new project
if idValue == "" && nameValue != "" && urlValue != "" && forgeValue != "" && releaseValue == "" {
- http.Redirect(w, r, "/new?action=yoink&name="+url.QueryEscape(nameValue)+"&url="+url.QueryEscape(urlValue)+"&forge="+url.QueryEscape(forgeValue), http.StatusSeeOther)
+ http.Redirect(
+ w,
+ r,
+ "/new?action=yoink&name="+url.QueryEscape(nameValue)+
+ "&url="+url.QueryEscape(urlValue)+
+ "&forge="+url.QueryEscape(forgeValue),
+ http.StatusSeeOther,
+ )
+
return
}
@@ -237,7 +263,12 @@ func (h Handler) LoginHandler(w http.ResponseWriter, r *http.Request) {
Version: *h.Version,
}
- tmpl := template.Must(template.ParseFS(fs, "static/login.html.tmpl", "static/head.html.tmpl", "static/footer.html.tmpl"))
+ tmpl := template.Must(template.ParseFS(
+ fs,
+ "static/login.html.tmpl",
+ "static/head.html.tmpl",
+ "static/footer.html.tmpl",
+ ))
if err := tmpl.Execute(w, data); err != nil {
fmt.Println(err)
}