-
Notifications
You must be signed in to change notification settings - Fork 0
/
resource_list.go
33 lines (29 loc) · 952 Bytes
/
resource_list.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
package planners
import (
"path/filepath"
"github.com/pkg/errors"
"github.com/replicatedcom/support-bundle/pkg/collect/plans"
"github.com/replicatedcom/support-bundle/pkg/collect/types"
)
func (k *Kubernetes) ResourceList(spec types.Spec) []types.Task {
var err error
if spec.KubernetesResourceList == nil {
err = errors.New("spec for kubernetes.resource-list required")
} else if spec.KubernetesResourceList.Kind == "" {
err = errors.New("spec for kubernetes.resource-list kind required")
}
if err != nil {
task := plans.PreparedError(err, spec)
return []types.Task{task}
}
task := plans.StructuredSource{
Producer: k.producers.ResourceList(*spec.KubernetesResourceList),
JSONPath: filepath.Join(spec.Shared().OutputDir, "resource.json"),
}
task, err = plans.SetCommonFieldsStructuredSource(task, spec)
if err != nil {
task := plans.PreparedError(err, spec)
return []types.Task{task}
}
return []types.Task{&task}
}