Skip to content

Commit e8f884c

Browse files
committed
Improve repositores code
Signed-off-by: Michael Sverdlov <[email protected]>
1 parent 265fea7 commit e8f884c

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

artifactory/commands/buildtoollogin/buildtoollogin.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ func buildToolToPackageType(buildTool project.ProjectType) (string, error) {
4646
return repository.Npm, nil
4747
case project.Pip, project.Pipenv, project.Poetry:
4848
return repository.Pypi, nil
49+
case project.Go:
50+
return repository.Go, nil
4951
default:
5052
return "", errorutils.CheckError(fmt.Errorf("unsupported build tool: %s", buildTool))
5153
}
@@ -69,9 +71,9 @@ func (btlc *BuildToolLoginCommand) ServerDetails() (*config.ServerDetails, error
6971

7072
// Run executes the configuration method corresponding to the project type specified for the command.
7173
func (btlc *BuildToolLoginCommand) Run() (err error) {
72-
// Prompt the user to select a repository if none has been specified.
7374
if btlc.repoName == "" {
74-
if err = btlc.SetVirtualRepoNameInteractively(); err != nil {
75+
// Prompt the user to select a virtual repository that matches the project type.
76+
if err = btlc.GetRepositoryNameFromUserInteractively(); err != nil {
7577
return err
7678
}
7779
}
@@ -99,8 +101,8 @@ func (btlc *BuildToolLoginCommand) Run() (err error) {
99101
return nil
100102
}
101103

102-
// SetVirtualRepoNameInteractively prompts the user to select a compatible virtual repository.
103-
func (btlc *BuildToolLoginCommand) SetVirtualRepoNameInteractively() error {
104+
// GetRepositoryNameFromUserInteractively prompts the user to select a compatible virtual repository.
105+
func (btlc *BuildToolLoginCommand) GetRepositoryNameFromUserInteractively() error {
104106
// Map the build tool to its corresponding package type.
105107
packageType, err := buildToolToPackageType(btlc.buildTool)
106108
if err != nil {

artifactory/commands/buildtoollogin/buildtoollogin_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ var testCases = []struct {
4444
func createTestBuildToolLoginCommand(buildTool project.ProjectType) *BuildToolLoginCommand {
4545
cmd := NewBuildToolLoginCommand(buildTool)
4646
cmd.repoName = "test-repo"
47-
cmd.serverDetails = &config.ServerDetails{ArtifactoryUrl: "https://acme.jfrog.io/artifactory"}
47+
dummyUrl := "https://acme.jfrog.io"
48+
cmd.serverDetails = &config.ServerDetails{Url: dummyUrl, ArtifactoryUrl: dummyUrl + "/artifactory"}
4849

4950
return cmd
5051
}

0 commit comments

Comments
 (0)