Skip to content

Commit

Permalink
Publish only on demand the missing dependencies (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeiVainshtein authored Mar 31, 2019
1 parent 2debc22 commit 138ff67
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ func RecursivePublish(targetRepo, goModEditMessage string, serviceManager *artif
return executers.RecursivePublish(targetRepo, goModEditMessage, serviceManager)
}

func RunWithFallbacksAndPublish(goArg []string, targetRepo string, noRegistry bool, serviceManager *artifactory.ArtifactoryServicesManager) error {
return executers.RunWithFallbacksAndPublish(goArg, targetRepo, noRegistry, serviceManager)
func RunWithFallbacksAndPublish(goArg []string, targetRepo string, noRegistry, publishDeps bool, serviceManager *artifactory.ArtifactoryServicesManager) error {
return executers.RunWithFallbacksAndPublish(goArg, targetRepo, noRegistry, publishDeps, serviceManager)
}

func RunWithFallback(goArg []string, url string) error {
Expand Down
11 changes: 7 additions & 4 deletions executers/dependenciesutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (
)

// Resolve artifacts from VCS and publish the missing artifacts to Artifactory
func collectDependenciesAndPublish(targetRepo string, failOnError bool, dependenciesInterface GoPackage, serviceManager *artifactory.ArtifactoryServicesManager) error {
func collectDependenciesAndPublish(targetRepo string, failOnError, publishDeps bool, dependenciesInterface GoPackage, serviceManager *artifactory.ArtifactoryServicesManager) error {
rootProjectDir, err := cmd.GetProjectRoot()
if err != nil {
return err
Expand All @@ -48,9 +48,12 @@ func collectDependenciesAndPublish(targetRepo string, failOnError bool, dependen
}
log.Error("Received an error retrieving project dependencies:", err)
}
err = populateAndPublish(targetRepo, cachePath, dependenciesInterface, packageDependencies, &cache, serviceManager)
if err != nil {
return err

if publishDeps {
err = populateAndPublish(targetRepo, cachePath, dependenciesInterface, packageDependencies, &cache, serviceManager)
if err != nil {
return err
}
}
utils.LogFinishedMsg(&cache)
return nil
Expand Down
4 changes: 2 additions & 2 deletions executers/fallbackandpublish.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

// Runs Go, with multiple fallbacks if needed and publish missing dependencies to Artifactory
func RunWithFallbacksAndPublish(goArg []string, targetRepo string, noRegistry bool, serviceManager *artifactory.ArtifactoryServicesManager) error {
func RunWithFallbacksAndPublish(goArg []string, targetRepo string, noRegistry, publishDeps bool, serviceManager *artifactory.ArtifactoryServicesManager) error {
if !noRegistry {
artDetails := serviceManager.GetConfig().GetArtDetails()
err := utils.SetGoProxyWithApi(targetRepo, artDetails)
Expand All @@ -28,7 +28,7 @@ func RunWithFallbacksAndPublish(goArg []string, targetRepo string, noRegistry bo
return err
}

err = collectDependenciesAndPublish(targetRepo, true, &Package{}, serviceManager)
err = collectDependenciesAndPublish(targetRepo, true, publishDeps, &Package{}, serviceManager)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion executers/populateandpublish.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func RecursivePublish(targetRepo, goModEditMessage string, serviceManager *artif
if err != nil {
return err
}
collectDependenciesAndPublish(targetRepo, false, pwd, serviceManager)
collectDependenciesAndPublish(targetRepo, false, true, pwd, serviceManager)
return nil
}

Expand Down

0 comments on commit 138ff67

Please sign in to comment.