mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 13:29:41 +02:00
chore(code): replace interface{} with any EE-6513 (#11986)
This commit is contained in:
parent
9c4935286f
commit
f0d43f941f
66 changed files with 231 additions and 231 deletions
|
@ -13,25 +13,25 @@ import (
|
|||
|
||||
// GetJSONObject will extract an object from a specific property of another JSON object.
|
||||
// Returns nil if nothing is associated to the specified key.
|
||||
func GetJSONObject(jsonObject map[string]interface{}, property string) map[string]interface{} {
|
||||
func GetJSONObject(jsonObject map[string]any, property string) map[string]any {
|
||||
object := jsonObject[property]
|
||||
if object != nil {
|
||||
return object.(map[string]interface{})
|
||||
return object.(map[string]any)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetArrayObject will extract an array from a specific property of another JSON object.
|
||||
// Returns nil if nothing is associated to the specified key.
|
||||
func GetArrayObject(jsonObject map[string]interface{}, property string) []interface{} {
|
||||
func GetArrayObject(jsonObject map[string]any, property string) []any {
|
||||
object := jsonObject[property]
|
||||
if object != nil {
|
||||
return object.([]interface{})
|
||||
return object.([]any)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getBody(body io.ReadCloser, contentType string, isGzip bool) (interface{}, error) {
|
||||
func getBody(body io.ReadCloser, contentType string, isGzip bool) (any, error) {
|
||||
if body == nil {
|
||||
return nil, errors.New("unable to parse response: empty response body")
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ func getBody(body io.ReadCloser, contentType string, isGzip bool) (interface{},
|
|||
|
||||
defer reader.Close()
|
||||
|
||||
var data interface{}
|
||||
var data any
|
||||
err := unmarshal(contentType, reader, &data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -58,7 +58,7 @@ func getBody(body io.ReadCloser, contentType string, isGzip bool) (interface{},
|
|||
return data, nil
|
||||
}
|
||||
|
||||
func marshal(contentType string, data interface{}) ([]byte, error) {
|
||||
func marshal(contentType string, data any) ([]byte, error) {
|
||||
// Note: contentType can look like: "application/json" or "application/json; charset=utf-8"
|
||||
mediaType, _, err := mime.ParseMediaType(contentType)
|
||||
if err != nil {
|
||||
|
@ -75,7 +75,7 @@ func marshal(contentType string, data interface{}) ([]byte, error) {
|
|||
return nil, fmt.Errorf("content type is not supported for marshaling: %s", contentType)
|
||||
}
|
||||
|
||||
func unmarshal(contentType string, body io.Reader, returnBody interface{}) error {
|
||||
func unmarshal(contentType string, body io.Reader, returnBody any) error {
|
||||
// Note: contentType can look like: "application/json" or "application/json; charset=utf-8"
|
||||
mediaType, _, err := mime.ParseMediaType(contentType)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue