/
utils.go
31 lines (26 loc) · 883 Bytes
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2023-present Datadog, Inc.
package profile
import (
"os"
"github.com/mohae/deepcopy"
)
// mergeProfiles merges two profiles config map
// we use deepcopy to lower risk of modifying original profiles
func mergeProfiles(profilesA ProfileConfigMap, profilesB ProfileConfigMap) ProfileConfigMap {
profiles := make(ProfileConfigMap)
for k, v := range profilesA {
profiles[k] = deepcopy.Copy(v).(ProfileConfig)
}
for k, v := range profilesB {
profiles[k] = deepcopy.Copy(v).(ProfileConfig)
}
return profiles
}
// pathExists returns true if the given path exists
func pathExists(path string) bool {
_, err := os.Stat(path)
return !os.IsNotExist(err)
}