use empty struct for UserAssignedIdentities map value; omitempty

This commit is contained in:
Feiyu Shi 2020-05-24 15:33:36 -07:00
parent c5e2eff847
commit b334458b91
2 changed files with 5 additions and 9 deletions

View File

@ -100,14 +100,10 @@ type Properties struct {
}
// Template > Resource > Identity
// The map values are simplified to struct{} since they are read-only and cannot be set
type Identity struct {
Type *string `json:"type,omitempty"`
UserAssignedIdentities map[string]*UserAssignedIdentitiesValue `json:"userAssignedIdentities"`
}
type UserAssignedIdentitiesValue struct {
PrincipalId *string `json:"principalId,omitempty"`
ClientId *string `json:"clientId,omitempty"`
Type *string `json:"type,omitempty"`
UserAssignedIdentities map[string]struct{} `json:"userAssignedIdentities,omitempty"`
}
type AccessPolicies struct {

View File

@ -115,10 +115,10 @@ func (s *TemplateBuilder) SetIdentity(userAssignedManagedIdentities []string) er
s.setVariable("apiVersion", "2018-06-01") // Required for user assigned managed identity
id = &Identity{
Type: to.StringPtr("UserAssigned"),
UserAssignedIdentities: make(map[string]*UserAssignedIdentitiesValue),
UserAssignedIdentities: make(map[string]struct{}),
}
for _, uid := range userAssignedManagedIdentities {
id.UserAssignedIdentities[uid] = &UserAssignedIdentitiesValue{}
id.UserAssignedIdentities[uid] = struct{}{}
}
}