From 228bfef75bf3af6dcf6462b7bce10bde0d223199 Mon Sep 17 00:00:00 2001 From: YanniHu1996 Date: Thu, 8 Jun 2023 16:47:51 +0800 Subject: [PATCH] fix: Fixed compile error --- pkg/provider/data_source_projects.go | 10 +++++++--- pkg/provider/resource_project.go | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/provider/data_source_projects.go b/pkg/provider/data_source_projects.go index a8477c24..b368a1df 100644 --- a/pkg/provider/data_source_projects.go +++ b/pkg/provider/data_source_projects.go @@ -29,8 +29,8 @@ func (d *projectsDataSource) Configure(_ context.Context, req datasource.Configu } type projectsDataSourceData struct { - Query string `tfsdk:"query"` - Projects []*models.Project `tfsdk:"items"` + Query *string `tfsdk:"query"` + Projects []*models.Project `tfsdk:"projects"` } func (p projectsDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { @@ -95,7 +95,11 @@ func (p projectsDataSource) Read(ctx context.Context, req datasource.ReadRequest } tflog.Trace(ctx, "read projects data source") - list, err := p.client.ProjectClient().List(ctx, data.Query) + var query string + if data.Query != nil { + query = *data.Query + } + list, err := p.client.ProjectClient().List(ctx, query) if err != nil { resp.Diagnostics.AddError("Read Error", fmt.Sprintf("Unable to call read project, got error: %s", err)) return diff --git a/pkg/provider/resource_project.go b/pkg/provider/resource_project.go index c5638279..d702cac6 100644 --- a/pkg/provider/resource_project.go +++ b/pkg/provider/resource_project.go @@ -173,7 +173,7 @@ func (p projectResource) Read(ctx context.Context, req resource.ReadRequest, res state.UserCount = types.Int64Value(int64(project.UserCount)) state.ClusterCount = types.Int64Value(int64(project.ClusterCount)) if cps := project.CloudProviders; cps != nil { - for _, provider := range *cps { + for _, provider := range cps { state.CloudProviders = append(state.CloudProviders, cloudProvider{ CloudProviderId: provider.CloudProviderId, CloudProviderName: provider.CloudProviderName,