@@ -20,6 +20,8 @@ import (
2020
2121var (
2222 template , clusterUUID , caseID string
23+ isURL bool
24+ HTMLBody []byte
2325 Message servicelog.Message
2426 GoodReply servicelog.GoodReply
2527 BadReply servicelog.BadReply
@@ -98,10 +100,13 @@ func accessTemplate(template string) (err error) {
98100 if err := utils .IsOnline (* urlPage ); err != nil {
99101 log .Errorf ("host %q is not accessible" , template )
100102 } else {
103+ HTMLBody , err = utils .CurlThis (urlPage .String ())
104+ if err == nil {
105+ isURL = true
106+ }
101107 return err
102108 }
103109 }
104-
105110 return fmt .Errorf ("cannot read the template %q" , template )
106111
107112}
@@ -120,10 +125,17 @@ func parseBadReply(jsonFile []byte) error {
120125}
121126
122127func readTemplate () {
123- if err := accessTemplate (template ); err == nil {
124- file , err := ioutil .ReadFile (template )
125- if err != nil {
126- log .Fatalf ("Cannot not read the file.\n Error: %q\n " , err )
128+ if err := accessTemplate (template ); err == nil { // check if this URL or file and if we can access it
129+ var file []byte
130+ if isURL {
131+ // template is URL on the web
132+ file = HTMLBody
133+ } else {
134+ // template is file on the disk
135+ file , err = ioutil .ReadFile (template ) // this works only for files
136+ if err != nil {
137+ log .Fatalf ("Cannot not read the file.\n Error: %q\n " , err )
138+ }
127139 }
128140
129141 if err = parseTemplate (file ); err != nil {
0 commit comments