Skip to content

Commit

Permalink
fix: Changed string to *string
Browse files Browse the repository at this point in the history
  • Loading branch information
YanniHu1996 committed Jun 8, 2023
1 parent 3af6be4 commit 27850ba
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/provider/data_source_projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 27850ba

Please sign in to comment.