diff --git a/octopusdeploy_framework/datasource_spaces.go b/octopusdeploy_framework/datasource_spaces.go index dcb66e07..18754f11 100644 --- a/octopusdeploy_framework/datasource_spaces.go +++ b/octopusdeploy_framework/datasource_spaces.go @@ -62,7 +62,7 @@ func (b *spacesDataSource) Read(ctx context.Context, req datasource.ReadRequest, return } - var mappedSpaces []schemas.SpaceModel + mappedSpaces := []schemas.SpaceModel{} for _, space := range existingSpaces.Items { var s schemas.SpaceModel mapSpaceToState(ctx, &s, space) diff --git a/octopusdeploy_framework/datasource_tag_sets.go b/octopusdeploy_framework/datasource_tag_sets.go index cad823bd..98ca57b8 100644 --- a/octopusdeploy_framework/datasource_tag_sets.go +++ b/octopusdeploy_framework/datasource_tag_sets.go @@ -60,15 +60,16 @@ func (t *tagSetsDataSource) Read(ctx context.Context, req datasource.ReadRequest util.DatasourceResultCount(ctx, "tag sets", len(existingTagSets.Items)) - data.TagSets = flattenTagSets(existingTagSets.Items) + data.TagSets = flattenTagSets(ctx, existingTagSets.Items) data.ID = types.StringValue(fmt.Sprintf("TagSets-%s", time.Now().UTC().String())) resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } -func flattenTagSets(tagSets []*tagsets.TagSet) types.List { +func flattenTagSets(ctx context.Context, tagSets []*tagsets.TagSet) types.List { if len(tagSets) == 0 { - return types.ListNull(types.ObjectType{AttrTypes: schemas.GetTagSetAttrTypes()}) + emptyList, _ := types.ListValueFrom(ctx, types.ObjectType{AttrTypes: schemas.GetTagSetAttrTypes()}, tagSets) + return emptyList } tfList := make([]attr.Value, len(tagSets))