@@ -19,45 +19,48 @@ func getServerIP() string {
1919 return conn .LocalAddr ().(* net.UDPAddr ).IP .String ()
2020}
2121
22- func getHTML (image string ) string {
23- message := "TechSupport, Mr. Cat speaking, how can I help you?"
22+ func getHTML (status string ) string {
23+ message := "DevOps, Mr. Cat speaking, how can I help you?"
24+ image := "1.3.0"
2425 color := "orange"
25- if image == "1.3.1 " {
26+ if status == "alive " {
2627 message = "High five budy, I'm healthy as ever!"
28+ image = "1.3.1"
2729 color = "green"
2830 }
29- if image == "1.3.2" {
30- message = "I don't want to die Mr. Stark ( x_x ) ..."
31+ if status == "dead" {
32+ message = "I don't want to die Mr. Stark..."
33+ image = "1.3.2"
3134 color = "red"
3235 }
3336 return `<!DOCTYPE html><html><body><center>
34- <img src="https://raw.githubusercontent.com/twogg-git/k8s-workshop/master /src/` + image + `.png">
35- <h1 style="color:` + color + `">` + message + `</h3>
36- <h2 style="color:green">Playing with Kubernetes</h1>
37- <h2 style="color:blue">Server IP ` + getServerIP () + `</h2>
38- <h3 style="color:blue">Version twogghub/k8s-workshop:1.3-liveness</h3>
39- </center></body></html>`
37+ <img src="https://raw.githubusercontent.com/twogg-git/k8s-workshop/1.3-liveness /src/` + image + `.png">
38+ <h1 style="color:` + color + `">` + message + `</h3>
39+ <h2 style="color:green">Playing with Kubernetes</h1>
40+ <h2 style="color:blue">Server IP ` + getServerIP () + `</h2>
41+ <h3 style="color:blue">Version twogghub/k8s-workshop:1.3-liveness</h3>
42+ </center></body></html>`
4043}
4144
4245func playHome (w http.ResponseWriter , r * http.Request ) {
43- if getServerIP () == bannedIp {
44- fmt .Fprintf (w , getHTML ("1.3.2 " ))
46+ if bannedIp == getServerIP () {
47+ fmt .Fprintf (w , getHTML ("dead " ))
4548 } else {
46- fmt .Fprintf (w , getHTML ("1.3.0 " ))
49+ fmt .Fprintf (w , getHTML ("home " ))
4750 }
4851}
4952
5053func playHealth (w http.ResponseWriter , r * http.Request ) {
5154 if getServerIP () == bannedIp {
5255 w .WriteHeader (http .StatusServiceUnavailable )
5356 } else {
54- fmt .Fprintf (w , getHTML ("1.3.1 " ))
57+ fmt .Fprintf (w , getHTML ("alive " ))
5558 }
5659}
5760
5861func playKillMe (w http.ResponseWriter , r * http.Request ) {
5962 bannedIp = getServerIP ()
60- fmt .Fprintf (w , getHTML ("1.3.2 " ))
63+ fmt .Fprintf (w , getHTML ("dead " ))
6164}
6265
6366func main () {
0 commit comments