removed deprecations

This commit is contained in:
Peter Morton 2023-05-01 18:28:23 -05:00
parent 32fa31bcac
commit 6e15434846

View File

@ -2,9 +2,10 @@ package client
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"strings"
@ -33,7 +34,7 @@ func GetAccessToken(c *Config) (string, error) {
Scopes: []string{"oidc", "tags", "context_entitlements", "content_entitlements", "em_api_access"},
}
log.WithFields(log.Fields{"conf": fmt.Sprintf("%+v", conf)}).Debug()
token, err := conf.PasswordCredentialsToken(oauth2.NoContext, c.Username, c.Password)
token, err := conf.PasswordCredentialsToken(context.TODO(), c.Username, c.Password)
if err != nil {
log.Error("Error retrieving AccessToken. Chech configuration, username and password")
return "", err
@ -68,7 +69,7 @@ func GetProperties(c *Config, q string) (string, error) {
return "", err
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
log.Error(err)
return "", err
@ -105,7 +106,7 @@ func UpdateProperty(c *Config, p []properties.PropertyUpdateOrCreate) error {
return err
}
defer res.Body.Close()
response, err := ioutil.ReadAll(res.Body)
response, err := io.ReadAll(res.Body)
if err != nil {
log.Error(err)
return err
@ -115,7 +116,11 @@ func UpdateProperty(c *Config, p []properties.PropertyUpdateOrCreate) error {
rp := []properties.PropertyUpdateOrCreate{}
json.Unmarshal(response, &rp)
err = json.Unmarshal(response, &rp)
if err != nil {
log.Fatal(err)
return err
}
if strings.HasPrefix("2", res.Status) {
log.Error(rp[0].Status + rp[0].Description)
}
@ -151,7 +156,7 @@ func DeleteProperty(c *Config, p []properties.PropertyDelete) error {
return err
}
defer res.Body.Close()
response, err := ioutil.ReadAll(res.Body)
response, err := io.ReadAll(res.Body)
if err != nil {
log.Error(err)
return err
@ -161,7 +166,12 @@ func DeleteProperty(c *Config, p []properties.PropertyDelete) error {
rp := []properties.PropertyDelete{}
json.Unmarshal(response, &rp)
err = json.Unmarshal(response, &rp)
if err != nil {
log.Error(err)
return err
}
if strings.HasPrefix("2", res.Status) {
log.Error(rp[0].Status + rp[0].Description)
}