/
concat.go
37 lines (34 loc) · 1.3 KB
/
concat.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
32
33
34
35
36
37
package preflight
import (
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
)
func ConcatPreflightSpec(target *troubleshootv1beta2.Preflight, source *troubleshootv1beta2.Preflight) *troubleshootv1beta2.Preflight {
if source == nil {
return target
}
var newSpec *troubleshootv1beta2.Preflight
if target == nil {
newSpec = source
} else {
newSpec = target.DeepCopy()
newSpec.Spec.Collectors = append(newSpec.Spec.Collectors, source.Spec.Collectors...)
newSpec.Spec.RemoteCollectors = append(newSpec.Spec.RemoteCollectors, source.Spec.RemoteCollectors...)
newSpec.Spec.Analyzers = append(newSpec.Spec.Analyzers, source.Spec.Analyzers...)
}
return newSpec
}
func ConcatHostPreflightSpec(target *troubleshootv1beta2.HostPreflight, source *troubleshootv1beta2.HostPreflight) *troubleshootv1beta2.HostPreflight {
if source == nil {
return target
}
var newSpec *troubleshootv1beta2.HostPreflight
if target == nil {
newSpec = source
} else {
newSpec = target.DeepCopy()
newSpec.Spec.Collectors = append(newSpec.Spec.Collectors, source.Spec.Collectors...)
newSpec.Spec.RemoteCollectors = append(newSpec.Spec.RemoteCollectors, source.Spec.RemoteCollectors...)
newSpec.Spec.Analyzers = append(newSpec.Spec.Analyzers, source.Spec.Analyzers...)
}
return newSpec
}