Skip to content
Snippets Groups Projects
Commit 2bf47432 authored by Hugo Hörnquist's avatar Hugo Hörnquist
Browse files

Const apiurl.

parent 5d8ae4b3
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
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