Skip to content

Commit

Permalink
Merge pull request #51 from 030/gh50-broken-repositories-command
Browse files Browse the repository at this point in the history
[GH-50] broken repository subcommands due to authentication request o…
  • Loading branch information
030 authored May 20, 2019
2 parents 4e0a580 + 8bb71fd commit 003adb2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [2.2.1] - 2019-05-20
### Fixed
- Broken repositories subcommands due to omission of authentication request.

## [2.2.0] - 2019-05-20
### Added
- Password lookup using viper.
Expand Down Expand Up @@ -64,7 +69,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Download all artifacts from a certain Nexus3 repository.

[Unreleased]: https://github.com/030/n3dr/compare/2.2.0...HEAD
[Unreleased]: https://github.com/030/n3dr/compare/2.2.1...HEAD
[2.2.1]: https://github.com/030/n3dr/compare/2.2.0...2.2.1
[2.2.0]: https://github.com/030/n3dr/compare/2.1.1...2.2.0
[2.1.1]: https://github.com/030/n3dr/compare/2.1.0...2.1.1
[2.1.0]: https://github.com/030/n3dr/compare/2.0.0...2.1.0
Expand Down
9 changes: 7 additions & 2 deletions cli/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ package cli
import (
"fmt"
"io/ioutil"
"log"
"net/http"

log "github.com/sirupsen/logrus"

"github.com/thedevsaddam/gojsonq"
)

func (n Nexus3) repositories() string {
// Generated by curl-to-Go: https://mholt.github.io/curl-to-go

log.Info("Consult repositories URL: " + n.URL)
req, err := http.NewRequest("GET", n.URL+"/service/rest/v1/repositories", nil)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Accept", "application/json")
req.SetBasicAuth(n.User, n.Pass)

resp, err := http.DefaultClient.Do(req)
if err != nil {
Expand All @@ -31,6 +33,9 @@ func (n Nexus3) repositories() string {
log.Fatal(err)
}
bodyString = string(bodyBytes)
if bodyString == "[ ]" {
log.Fatal("Bodystring should not be empty. Did the authentication to '" + n.URL + "' succeed?")
}
}
return bodyString
}
Expand Down
1 change: 0 additions & 1 deletion cmd/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ download artifacts from all repositories`,
n.CountRepositories()
}
if download {
n := cli.Nexus3{URL: n3drURL, User: n3drUser, Pass: pw}
err := n.Downloads()
if err != nil {
log.Fatal(err)
Expand Down

0 comments on commit 003adb2

Please sign in to comment.