From 2bf47432c86ac5ea5f2c126bab4ee50f44c51ad6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= <hugo@lysator.liu.se>
Date: Mon, 2 Nov 2020 18:30:01 +0100
Subject: [PATCH] Const apiurl.

---
 main.go | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/main.go b/main.go
index dc05663..d4c29ef 100644
--- a/main.go
+++ b/main.go
@@ -24,6 +24,9 @@ var classes map[float64]Puppetclass
 var hosts = map[string]Host{}
 var topLevels = []string{ "hosts" }
 
+// const apiurl := "http://localhost:8000/hosts.json"
+const apiurl = "https://chapman.lysator.liu.se/api/"
+
 func main() {
 	password = os.Args[1:][0]
 
@@ -36,13 +39,13 @@ func main() {
 	client = &http.Client { Transport: tr }
 
 
-	// request, err := http.NewRequest("GET", "https://chapman.lysator.liu.se/api/hosts", nil)
-	request, err := http.NewRequest("GET", "http://localhost:8000/hosts.json", nil)
+	request, err := http.NewRequest("GET", apiurl + "hosts", nil)
 	if err != nil {
 		log.Fatal(err);
 	}
 	request.SetBasicAuth("hugo", password);
 
+	log.Print("Getting host list")
 	resp, err := client.Do(request)
 	if err != nil {
 		log.Fatal(err);
@@ -54,6 +57,7 @@ func main() {
 	// echo curl --user "hugo:$(pass lysator/hugo)" -k https://chapman.lysator.liu.se/api/hosts 
 
 
+	log.Print("Parsing host list");
 	decoder := json.NewDecoder(resp.Body);
 	var m Message
 	err = decoder.Decode(&m)
@@ -83,6 +87,7 @@ func main() {
 	// defer c.Unmount()
 	defer c.Close()
 
+	log.Print("Serving filesystem");
 	err = fs.Serve(c, FS{})
 	if err != nil {
 		log.Fatal(err)
@@ -207,6 +212,7 @@ func (fs FS) Root() (fs.Node, error) {
 	return Dir{   /*fs.data*/ }, nil
 }
 
+/*
 func (FS) GenerateInode(parentInode uint64, name string) uint64 {
 	sum := uint64(0)
 	sum += parentInode
@@ -217,6 +223,7 @@ func (FS) GenerateInode(parentInode uint64, name string) uint64 {
 		name, sum, parentInode)
 	return sum
 }
+*/
 
 /* dir hashable? */
 /* TODO does two Dir object with same value hash become the same
-- 
GitLab