Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
feature/queue-with-rpc - new flags, new features
Browse files Browse the repository at this point in the history
  • Loading branch information
MindHunter86 committed Dec 13, 2021
1 parent 1f8c4c6 commit 50bc973
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
8 changes: 7 additions & 1 deletion cloner/cloner.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func NewCloner(l *zerolog.Logger) *Cloner {
func (m *Cloner) Bootstrap(ctx *cli.Context) error {
gCli = ctx

// !!
if strings.ToLower(gCli.String("loglevel")) == "debug" {
gIsDebug = true
}
Expand Down Expand Up @@ -234,8 +235,13 @@ func (m *Cloner) getMissingAssetsRPC(srcCollection, dstCollection []NexusAsset2)
dstAssets[asset.getHumanReadbleName()] = asset
}

var reg string = "((maven-metadata\\.xml)|\\.(md5|sha1|sha256|sha512))$"
if gCli.Bool("skip-pom-upload") {
reg = "((maven-metadata\\.xml)|\\.(pom|md5|sha1|sha256|sha512))$"
}

for _, asset := range srcCollection {
if matched, _ := regexp.MatchString("((maven-metadata\\.xml)|\\.(pom|md5|sha1|sha256|sha512))$", asset.getHumanReadbleName()); matched {
if matched, _ := regexp.MatchString(reg, asset.getHumanReadbleName()); matched {
gLog.Debug().Msgf("The asset %s will be skipped!", asset.getHumanReadbleName())
continue
}
Expand Down
7 changes: 6 additions & 1 deletion cloner/nexus.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ func (m *nexus) parseRepositoryAssetsRPC(rsp *rpcRsp) (e error) {
payload: []interface{}{m, obj["id"].(string)},
})
case "asset":
if matched, _ := regexp.MatchString("((maven-metadata\\.xml)|\\.(pom|md5|sha1|sha256|sha512))$", obj["id"].(string)); matched {
var reg string = "((maven-metadata\\.xml)|\\.(md5|sha1|sha256|sha512))$"
if gCli.Bool("skip-pom-upload") {
reg = "((maven-metadata\\.xml)|\\.(pom|md5|sha1|sha256|sha512))$"
}

if matched, _ := regexp.MatchString(reg, obj["id"].(string)); matched {
gLog.Debug().Msgf("The asset %s will be skipped!", obj["id"].(string))
continue
}
Expand Down
12 changes: 8 additions & 4 deletions cloner/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,15 @@ func (m *rpcAsset) getDownloadUrl(reponame string, baseurl *url.URL) (data strin
return
}

buf := strings.Split(drl.String(), "/")
bufLen := len(buf)
gLog.Debug().Msg("[DOWNLAODURL] parsed version - " + buf[bufLen-2])
if gCli.Bool("maven-snapshots") {
buf := strings.Split(drl.String(), "/")
bufLen := len(buf)
gLog.Debug().Msg("[DOWNLOADURL] parsed version - " + buf[bufLen-2])

data = strings.ReplaceAll(drl.String(), buf[bufLen-2]+"/", "")
data = strings.ReplaceAll(drl.String(), buf[bufLen-2]+"/", "")
}

data = drl.String()
gLog.Debug().Msg("Download URL - " + data)
// https://HOST/repository/maven-ums/ru/mts/tvhouse/tvh-core/1.0-M1-20181002.132713-41/tvh-core-1.0-M1-20181002.132713-41-sources.log
}
Expand Down
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ func main() {
Name: "skip-upload",
Usage: "Skip upload after downloading missing assets. Flag for debugging only.",
},
cli.BoolFlag{
Name: "skip-pom-upload",
Usage: "",
},
cli.BoolFlag{
Name: "maven-snapshots",
Usage: "",
},
cli.StringFlag{
Name: "path-filter",
Usage: "Regexp value with `path` for syncing.",
Expand Down

0 comments on commit 50bc973

Please sign in to comment.