Skip to content

Commit

Permalink
4
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-lifshits committed Nov 29, 2024
1 parent c7a6746 commit 5a7f31a
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions openstack/obs/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,32 @@ 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 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 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))
}
xml = append(xml, "</Grantee>")
} else {
if grant.Grantee.URI == GroupLogDelivery {
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, "")
}
}
xml = append(xml, "</Grantee>")

xml = append(xml, fmt.Sprintf("<Permission>%s</Permission>", grant.Permission))
if isObs && isBucket {
Expand Down

0 comments on commit 5a7f31a

Please sign in to comment.