2626)
2727
2828const (
29- defaultTemplate = "/path/example.json "
30- defaultClusterUUID = "abcdefgh-12d4-5678-b8ab-ca08e2e82ca7 "
31- defaultCaseID = "12345678 "
29+ defaultTemplate = ""
30+ defaultClusterUUID = ""
31+ defaultCaseID = ""
3232 targetAPIPath = "/api/service_logs/v1/cluster_logs" // https://api.openshift.com/?urls.primaryName=Service%20logs#/default/post_api_service_logs_v1_cluster_logs
3333 modifiedJSON = "modified-template.json"
3434 clusterParameter = "${CLUSTER_UUID}"
@@ -58,7 +58,7 @@ var postCmd = &cobra.Command{
5858 ocmClient := createConnection ()
5959 defer func () {
6060 if err := ocmClient .Close (); err != nil {
61- log .Errorf ("Couldn't close the ocmClient (possible memory leak): %q" , err )
61+ log .Errorf ("Cannot close the ocmClient (possible memory leak): %q" , err )
6262 }
6363 }()
6464
@@ -80,8 +80,8 @@ func init() {
8080// accessTemplate checks if the provided template is currently accessible and returns an error
8181func accessTemplate (template string ) (err error ) {
8282
83- if strings . Contains ( template , defaultTemplate ) {
84- log .Info ( "User template is not provided." )
83+ if template == "" {
84+ log .Errorf ( "Template file is not provided. Use '-t' to fix this ." )
8585 return err
8686 }
8787
@@ -102,7 +102,7 @@ func accessTemplate(template string) (err error) {
102102 }
103103 }
104104
105- return fmt .Errorf ("couldn't read the template %q" , template )
105+ return fmt .Errorf ("cannot read the template %q" , template )
106106
107107}
108108
@@ -123,11 +123,11 @@ func readTemplate() {
123123 if err := accessTemplate (template ); err == nil {
124124 file , err := ioutil .ReadFile (template )
125125 if err != nil {
126- log .Fatalf ("Could not read the file.\n Error: %q\n " , err )
126+ log .Fatalf ("Cannot not read the file.\n Error: %q\n " , err )
127127 }
128128
129129 if err = parseTemplate (file ); err != nil {
130- log .Fatalf ("could not parse the JSON template.\n Error: %q\n " , err )
130+ log .Fatalf ("Cannot not parse the JSON template.\n Error: %q\n " , err )
131131 }
132132 } else {
133133 log .Fatal (err )
@@ -174,7 +174,7 @@ func modifyTemplate(dir string) (newData string) {
174174 // Create the corrected JSON
175175 s , _ := json .MarshalIndent (Message , "" , "\t " )
176176 if _ , err := file .WriteString (string (s )); err != nil {
177- log .Fatalf ("Couldn't write the new modified template %q" , err )
177+ log .Fatalf ("Cannot write the new modified template %q" , err )
178178 }
179179 } else {
180180 log .Fatalf ("Cannot create file %q" , err )
@@ -237,7 +237,7 @@ func check(response *sdk.Response, dir string) {
237237
238238func validateGoodResponse (body []byte ) {
239239 if err := parseGoodReply (body ); err != nil {
240- log .Fatalf ("could not parse the JSON template.\n Error: %q\n " , err )
240+ log .Fatalf ("Cannot not parse the JSON template.\n Error: %q\n " , err )
241241 }
242242
243243 severity := GoodReply .Severity
@@ -272,12 +272,12 @@ func validateBadResponse(body []byte) {
272272 }
273273
274274 if err := parseBadReply (body ); err != nil {
275- log .Fatalf ("Couldn't parse the error JSON message %q" , err )
275+ log .Fatalf ("Cannot parse the error JSON message %q" , err )
276276 }
277277}
278278
279279func cleanup (dir string ) {
280280 if err := os .RemoveAll (dir ); err != nil {
281- log .Errorf ("Couldn't clean up %q" , err )
281+ log .Errorf ("Cannot clean up %q" , err )
282282 }
283283}
0 commit comments