Skip to content

Commit 0e842d9

Browse files
committed
RTECO-1646 - Refactor checksumAql function to simplify JSON construction for repository and SHA256 values
1 parent 13ad80c commit 0e842d9

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

artifactory/commands/flexpack/maven.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package flexpack
22

33
import (
4-
"encoding/json"
54
"fmt"
65
"net/url"
76
"os"
@@ -279,18 +278,16 @@ func extractRepoKeyFromUrl(repoUrl string) (string, error) {
279278
// content stored elsewhere from being matched, without assuming any repository path layout.
280279
func checksumAql(repo string, sha256s []string) string {
281280
var b strings.Builder
282-
b.WriteString(`{"repo":`)
283-
repoJSON, _ := json.Marshal(repo)
284-
b.Write(repoJSON)
285-
b.WriteString(`,"$or":[`)
281+
b.WriteString(`{"repo":"`)
282+
b.WriteString(repo)
283+
b.WriteString(`","$or":[`)
286284
for i, sha256 := range sha256s {
287285
if i > 0 {
288286
b.WriteByte(',')
289287
}
290-
b.WriteString(`{"sha256":`)
291-
sha256JSON, _ := json.Marshal(sha256)
292-
b.Write(sha256JSON)
293-
b.WriteByte('}')
288+
b.WriteString(`{"sha256":"`)
289+
b.WriteString(sha256)
290+
b.WriteString(`"}`)
294291
}
295292
b.WriteString("]}")
296293
return b.String()

0 commit comments

Comments
 (0)