Skip to content

Commit

Permalink
obs acl
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-lifshits committed Nov 29, 2024
1 parent 12bde9d commit a7a2dca
Showing 1 changed file with 23 additions and 25 deletions.
48 changes: 23 additions & 25 deletions openstack/obs/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,42 +78,40 @@ func prepareGrantURI(grant Grant) string {

func convertGrantToXml(grant Grant, isObs bool, isBucket bool) string {
xml := make([]string, 0, 4)
if !isObs {

if isObs {
xml = append(xml, "<Grant><Grantee>")
} else {
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.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>")

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, fmt.Sprintf("<Canned>Everyone</Canned>"))

Check failure on line 103 in openstack/obs/convert.go

View workflow job for this annotation

GitHub Actions / golangci-lint

S1039: unnecessary use of fmt.Sprintf (gosimple)
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))
if isObs && isBucket {
xml = append(xml, fmt.Sprintf("<Delivered>%t</Delivered>", grant.Delivered))
}
xml = append(xml, "</Grant>")
xml = append(xml, fmt.Sprintf("</Grant>"))

Check failure on line 114 in openstack/obs/convert.go

View workflow job for this annotation

GitHub Actions / golangci-lint

S1039: unnecessary use of fmt.Sprintf (gosimple)
return strings.Join(xml, "")
}

Expand Down

0 comments on commit a7a2dca

Please sign in to comment.