Skip to content

Commit

Permalink
Merge pull request #117 from 030/113-upload-zip-files
Browse files Browse the repository at this point in the history
[GH-113] Upload zip files.
  • Loading branch information
030 authored Mar 25, 2020
2 parents 52ed61e + b6f142a commit 4e36ef9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ If the matter is security related, please disclose it privately by sending an em
**Anything else we need to know?**:

**Environment**:
- nexus version:
- n3dr version (use `n3dr -v`):
- OS (e.g: `cat /etc/os-release`):
- Kernel (e.g. `uname -a`):
Expand Down
2 changes: 1 addition & 1 deletion cli/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/030/go-utils"
log "github.com/sirupsen/logrus"

mp "github.com/030/go-curl/utils"
mp "github.com/030/go-multipart/utils"
)

// See https://stackoverflow.com/a/34102842/2777965
Expand Down
8 changes: 7 additions & 1 deletion cli/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"path/filepath"
"strings"

mp "github.com/030/go-curl/utils"
mp "github.com/030/go-multipart/utils"
log "github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -70,6 +70,12 @@ func (n Nexus3) Upload() error {
s.WriteString("maven2.asset3=@" + path + ",")
s.WriteString("maven2.asset3.extension=war,")
}

if filepath.Ext(path) == ".zip" {
log.Debug("ZIP found " + path)
s.WriteString("maven2.asset42=@" + path + ",")
s.WriteString("maven2.asset42.extension=zip,")
}
}
return nil
})
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module n3dr
go 1.14

require (
github.com/030/go-curl v1.0.0
github.com/030/go-multipart v1.0.2
github.com/030/go-utils v0.0.0-20190427204242-b7d6df265912
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/030/go-curl v1.0.0 h1:xvRH71ShK4rsLJZZbBm3QcZIDbgA8pp++SdP89RdGyU=
github.com/030/go-curl v1.0.0/go.mod h1:Os6VaotEeJnnPA/4VWNr2ou3rx5gUj822VMr9jtnmoc=
github.com/030/go-multipart v1.0.2 h1:0TQEVo/26lxzUv4F10I5g2EpRCqoKUzLGNqxix8sKEA=
github.com/030/go-multipart v1.0.2/go.mod h1:2FgmvRHQPTXWsP1JXG2X0S04yLepJusX8G6vuWTzxkE=
github.com/030/go-utils v0.0.0-20190427204242-b7d6df265912 h1:MdgRWx8epGSKbQYxR/kEzmQkUHQCiB8gNlM+QDwiivM=
github.com/030/go-utils v0.0.0-20190427204242-b7d6df265912/go.mod h1:HQbQNpJnmYGDC3WTdKeB5cslJFbZ78Cr+KTEZcJTi4o=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
Expand Down
22 changes: 12 additions & 10 deletions integration-tests.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/bin/bash -ex
#!/bin/bash -e

NEXUS_VERSION="${1:-3.21.1}"
NEXUS_API_VERSION="${2:-v1}"
TOOL="${3:-./n3dr}"
TRAVIS_TAG="${TRAVIS_TAG:-local}"
SHA512_CMD="${SHA512_CMD:-sha512sum}"
DELIVERABLE="${DELIVERABLE:-n3dr}"

validate(){
if [ -z "$TOOL" ]; then
if [ -z "${TOOL}" ]; then
echo "No deliverable defined. Assuming that 'go run main.go'
should be run."
TOOL="go run main.go"
Expand Down Expand Up @@ -53,7 +54,8 @@ password(){
artifact(){
mkdir -p "maven-releases/file${1}/file${1}/1.0.0"
echo someContent > "maven-releases/file${1}/file${1}/1.0.0/file${1}-1.0.0.jar"
echo -e "<project>\n<modelVersion>4.0.0</modelVersion>\n<groupId>file${1}</groupId>\n<artifactId>file${1}</artifactId>\n<version>1.0.0</version>\n</project>" > "maven-releases/file${1}/file${1}/1.0.0/file${1}-1.0.0.pom"
echo someContentZIP > "maven-releases/file${1}/file${1}/1.0.0/file${1}-1.0.0.zip"
echo -e "<project>\n<modelVersion>4.0.0</modelVersion>\n<groupId>file${1}</groupId>\n<artifactId>file${1}</artifactId>\n<version>1.0.0</version>\n</project>" > "maven-releases/file${1}/file${1}/1.0.0/file${1}-1.0.0.pom"
}

files(){
Expand All @@ -72,11 +74,11 @@ backup(){
$TOOL backup -n http://localhost:9999 -u admin -p $PASSWORD -r maven-releases -v "${NEXUS_API_VERSION}" -z

if [ "${NEXUS_VERSION}" == "3.9.0" ]; then
count_downloads 20
test_zip 12
else
count_downloads 30
test_zip 16
else
count_downloads 40
test_zip 20
fi

cleanup_downloads
Expand All @@ -92,11 +94,11 @@ repositories(){
$cmd -b -z

if [ "${NEXUS_VERSION}" == "3.9.0" ]; then
count_downloads 40
test_zip 24
else
count_downloads 60
test_zip 32
test_zip 28
else
count_downloads 80
test_zip 36
fi

cleanup_downloads
Expand Down

0 comments on commit 4e36ef9

Please sign in to comment.