Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into feature/reduce-requ…
Browse files Browse the repository at this point in the history
…ests-for-group-read-operation
  • Loading branch information
vmanilo committed May 8, 2024
2 parents f7bc615 + 5242927 commit efdf0c0
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions twingate/internal/provider/resource/resource-v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,9 @@ func convertAccessGroupsToTerraform(ctx context.Context, groups []string) (types

for _, g := range groups {
attributes := map[string]tfattr.Value{
attr.GroupID: types.StringValue(g),
attr.SecurityPolicyID: types.StringNull(),
attr.GroupID: types.StringValue(g),
attr.SecurityPolicyID: types.StringNull(),
attr.UsageBasedAutolockDurationDays: types.Int64Null(),
}

obj, diags := types.ObjectValue(accessGroupAttributeTypes(), attributes)
Expand All @@ -244,7 +245,7 @@ func convertAccessGroupsToTerraform(ctx context.Context, groups []string) (types
}

if diagnostics.HasError() {
return makeObjectsSetNull(ctx, accessAttributeTypes()), diagnostics
return makeObjectsSetNull(ctx, accessGroupAttributeTypes()), diagnostics
}

return makeObjectsSet(ctx, objects...)
Expand All @@ -264,26 +265,15 @@ func convertAccessServiceAccountsToTerraform(ctx context.Context, serviceAccount
attr.ServiceAccountID: types.StringValue(account),
}

obj, diags := types.ObjectValue(accessGroupAttributeTypes(), attributes)
obj, diags := types.ObjectValue(accessServiceAccountAttributeTypes(), attributes)
diagnostics.Append(diags...)

objects = append(objects, obj)
}

if diagnostics.HasError() {
return makeObjectsSetNull(ctx, accessAttributeTypes()), diagnostics
return makeObjectsSetNull(ctx, accessServiceAccountAttributeTypes()), diagnostics
}

return makeObjectsSet(ctx, objects...)
}

func accessAttributeTypes() map[string]tfattr.Type {
return map[string]tfattr.Type{
attr.GroupIDs: types.SetType{
ElemType: types.StringType,
},
attr.ServiceAccountIDs: types.SetType{
ElemType: types.StringType,
},
}
}

0 comments on commit efdf0c0

Please sign in to comment.