Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into update_build_info_go…
Browse files Browse the repository at this point in the history
…_dotnet
  • Loading branch information
attiasas committed Feb 18, 2024
2 parents 01d9849 + 40b1646 commit a5f53a6
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 121 deletions.
7 changes: 2 additions & 5 deletions artifactory/utils/repositoryutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,13 @@ func GetRepositories(artDetails *config.ServerDetails, repoTypes ...RepoType) ([
if err != nil {
return nil, err
}
if len(repoTypes) == 0 {
return GetFilteredRepositoriesByName(sm, nil, nil)
}
repos := []string{}
for _, repoType := range repoTypes {
repoKey, err := GetFilteredRepositoriesByNameAndType(sm, nil, nil, repoType)
filteredRepos, err := GetFilteredRepositoriesByNameAndType(sm, nil, nil, repoType)
if err != nil {
return repos, err
}
repos = append(repos, repoKey...)
repos = append(repos, filteredRepos...)
}

return repos, nil
Expand Down
129 changes: 53 additions & 76 deletions common/commands/configfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,27 +152,23 @@ func handleInteractiveConfigCreation(configFile *ConfigFile, confType project.Pr
}
switch confType {
case project.Go:
err = configFile.configGo()
case project.Pip:
err = configFile.configPip()
case project.Pipenv:
err = configFile.configPipenv()
case project.Poetry:
err = configFile.configPoetry()
return configFile.setDeployerResolver()
case project.Pip, project.Pipenv, project.Poetry:
return configFile.setResolver(false)
case project.Yarn:
err = configFile.configYarn()
return configFile.setResolver(false)
case project.Npm:
err = configFile.configNpm()
return configFile.setDeployerResolver()
case project.Nuget, project.Dotnet:
err = configFile.configDotnet()
return configFile.configDotnet()
case project.Maven:
err = configFile.configMaven()
return configFile.configMaven()
case project.Gradle:
err = configFile.configGradle()
return configFile.configGradle()
case project.Terraform:
err = configFile.configTerraform()
return configFile.setResolver(false)
}
return errorutils.CheckError(err)
return
}

func writeConfigFile(configFile *ConfigFile, destination string) (err error) {
Expand Down Expand Up @@ -394,32 +390,8 @@ func (configFile *ConfigFile) VerifyConfigFile(configFilePath string) error {
return errorutils.CheckError(os.Remove(configFilePath))
}

func (configFile *ConfigFile) configGo() error {
return configFile.setDeployerResolver()
}

func (configFile *ConfigFile) configPip() error {
return configFile.setResolver()
}

func (configFile *ConfigFile) configPipenv() error {
return configFile.setResolver()
}

func (configFile *ConfigFile) configPoetry() error {
return configFile.setResolver()
}

func (configFile *ConfigFile) configYarn() error {
return configFile.setResolver()
}

func (configFile *ConfigFile) configNpm() error {
return configFile.setDeployerResolver()
}

func (configFile *ConfigFile) configDotnet() error {
if err := configFile.setResolver(); err != nil {
if err := configFile.setResolver(false); err != nil {
return err
}
if configFile.Resolver.ServerId != "" {
Expand All @@ -429,21 +401,10 @@ func (configFile *ConfigFile) configDotnet() error {
}

func (configFile *ConfigFile) configMaven() error {
// Set resolution repositories
if err := configFile.setResolverId(); err != nil {
return err
}
if configFile.Resolver.ServerId != "" {
configFile.setRepo(&configFile.Resolver.ReleaseRepo, "Set resolution repository for release dependencies", configFile.Resolver.ServerId, utils.Remote)
configFile.setRepo(&configFile.Resolver.SnapshotRepo, "Set resolution repository for snapshot dependencies", configFile.Resolver.ServerId, utils.Remote)
}
// Set deployment repositories
if err := configFile.setDeployerId(); err != nil {
if err := configFile.setDeployerResolverWithSnapshot(); err != nil {
return err
}
if configFile.Deployer.ServerId != "" {
configFile.setRepo(&configFile.Deployer.ReleaseRepo, "Set repository for release artifacts deployment", configFile.Deployer.ServerId, utils.Local)
configFile.setRepo(&configFile.Deployer.SnapshotRepo, "Set repository for snapshot artifacts deployment", configFile.Deployer.ServerId, utils.Local)
configFile.setIncludeExcludePatterns()
}
configFile.UseWrapper = coreutils.AskYesNo("Use Maven wrapper?", true)
Expand Down Expand Up @@ -494,40 +455,65 @@ func (configFile *ConfigFile) readGradleGlobalConfig() {
configFile.UseWrapper = coreutils.AskYesNo("Use Gradle wrapper?", true)
}

func (configFile *ConfigFile) configTerraform() error {
return configFile.setDeployer()
}

func (configFile *ConfigFile) setDeployer() error {
func (configFile *ConfigFile) setDeployer(withSnapshot bool) error {
// Set deployer id
if err := configFile.setDeployerId(); err != nil {
return err
}

// Set deployment repository
if configFile.Deployer.ServerId != "" {
configFile.setRepo(&configFile.Deployer.Repo, "Set repository for artifacts deployment", configFile.Deployer.ServerId, utils.Local)
deployerRepos, err := getRepositories(configFile.Deployer.ServerId, utils.Virtual, utils.Local)
if err != nil {
log.Error("failed getting repositories list: " + err.Error())
// Continue without auto complete.
deployerRepos = []string{}
}
if withSnapshot {
configFile.setRepo(&configFile.Deployer.SnapshotRepo, "Set repository for release artifacts deployment", deployerRepos)
configFile.setRepo(&configFile.Deployer.SnapshotRepo, "Set repository for snapshot artifacts deployment", deployerRepos)
} else {
configFile.setRepo(&configFile.Deployer.Repo, "Set repository for artifacts deployment", deployerRepos)
}
}
return nil
}

func (configFile *ConfigFile) setResolver() error {
func (configFile *ConfigFile) setResolver(withSnapshot bool) error {
// Set resolver id
if err := configFile.setResolverId(); err != nil {
return err
}
// Set resolution repository
if configFile.Resolver.ServerId != "" {
configFile.setRepo(&configFile.Resolver.Repo, "Set repository for dependencies resolution", configFile.Resolver.ServerId, utils.Remote)
resolverRepos, err := getRepositories(configFile.Resolver.ServerId, utils.Virtual, utils.Remote)
if err != nil {
log.Error("failed getting repositories list: " + err.Error())
// Continue without auto complete.
resolverRepos = []string{}
}
if withSnapshot {
configFile.setRepo(&configFile.Resolver.SnapshotRepo, "Set resolution repository for release dependencies", resolverRepos)
configFile.setRepo(&configFile.Resolver.SnapshotRepo, "Set resolution repository for snapshot dependencies", resolverRepos)
} else {
configFile.setRepo(&configFile.Resolver.Repo, "Set resolution repository for dependencies resolution", resolverRepos)
}
}
return nil
}

func (configFile *ConfigFile) setDeployerResolver() error {
if err := configFile.setResolver(); err != nil {
if err := configFile.setResolver(false); err != nil {
return err
}
return configFile.setDeployer()
return configFile.setDeployer(false)
}

func (configFile *ConfigFile) setDeployerResolverWithSnapshot() error {
if err := configFile.setResolver(true); err != nil {
return err
}
return configFile.setDeployer(true)
}

func (configFile *ConfigFile) setResolverId() error {
Expand All @@ -544,9 +530,13 @@ func (configFile *ConfigFile) setServerId(serverId *string, useArtifactoryQuesti
return err
}

func (configFile *ConfigFile) setRepo(repo *string, message string, serverId string, repoType utils.RepoType) {
func (configFile *ConfigFile) setRepo(repo *string, promptPrefix string, availableRepos []string) {
if *repo == "" {
*repo = readRepo(message+ioutils.PressTabMsg, serverId, repoType, utils.Virtual)
if len(availableRepos) > 0 {
*repo = ioutils.AskFromListWithMismatchConfirmation(promptPrefix, "Repository not found.", ioutils.ConvertToSuggests(availableRepos))
} else {
*repo = ioutils.AskString("", promptPrefix, false, false)
}
}
}

Expand Down Expand Up @@ -635,19 +625,6 @@ func readArtifactoryServer(useArtifactoryQuestion string) (string, error) {
return ioutils.AskFromList("", "Set Artifactory server ID", false, ioutils.ConvertToSuggests(serversIds), defaultServer), nil
}

func readRepo(promptPrefix string, serverId string, repoTypes ...utils.RepoType) string {
availableRepos, err := getRepositories(serverId, repoTypes...)
if err != nil {
log.Error("failed getting repositories list: " + err.Error())
// Continue without auto complete.
availableRepos = []string{}
}
if len(availableRepos) > 0 {
return ioutils.AskFromListWithMismatchConfirmation(promptPrefix, "Repository not found.", ioutils.ConvertToSuggests(availableRepos))
}
return ioutils.AskString("", promptPrefix, false, false)
}

func getServersIdAndDefault() ([]string, string, error) {
allConfigs, err := config.GetAllServersConfigs()
if err != nil {
Expand Down
24 changes: 12 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ require (
github.com/chzyer/readline v1.5.1
github.com/forPelevin/gomoji v1.1.8
github.com/gocarina/gocsv v0.0.0-20231116093920-b87c2d0e983a
github.com/google/uuid v1.4.0
github.com/google/uuid v1.6.0
github.com/gookit/color v1.5.4
github.com/jedib0t/go-pretty/v6 v6.5.3
github.com/jedib0t/go-pretty/v6 v6.5.4
github.com/jfrog/build-info-go v1.9.21
github.com/jfrog/gofrog v1.5.1
github.com/jfrog/gofrog v1.6.0
github.com/jfrog/jfrog-client-go v1.36.0
github.com/magiconair/properties v1.8.7
github.com/manifoldco/promptui v0.9.0
Expand All @@ -22,10 +22,10 @@ require (
github.com/stretchr/testify v1.8.4
github.com/urfave/cli v1.22.14
github.com/vbauerster/mpb/v7 v7.5.3
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
golang.org/x/mod v0.14.0
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a
golang.org/x/mod v0.15.0
golang.org/x/sync v0.6.0
golang.org/x/term v0.16.0
golang.org/x/term v0.17.0
golang.org/x/text v0.14.0
gopkg.in/yaml.v3 v3.0.1
)
Expand All @@ -39,7 +39,7 @@ require (
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
Expand Down Expand Up @@ -88,15 +88,15 @@ require (
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/tools v0.17.0 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/tools v0.18.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
)

replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20240204105421-dd3f7041f3df
replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20240214141548-6691c4323f52

replace github.com/jfrog/build-info-go => github.com/attiasas/build-info-go v0.0.0-20240218080400-61fadad9deb8

Expand Down
Loading

0 comments on commit a5f53a6

Please sign in to comment.