Skip to content

Commit

Permalink
fix: [#384] Create groups.
Browse files Browse the repository at this point in the history
  • Loading branch information
030 committed Nov 19, 2023
1 parent e66a0bd commit b66c70c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions cmd/n3dr/configRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ Examples:
# Create a Rubygems repository:
n3dr configRepository -u admin -p some-pass -n localhost:9000 --https=false --configRepoName 3rdparty-rubygems --configRepoType gem
# Create a Maven2 proxy:
# Create Maven2 proxies:
n3dr configRepository --configRepoType maven2 --configRepoName 3rdparty-maven --configRepoRecipe proxy --configRepoProxyURL https://repo.maven.apache.org/maven2/
n3dr configRepository --configRepoType maven2 --configRepoName 3rdparty-maven-gradle-plugins --configRepoRecipe proxy --configRepoProxyURL https://plugins.gradle.org/m2/
# Create a NPM proxy:
n3dr configRepository --configRepoType npm --configRepoName 3rdparty-npm --configRepoRecipe proxy --configRepoProxyURL https://registry.npmjs.org/
Expand Down Expand Up @@ -178,10 +179,12 @@ Examples:

if configRepoRecipe == "proxy" && configRepoProxyURL == "" {
log.Fatal("configRepoProxyURL should not be empty")

} else {
rr.ProxyRemoteURL = configRepoProxyURL
log.Infof("configRepoProxyURL has been set to: '%s'", rr.ProxyRemoteURL)
}

log.Infof("creating repo: '%s' of type: '%s'", configRepoName, configRepoType)
r := repo{conn: rr, kind: configRepoType, name: configRepoName, recipe: configRepoRecipe, snapshot: snapshot}
if err := r.createByType(); err != nil {
log.Fatalf("repo not created. Error: '%v'", err)
Expand Down
8 changes: 4 additions & 4 deletions internal/app/n3dr/config/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ func (r *Repository) CreateMavenProxied(name string) error {
if err != nil {
return err
}
if name == "" {
return fmt.Errorf("repo name should not be empty")
remoteURL := r.ProxyRemoteURL
log.Infof("remoteURL: '%s'", remoteURL)
if name == "" || remoteURL == "" {
return fmt.Errorf("repo name of proxy url should not be empty")
}

httpClientBlocked := false
Expand All @@ -193,8 +195,6 @@ func (r *Repository) CreateMavenProxied(name string) error {
negativeCache := models.NegativeCacheAttributes{Enabled: &negativeCacheEnabled, TimeToLive: &negativeCacheTimeToLive}
var contentMaxAge int32 = 1440
var metadataMaxAge int32 = 1440
remoteURL := r.ProxyRemoteURL
log.Infof("remoteURL: '%s'", remoteURL)
proxy := models.ProxyAttributes{ContentMaxAge: &contentMaxAge, MetadataMaxAge: &metadataMaxAge, RemoteURL: remoteURL}
online := true
maven := models.MavenAttributes{LayoutPolicy: "STRICT", VersionPolicy: "MIXED"}
Expand Down

0 comments on commit b66c70c

Please sign in to comment.