@@ -19,6 +19,12 @@ package agreementbot
19
19
import (
20
20
"encoding/json"
21
21
"fmt"
22
+ "io"
23
+ "net/http"
24
+ "os"
25
+ "strings"
26
+ "time"
27
+
22
28
"github.com/golang/glog"
23
29
"github.com/gorilla/mux"
24
30
"github.com/open-horizon/anax/agreementbot/persistence"
@@ -34,11 +40,6 @@ import (
34
40
"github.com/open-horizon/anax/i18n"
35
41
"github.com/open-horizon/anax/worker"
36
42
"golang.org/x/text/message"
37
- "io/ioutil"
38
- "net/http"
39
- "os"
40
- "strings"
41
- "time"
42
43
)
43
44
44
45
const UserTypeCred = "users"
@@ -272,7 +273,7 @@ func (a *SecureAPI) policyCompatibleNodeList(w http.ResponseWriter, r *http.Requ
272
273
matchingNodes := []string {}
273
274
274
275
if user_ec , _ , msgPrinter , ok := a .processExchangeCred ("/compatibility/constraints/node" , UserTypeCred , w , r ); ok {
275
- body , _ := ioutil .ReadAll (r .Body )
276
+ body , _ := io .ReadAll (r .Body )
276
277
if len (body ) == 0 {
277
278
glog .Errorf (APIlogString (fmt .Sprintf ("No input found." )))
278
279
writeResponse (w , msgPrinter .Sprintf ("No input found." ), http .StatusBadRequest )
@@ -350,7 +351,7 @@ func (a *SecureAPI) patternCompatibleNodeList(w http.ResponseWriter, r *http.Req
350
351
matchingNodes := []string {}
351
352
352
353
if user_ec , _ , msgPrinter , ok := a .processExchangeCred ("/compatibility/patterns/node" , UserTypeCred , w , r ); ok {
353
- body , _ := ioutil .ReadAll (r .Body )
354
+ body , _ := io .ReadAll (r .Body )
354
355
if len (body ) == 0 {
355
356
glog .Errorf (APIlogString (fmt .Sprintf ("No input found." )))
356
357
writeResponse (w , msgPrinter .Sprintf ("No input found." ), http .StatusBadRequest )
@@ -491,7 +492,7 @@ func (a *SecureAPI) policy_compatible(w http.ResponseWriter, r *http.Request) {
491
492
492
493
// check user cred
493
494
if user_ec , _ , msgPrinter , ok := a .processExchangeCred ("/deploycheck/policycompatible" , UserTypeCred , w , r ); ok {
494
- body , _ := ioutil .ReadAll (r .Body )
495
+ body , _ := io .ReadAll (r .Body )
495
496
if len (body ) == 0 {
496
497
glog .Errorf (APIlogString (fmt .Sprintf ("No input found." )))
497
498
writeResponse (w , msgPrinter .Sprintf ("No input found." ), http .StatusBadRequest )
@@ -624,7 +625,7 @@ func (a *SecureAPI) userinput_compatible(w http.ResponseWriter, r *http.Request)
624
625
glog .V (5 ).Infof (APIlogString (fmt .Sprintf ("/deploycheck/userinputcompatible called." )))
625
626
626
627
if user_ec , _ , msgPrinter , ok := a .processExchangeCred ("/deploycheck/userinputcompatible" , UserTypeCred , w , r ); ok {
627
- body , _ := ioutil .ReadAll (r .Body )
628
+ body , _ := io .ReadAll (r .Body )
628
629
if len (body ) == 0 {
629
630
glog .Errorf (APIlogString (fmt .Sprintf ("No input found." )))
630
631
writeResponse (w , msgPrinter .Sprintf ("No input found." ), http .StatusBadRequest )
@@ -747,7 +748,7 @@ func (a *SecureAPI) secretbinding_compatible(w http.ResponseWriter, r *http.Requ
747
748
glog .V (5 ).Infof (APIlogString (fmt .Sprintf ("/deploycheck/secretbindingcompatible called." )))
748
749
749
750
if user_ec , exUser , msgPrinter , ok := a .processExchangeCred ("/deploycheck/secretbindingcompatible" , UserTypeCred , w , r ); ok {
750
- body , _ := ioutil .ReadAll (r .Body )
751
+ body , _ := io .ReadAll (r .Body )
751
752
if len (body ) == 0 {
752
753
glog .Errorf (APIlogString (fmt .Sprintf ("No input found." )))
753
754
writeResponse (w , msgPrinter .Sprintf ("No input found." ), http .StatusBadRequest )
@@ -909,7 +910,7 @@ func (a *SecureAPI) deploy_compatible(w http.ResponseWriter, r *http.Request) {
909
910
glog .V (5 ).Infof (APIlogString (fmt .Sprintf ("/deploycheck/deploycompatible called." )))
910
911
911
912
if user_ec , exUser , msgPrinter , ok := a .processExchangeCred ("/deploycheck/deploycompatible" , UserTypeCred , w , r ); ok {
912
- body , _ := ioutil .ReadAll (r .Body )
913
+ body , _ := io .ReadAll (r .Body )
913
914
if len (body ) == 0 {
914
915
glog .Errorf (APIlogString (fmt .Sprintf ("No input found." )))
915
916
writeResponse (w , msgPrinter .Sprintf ("No input found." ), http .StatusBadRequest )
@@ -1305,7 +1306,7 @@ func (a *SecureAPI) secretsSetup(w http.ResponseWriter, r *http.Request) *Secret
1305
1306
1306
1307
func parseSecretDetails (w http.ResponseWriter , r * http.Request , msgPrinter * message.Printer ) * secrets.SecretDetails {
1307
1308
var input secrets.SecretDetails
1308
- if body , err := ioutil .ReadAll (r .Body ); err != nil {
1309
+ if body , err := io .ReadAll (r .Body ); err != nil {
1309
1310
glog .Errorf (APIlogString (fmt .Sprintf ("Unable to read request body, error: %v." , err )))
1310
1311
writeResponse (w , msgPrinter .Sprintf ("Unable to read request body, error: %v." , err ), http .StatusInternalServerError )
1311
1312
return nil
0 commit comments