package main // parses /etc/gowebd/repomap // this file defines what repositories show up on go.wit.com import ( "fmt" "net/http" "os" "strings" "go.wit.com/log" ) // this makes the "go-source" / "go-import" page // this redirects the go path "go.wit.com/apps/go-clone" to the git path "gitea.wit.com/wit/go-clone" func repoHTML(w http.ResponseWriter, gourl string, realurl string) { realurl = "https://" + realurl log.Info("go repo =", gourl, "real url =", realurl) fmt.Fprintln(w, "") fmt.Fprintln(w, "") fmt.Fprintln(w, "") // fmt.Fprintln(w, fmt.Fprintln(w, "") fmt.Fprintln(w, "") fmt.Fprintln(w, "") fmt.Fprintln(w, "") fmt.Fprintln(w, "") fmt.Fprintln(w, "Nothing to see here. Please move along.\"") fmt.Fprintln(w, "") fmt.Fprintln(w, "") } func findkey(url string) (string, string) { key := "go.wit.com" + url if repoMap[key] != "" { return key, repoMap[key] } return key, "" // parts := strings.Split(key, "/") } func readRepomap() { var pfile []byte var err error pfile, err = os.ReadFile(REPOMAP) if err != nil { log.Error(err, "no repository map file found in /etc/gowebd/") log.Error(err, "falling back to the repository map file built into the gowebd binary") pfile, err = resources.ReadFile("resources/repomap") if err != nil { log.Error(err, "missing repomap in the binary") return } } configfile = strings.Split(string(pfile), "\n") for _, line := range configfile { fields := strings.Fields(line) if len(fields) < 2 { continue } gopath := fields[0] giturl := fields[1] repoMap[gopath] = giturl repo := forge.Repos.FindByGoPath(gopath) if repo != nil { version := repo.GetLastTag() age := repo.NewestAge() log.Info("repo =", gopath, "real url =", repoMap[gopath], version, formatDuration(age)) versionMap[gopath] = version + " " + formatDuration(age) } else { log.Info("repo =", gopath, "real url =", repoMap[gopath], "not found") } } }