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