mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-04-15 07:16:34 +00:00
fix: address runtime error of nil pointer when concatenating preflight spec with hostpreflight spec in preflight run.go
38 lines
1.3 KiB
Go
38 lines
1.3 KiB
Go
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
|
|
}
|