Skip to content

Commit dc38bdd

Browse files
author
Scott Nichols
committed
update to latest knative.
1 parent bd04427 commit dc38bdd

File tree

15 files changed

+64
-115
lines changed

15 files changed

+64
-115
lines changed

Gopkg.lock

Lines changed: 2 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/graph/kodata/static/css/style.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
margin: 0 auto;
2626
}
2727

28+
svg {
29+
vertical-align: middle;
30+
display: block;
31+
margin: auto;
32+
}
33+
2834
.graph-content {
2935
border-radius: 15px;
3036
padding: 20px 30px;

cmd/graph/kodata/templates/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
<main class="graph-main mdl-layout__content">
2626

27-
{{template "main.html"}}
27+
{{template "main.html" .}}
2828

2929
</main>
3030
<footer class="graph-footer mdl-mini-footer">
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<div class="graph-container mdl-grid">
2-
{{ if (eq .Format "svg")}}
3-
{{.Image}}
2+
<div class="mdl-cell mdl-cell--12-col">
3+
{{ if eq .Format "svg" }}
4+
{{ .Image }}
45
{{ else }}
5-
<img src="data:{{.Format}},{{.Image}}">
6+
<img src="data:{{ .Format }},{{ .Image }}">
67
{{ end }}
7-
</div>
8-
8+
</div>
9+
</div>

config/graph.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ metadata:
55
spec:
66
template:
77
spec:
8+
serviceAccountName: n3wscott-graph
89
containers:
910
- image: github.com/n3wscott/graph/cmd/graph
10-
serviceAccountName: n3wscott-graph
1111
env:
1212
- name: NAMESPACE
1313
value: default

config/rbac.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ apiVersion: rbac.authorization.k8s.io/v1
9696
kind: ClusterRoleBinding
9797
metadata:
9898
name: n3wscott-graph-resolver
99-
labels:
100-
events.cloud.run/release: devel
10199
subjects:
102100
- kind: ServiceAccount
103101
name: controller

pkg/controller/ce.go

Lines changed: 0 additions & 23 deletions
This file was deleted.

pkg/controller/controller.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ func (c *Controller) Mux() *http.ServeMux {
2323
c.once.Do(func() {
2424
m := http.NewServeMux()
2525
m.HandleFunc("/ui", c.RootHandler)
26-
http.HandleFunc("/favicon.ico", c.Favicon)
2726
c.mux = m
2827
})
2928

pkg/controller/favicon.go

Lines changed: 0 additions & 23 deletions
This file was deleted.

pkg/controller/root.go

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,23 @@ func getQueryParam(r *http.Request, key string) string {
2727
return keys[0]
2828
}
2929

30+
// TODO: support just fetching the graph image
31+
32+
var defaultFormat = "svg" // or png
33+
var defaultFocus = "trigger" // or png
34+
3035
func (c *Controller) RootHandler(w http.ResponseWriter, r *http.Request) {
3136
once.Do(func() {
32-
t, _ = template.ParseFiles(
37+
var err error
38+
t, err = template.ParseFiles(
3339
c.root+"/templates/index.html",
3440
c.root+"/templates/main.html",
3541
)
42+
if err != nil {
43+
log.Printf("Failed to parse template: %v\n", err)
44+
}
3645
})
3746

38-
c.GraphHTML(w, r)
39-
}
40-
41-
// TODO: support just fetching the graph image
42-
43-
var defaultFormat = "svg" // or png
44-
var defaultFocus = "trigger" // or png
45-
46-
func (c *Controller) GraphHTML(w http.ResponseWriter, r *http.Request) {
4747
format := getQueryParam(r, "format")
4848
if format == "" {
4949
format = defaultFormat
@@ -71,13 +71,18 @@ func (c *Controller) GraphHTML(w http.ResponseWriter, r *http.Request) {
7171
return
7272
}
7373
img, err := ioutil.ReadFile(file)
74+
if err != nil {
75+
log.Printf("read file error %s", err)
76+
}
7477

7578
defer os.Remove(file) // clean up
7679

7780
var data map[string]interface{}
81+
log.Printf("Image is %s", format)
7882
if format == "svg" {
7983
data = map[string]interface{}{
80-
"Image": img,
84+
"svg": true,
85+
"Image": template.HTML(string(img)),
8186
"Format": format,
8287
}
8388
} else {
@@ -86,7 +91,12 @@ func (c *Controller) GraphHTML(w http.ResponseWriter, r *http.Request) {
8691
"Format": fmt.Sprintf("image/%s;base64", format),
8792
}
8893
}
89-
_ = t.Execute(w, data)
94+
data["Dot"] = dotGraph
95+
96+
err = t.Execute(w, data)
97+
if err != nil {
98+
log.Printf("template execute error %s", err)
99+
}
90100
}
91101

92102
var dot string

0 commit comments

Comments
 (0)