mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59: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
|
@ -321,7 +321,7 @@ func migrateDBTestHelper(t *testing.T, srcPath, wantPath string, overrideInstanc
|
|||
// importJSON reads input JSON and commits it to a portainer datastore.Store.
|
||||
// Errors are logged with the testing package.
|
||||
func importJSON(t *testing.T, r io.Reader, store *Store) error {
|
||||
objects := make(map[string]interface{})
|
||||
objects := make(map[string]any)
|
||||
|
||||
// Parse json into map of objects.
|
||||
d := json.NewDecoder(r)
|
||||
|
@ -337,9 +337,9 @@ func importJSON(t *testing.T, r io.Reader, store *Store) error {
|
|||
for k, v := range objects {
|
||||
switch k {
|
||||
case "version":
|
||||
versions, ok := v.(map[string]interface{})
|
||||
versions, ok := v.(map[string]any)
|
||||
if !ok {
|
||||
t.Logf("failed casting %s to map[string]interface{}", k)
|
||||
t.Logf("failed casting %s to map[string]any", k)
|
||||
}
|
||||
|
||||
// New format db
|
||||
|
@ -404,9 +404,9 @@ func importJSON(t *testing.T, r io.Reader, store *Store) error {
|
|||
}
|
||||
|
||||
case "dockerhub":
|
||||
obj, ok := v.([]interface{})
|
||||
obj, ok := v.([]any)
|
||||
if !ok {
|
||||
t.Logf("failed to cast %s to []interface{}", k)
|
||||
t.Logf("failed to cast %s to []any", k)
|
||||
}
|
||||
err := con.CreateObjectWithStringId(
|
||||
k,
|
||||
|
@ -418,9 +418,9 @@ func importJSON(t *testing.T, r io.Reader, store *Store) error {
|
|||
}
|
||||
|
||||
case "ssl":
|
||||
obj, ok := v.(map[string]interface{})
|
||||
obj, ok := v.(map[string]any)
|
||||
if !ok {
|
||||
t.Logf("failed to case %s to map[string]interface{}", k)
|
||||
t.Logf("failed to case %s to map[string]any", k)
|
||||
}
|
||||
err := con.CreateObjectWithStringId(
|
||||
k,
|
||||
|
@ -432,9 +432,9 @@ func importJSON(t *testing.T, r io.Reader, store *Store) error {
|
|||
}
|
||||
|
||||
case "settings":
|
||||
obj, ok := v.(map[string]interface{})
|
||||
obj, ok := v.(map[string]any)
|
||||
if !ok {
|
||||
t.Logf("failed to case %s to map[string]interface{}", k)
|
||||
t.Logf("failed to case %s to map[string]any", k)
|
||||
}
|
||||
err := con.CreateObjectWithStringId(
|
||||
k,
|
||||
|
@ -446,9 +446,9 @@ func importJSON(t *testing.T, r io.Reader, store *Store) error {
|
|||
}
|
||||
|
||||
case "tunnel_server":
|
||||
obj, ok := v.(map[string]interface{})
|
||||
obj, ok := v.(map[string]any)
|
||||
if !ok {
|
||||
t.Logf("failed to case %s to map[string]interface{}", k)
|
||||
t.Logf("failed to case %s to map[string]any", k)
|
||||
}
|
||||
err := con.CreateObjectWithStringId(
|
||||
k,
|
||||
|
@ -462,18 +462,18 @@ func importJSON(t *testing.T, r io.Reader, store *Store) error {
|
|||
continue
|
||||
|
||||
default:
|
||||
objlist, ok := v.([]interface{})
|
||||
objlist, ok := v.([]any)
|
||||
if !ok {
|
||||
t.Logf("failed to cast %s to []interface{}", k)
|
||||
t.Logf("failed to cast %s to []any", k)
|
||||
}
|
||||
|
||||
for _, obj := range objlist {
|
||||
value, ok := obj.(map[string]interface{})
|
||||
value, ok := obj.(map[string]any)
|
||||
if !ok {
|
||||
t.Logf("failed to cast %v to map[string]interface{}", obj)
|
||||
t.Logf("failed to cast %v to map[string]any", obj)
|
||||
} else {
|
||||
var ok bool
|
||||
var id interface{}
|
||||
var id any
|
||||
switch k {
|
||||
case "endpoint_relations":
|
||||
// TODO: need to make into an int, then do that weird
|
||||
|
|
|
@ -12,13 +12,13 @@ const dummyLogoURL = "example.com"
|
|||
|
||||
// initTestingDBConn creates a settings service with raw database DB connection
|
||||
// for unit testing usage only since using NewStore will cause cycle import inside migrator pkg
|
||||
func initTestingSettingsService(dbConn portainer.Connection, preSetObj map[string]interface{}) error {
|
||||
func initTestingSettingsService(dbConn portainer.Connection, preSetObj map[string]any) error {
|
||||
//insert a obj
|
||||
return dbConn.UpdateObject("settings", []byte("SETTINGS"), preSetObj)
|
||||
}
|
||||
|
||||
func setup(store *Store) error {
|
||||
dummySettingsObj := map[string]interface{}{
|
||||
dummySettingsObj := map[string]any{
|
||||
"LogoURL": dummyLogoURL,
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ func migrationError(err error, context string) error {
|
|||
return errors.Wrap(err, "failed in "+context)
|
||||
}
|
||||
|
||||
func GetFunctionName(i interface{}) string {
|
||||
func GetFunctionName(i any) string {
|
||||
return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
|
||||
}
|
||||
|
||||
|
|
|
@ -385,7 +385,7 @@ type storeExport struct {
|
|||
User []portainer.User `json:"users,omitempty"`
|
||||
Version models.Version `json:"version,omitempty"`
|
||||
Webhook []portainer.Webhook `json:"webhooks,omitempty"`
|
||||
Metadata map[string]interface{} `json:"metadata,omitempty"`
|
||||
Metadata map[string]any `json:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
func (store *Store) Export(filename string) (err error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue