Skip to content

Commit

Permalink
fix: Fixed compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
YanniHu1996 committed Jun 8, 2023
1 parent 3af6be4 commit 228bfef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 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
2 changes: 1 addition & 1 deletion pkg/provider/resource_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 228bfef

Please sign in to comment.