Skip to content

Commit 8411804

Browse files
committed
Make list part of HelmRelease struct
1 parent 449045c commit 8411804

File tree

1 file changed

+4
-40
lines changed

1 file changed

+4
-40
lines changed

helm/list_helm_release.go

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,13 @@ import (
88
"github.com/hashicorp/terraform-plugin-framework/diag"
99
"github.com/hashicorp/terraform-plugin-framework/list"
1010
"github.com/hashicorp/terraform-plugin-framework/list/schema"
11-
"github.com/hashicorp/terraform-plugin-framework/resource"
1211
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
1312
"github.com/hashicorp/terraform-plugin-framework/types"
14-
"github.com/hashicorp/terraform-plugin-log/tflog"
1513

1614
"helm.sh/helm/v3/pkg/action"
1715
)
1816

19-
var (
20-
_ list.ListResource = &HelmReleaseList{}
21-
_ list.ListResourceWithConfigure = &HelmReleaseList{}
22-
)
23-
24-
type HelmReleaseList struct {
25-
meta *Meta
26-
}
17+
var _ list.ListResource = &HelmRelease{}
2718

2819
type HelmReleaseListConfig struct {
2920
AllNamespaces types.Bool `tfsdk:"all_namespaces"`
@@ -32,37 +23,10 @@ type HelmReleaseListConfig struct {
3223
}
3324

3425
func NewHelmReleaseList() list.ListResource {
35-
return &HelmReleaseList{}
36-
}
37-
38-
func (l *HelmReleaseList) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) {
39-
if req.ProviderData == nil {
40-
tflog.Debug(ctx, "Meta is nil for List Resource")
41-
42-
// HACK FIXME
43-
l.meta = m
44-
45-
return
46-
}
47-
48-
meta, ok := req.ProviderData.(*Meta)
49-
if !ok {
50-
resp.Diagnostics.AddError(
51-
"Provider Configuration Error",
52-
fmt.Sprintf("Unexpected ProviderData type: %T", req.ProviderData),
53-
)
54-
return
55-
}
56-
tflog.Debug(ctx, fmt.Sprintf("Configured meta: %+v", meta))
57-
58-
l.meta = meta
59-
}
60-
61-
func (l *HelmReleaseList) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
62-
resp.TypeName = req.ProviderTypeName + "_release"
26+
return &HelmRelease{}
6327
}
6428

65-
func (l *HelmReleaseList) ListResourceConfigSchema(ctx context.Context, req list.ListResourceSchemaRequest, resp *list.ListResourceSchemaResponse) {
29+
func (l *HelmRelease) ListResourceConfigSchema(ctx context.Context, req list.ListResourceSchemaRequest, resp *list.ListResourceSchemaResponse) {
6630
resp.Schema = schema.Schema{
6731
Description: "Schema to define attributes that are available in the resource",
6832
Attributes: map[string]schema.Attribute{
@@ -82,7 +46,7 @@ func (l *HelmReleaseList) ListResourceConfigSchema(ctx context.Context, req list
8246
}
8347
}
8448

85-
func (l *HelmReleaseList) List(ctx context.Context, req list.ListRequest, results *list.ListResultsStream) {
49+
func (l *HelmRelease) List(ctx context.Context, req list.ListRequest, results *list.ListResultsStream) {
8650
results.Results = func(yield func(list.ListResult) bool) {
8751
listConfig := HelmReleaseListConfig{}
8852
req.Config.Get(ctx, &listConfig)

0 commit comments

Comments
 (0)