mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 07:49:41 +02:00
feat(edgejobs): support edge groups when using edge jobs EE-3873 (#8099)
This commit is contained in:
parent
9732d1b5d8
commit
e1b474d04f
29 changed files with 544 additions and 83 deletions
34
api/internal/maps/maps.go
Normal file
34
api/internal/maps/maps.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package maps
|
||||
|
||||
import "strings"
|
||||
|
||||
// Get a key from a nested map. Not support array for the moment
|
||||
func Get(mapObj map[string]interface{}, path string, key string) interface{} {
|
||||
if path == "" {
|
||||
return mapObj[key]
|
||||
}
|
||||
paths := strings.Split(path, ".")
|
||||
v := mapObj
|
||||
for _, p := range paths {
|
||||
if p == "" {
|
||||
continue
|
||||
}
|
||||
value, ok := v[p].(map[string]interface{})
|
||||
if ok {
|
||||
v = value
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
return v[key]
|
||||
}
|
||||
|
||||
// Copy copies all key/value pairs in src adding them to dst.
|
||||
// When a key in src is already present in dst,
|
||||
// the value in dst will be overwritten by the value associated
|
||||
// with the key in src.
|
||||
func Copy[M ~map[K]V, K comparable, V any](dst, src M) {
|
||||
for k, v := range src {
|
||||
dst[k] = v
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue