/
table_helm_template.go
58 lines (48 loc) · 1.47 KB
/
table_helm_template.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package kubernetes
import (
"context"
"path"
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
)
//// TABLE DEFINITION
func tableHelmTemplates(ctx context.Context) *plugin.Table {
return &plugin.Table{
Name: "helm_template",
Description: "Lists the raw templates defined in the configured charts",
List: &plugin.ListConfig{
Hydrate: listHelmTemplates,
},
Columns: []*plugin.Column{
{Name: "chart_name", Type: proto.ColumnType_STRING, Description: "The name of the chart."},
{Name: "path", Type: proto.ColumnType_STRING, Description: "The path to the template file."},
{Name: "raw", Type: proto.ColumnType_STRING, Description: "Raw is the template as byte data."},
},
}
}
type helmTemplateRaw struct {
ChartName string
Path string
Raw string
}
//// LIST FUNCTION
func listHelmTemplates(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) {
charts, err := getUniqueHelmCharts(ctx, d)
if err != nil {
return nil, err
}
for _, chart := range charts {
for _, template := range chart.Chart.Templates {
d.StreamListItem(ctx, helmTemplateRaw{
ChartName: chart.Chart.Metadata.Name,
Raw: string(template.Data),
Path: path.Join(chart.Path, template.Name),
})
// Context can be cancelled due to manual cancellation or the limit has been hit
if d.RowsRemaining(ctx) == 0 {
return nil, nil
}
}
}
return nil, nil
}