-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
312 additions
and
22,700 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
rover | ||
rover | ||
.DS_Store |
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,64 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
"io" | ||
"log" | ||
"net/http" | ||
"strings" | ||
|
||
tfjson "github.com/hashicorp/terraform-json" | ||
) | ||
|
||
func startServer(frontendFS http.Handler, plan *tfjson.Plan, rso *ResourcesOverview, mapDM *Map, graph Graph) error { | ||
http.Handle("/", frontendFS) | ||
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) { | ||
// simple healthcheck | ||
w.WriteHeader(http.StatusOK) | ||
w.Header().Set("Content-Type", "application/json") | ||
io.WriteString(w, `{"alive": true}`) | ||
|
||
}) | ||
http.HandleFunc("/api/", func(w http.ResponseWriter, r *http.Request) { | ||
fileType := strings.Replace(r.URL.Path, "/api/", "", 1) | ||
|
||
var j []byte | ||
var err error | ||
|
||
enableCors(&w) | ||
|
||
switch fileType { | ||
case "plan": | ||
j, err = json.Marshal(plan) | ||
if err != nil { | ||
io.WriteString(w, fmt.Sprintf("Error producing plan JSON: %s\n", err)) | ||
} | ||
case "rso": | ||
j, err = json.Marshal(rso) | ||
if err != nil { | ||
io.WriteString(w, fmt.Sprintf("Error producing rso JSON: %s\n", err)) | ||
} | ||
case "map": | ||
j, err = json.Marshal(mapDM) | ||
if err != nil { | ||
io.WriteString(w, fmt.Sprintf("Error producing map JSON: %s\n", err)) | ||
} | ||
case "graph": | ||
j, err = json.Marshal(graph) | ||
if err != nil { | ||
io.WriteString(w, fmt.Sprintf("Error producing graph JSON: %s\n", err)) | ||
} | ||
default: | ||
io.WriteString(w, "Please enter a valid file type: plan, rso, map, graph\n") | ||
} | ||
|
||
w.Header().Set("Content-Type", "application/json") | ||
io.Copy(w, bytes.NewReader(j)) | ||
}) | ||
|
||
log.Println("Rover is running on localhost:9000") | ||
|
||
return http.ListenAndServe(":9000", nil) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1 +1 @@ | ||
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>ui</title><link rel="stylesheet" href="/chota.min.css"><link rel="stylesheet" href="/style.css"><link href="/css/app.22910c3c.css" rel="preload" as="style"><link href="/js/app.20524777.js" rel="preload" as="script"><link href="/js/chunk-vendors.bd6ebaf4.js" rel="preload" as="script"><link href="/css/app.22910c3c.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.bd6ebaf4.js"></script><script src="/js/app.20524777.js"></script></body></html> | ||
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>ui</title><link rel="stylesheet" href="/chota.min.css"><link rel="stylesheet" href="/style.css"><link href="/css/app.f05e9f06.css" rel="preload" as="style"><link href="/js/app.8888d743.js" rel="preload" as="script"><link href="/js/chunk-vendors.bd6ebaf4.js" rel="preload" as="script"><link href="/css/app.f05e9f06.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.bd6ebaf4.js"></script><script src="/js/app.8888d743.js"></script></body></html> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.