Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-lifshits committed Nov 29, 2024
1 parent 12bde9d commit c9b069f
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions openstack/obs/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,31 +82,16 @@ func convertGrantToXml(grant Grant, isObs bool, isBucket bool) string {
xml = append(xml, fmt.Sprintf("<Grant><Grantee xsi:type=\"%s\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">", grant.Grantee.Type))
}

if grant.Grantee.Type == GranteeUser {
if isObs {
xml = append(xml, "<Grant><Grantee>")
}
if grant.Grantee.ID != "" {
granteeID := XmlTranscoding(grant.Grantee.ID)
xml = append(xml, fmt.Sprintf("<ID>%s</ID>", granteeID))
}
if !isObs && grant.Grantee.DisplayName != "" {
granteeDisplayName := XmlTranscoding(grant.Grantee.DisplayName)
xml = append(xml, fmt.Sprintf("<DisplayName>%s</DisplayName>", granteeDisplayName))
}
if !isObs {
xml = append(xml, fmt.Sprintf("<Grant><Grantee xsi:type=\"%s\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">", grant.Grantee.Type))
xml = append(xml, prepareGrantURI(grant))
xml = append(xml, "</Grantee>")
} else if grant.Grantee.URI == GroupAllUsers {
xml = append(xml, "<Grant><Grantee>")
xml = append(xml, "<Canned>Everyone</Canned>")
xml = append(xml, "</Grantee>")
} else {
if !isObs {
xml = append(xml, fmt.Sprintf("<Grant><Grantee xsi:type=\"%s\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">", grant.Grantee.Type))
xml = append(xml, prepareGrantURI(grant))
xml = append(xml, "</Grantee>")
} else if grant.Grantee.URI == GroupAllUsers {
xml = append(xml, "<Grant><Grantee>")
xml = append(xml, "<Canned>Everyone</Canned>")
xml = append(xml, "</Grantee>")
} else {
return strings.Join(xml, "")
}
return strings.Join(xml, "")
}

xml = append(xml, fmt.Sprintf("<Permission>%s</Permission>", grant.Permission))
Expand Down

0 comments on commit c9b069f

Please sign in to comment.