Skip to content

Commit

Permalink
empty result set is empty array
Browse files Browse the repository at this point in the history
  • Loading branch information
benPearce1 committed Sep 10, 2024
1 parent 4f89282 commit e67e6aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion octopusdeploy_framework/datasource_spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions octopusdeploy_framework/datasource_tag_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit e67e6aa

Please sign in to comment.