diff --git a/octopusdeploy_framework/datasource_environments.go b/octopusdeploy_framework/datasource_environments.go index 35951cd9..a7262886 100644 --- a/octopusdeploy_framework/datasource_environments.go +++ b/octopusdeploy_framework/datasource_environments.go @@ -69,7 +69,7 @@ func (e *environmentDataSource) Read(ctx context.Context, req datasource.ReadReq return } - var mappedEnvironments []schemas.EnvironmentTypeResourceModel + mappedEnvironments := []schemas.EnvironmentTypeResourceModel{} if data.Name.IsNull() { tflog.Debug(ctx, fmt.Sprintf("environments returned from API: %#v", existingEnvironments)) for _, environment := range existingEnvironments.Items { diff --git a/octopusdeploy_framework/datasource_project_groups.go b/octopusdeploy_framework/datasource_project_groups.go index 6a51b732..70e3e249 100644 --- a/octopusdeploy_framework/datasource_project_groups.go +++ b/octopusdeploy_framework/datasource_project_groups.go @@ -90,7 +90,7 @@ func (p *projectGroupsDataSource) Read(ctx context.Context, req datasource.ReadR return } - var newGroups []schemas.ProjectGroupTypeResourceModel + newGroups := []schemas.ProjectGroupTypeResourceModel{} for _, projectGroup := range existingProjectGroups.Items { tflog.Debug(ctx, "loaded group "+projectGroup.Name) var g schemas.ProjectGroupTypeResourceModel 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))