From 4d49aaccaaf52ee78ffc1f90208c1aab6b551b22 Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Wed, 4 Nov 2015 14:40:50 +0000 Subject: [PATCH 1/2] add eslintignore to the dockerfile where we run eslint --- client/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/Dockerfile b/client/Dockerfile index 14445b647a..df9129dde9 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -3,4 +3,4 @@ WORKDIR /home/weave COPY package.json /home/weave/ # Dont install optional developer tools RUN npm install --no-optional -COPY webpack.local.config.js webpack.production.config.js server.js .eslintrc /home/weave/ +COPY webpack.local.config.js webpack.production.config.js server.js .eslintrc .eslintignore /home/weave/ From 9877a2126aaee068c02ee855fc704c4fe0d6a385 Mon Sep 17 00:00:00 2001 From: Paul Bellamy Date: Thu, 5 Nov 2015 14:36:00 +0000 Subject: [PATCH 2/2] removing unused /api/origin/host/{id} route --- app/origin_host.go | 50 ----------------------------------------- app/origin_host_test.go | 33 --------------------------- app/router.go | 2 -- 3 files changed, 85 deletions(-) delete mode 100644 app/origin_host.go delete mode 100644 app/origin_host_test.go diff --git a/app/origin_host.go b/app/origin_host.go deleted file mode 100644 index 1ff8b6c895..0000000000 --- a/app/origin_host.go +++ /dev/null @@ -1,50 +0,0 @@ -package main - -import ( - "net/http" - - "github.com/gorilla/mux" - - "github.com/weaveworks/scope/probe/host" - "github.com/weaveworks/scope/report" -) - -// OriginHost represents a host that runs a probe, i.e. the origin host of -// some data in the system. The struct is returned by the /api/origin/{id} -// handler. -type OriginHost struct { - Hostname string `json:"hostname"` - OS string `json:"os"` - Networks []string `json:"networks"` - Load string `json:"load"` -} - -func getOriginHost(t report.Topology, nodeID string) (OriginHost, bool) { - h, ok := t.Nodes[nodeID] - if !ok { - return OriginHost{}, false - } - - return OriginHost{ - Hostname: h.Metadata[host.HostName], - OS: h.Metadata[host.OS], - Networks: h.Sets[host.LocalNetworks], - Load: h.Metadata[host.Load], - }, true -} - -// makeOriginHostHandler makes the /api/origin/* handler. -func makeOriginHostHandler(rep Reporter) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var ( - vars = mux.Vars(r) - nodeID = vars["id"] - ) - origin, ok := getOriginHost(rep.Report().Host, nodeID) - if !ok { - http.NotFound(w, r) - return - } - respondWith(w, http.StatusOK, origin) - } -} diff --git a/app/origin_host_test.go b/app/origin_host_test.go deleted file mode 100644 index 93b7e9fc5a..0000000000 --- a/app/origin_host_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "encoding/json" - "fmt" - "net/http/httptest" - "testing" - - "github.com/weaveworks/scope/test/fixture" -) - -func TestAPIOriginHost(t *testing.T) { - ts := httptest.NewServer(Router(StaticReport{})) - defer ts.Close() - - is404(t, ts, "/api/origin/foobar") - is404(t, ts, "/api/origin/host/foobar") - - { - // Origin - body := getRawJSON(t, ts, fmt.Sprintf("/api/origin/host/%s", fixture.ServerHostNodeID)) - var o OriginHost - if err := json.Unmarshal(body, &o); err != nil { - t.Fatalf("JSON parse error: %s", err) - } - if want, have := "Linux", o.OS; want != have { - t.Errorf("Origin error. Want %v, have %v", want, have) - } - if want, have := "0.01 0.01 0.01", o.Load; want != have { - t.Errorf("Origin error. Want %v, have %v", want, have) - } - } -} diff --git a/app/router.go b/app/router.go index d05afa2111..fd5eb820eb 100644 --- a/app/router.go +++ b/app/router.go @@ -71,8 +71,6 @@ func Router(c collector) *mux.Router { gzipHandler(topologyRegistry.captureRenderer(c, handleNode))) get.MatcherFunc(URLMatcher("/api/topology/{topology}/{local}/{remote}")).HandlerFunc( gzipHandler(topologyRegistry.captureRenderer(c, handleEdge))) - get.MatcherFunc(URLMatcher("/api/origin/host/{id}")).HandlerFunc( - gzipHandler(makeOriginHostHandler(c))) get.HandleFunc("/api/report", gzipHandler(makeRawReportHandler(c))) get.PathPrefix("/").Handler(http.FileServer(FS(false))) // everything else is static