Skip to content

Commit

Permalink
Improve repositores code
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Sverdlov <michaelsv@jfrog.com>
  • Loading branch information
sverdlov93 committed Nov 7, 2024
1 parent 2ee5950 commit aec982a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions artifactory/commands/buildtoollogin/buildtoollogin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package buildtoollogin
import (
"fmt"
biutils "github.com/jfrog/build-info-go/utils"
gocommands "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/golang"
pythoncommands "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/python"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/repository"
commandsutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils"
Expand All @@ -11,7 +12,6 @@ import (
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/yarn"
"github.com/jfrog/jfrog-cli-core/v2/common/project"
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
goutils "github.com/jfrog/jfrog-cli-core/v2/utils/golang"
"github.com/jfrog/jfrog-client-go/artifactory/services"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
"github.com/jfrog/jfrog-client-go/utils/log"
Expand Down Expand Up @@ -200,7 +200,7 @@ func (btlc *BuildToolLoginCommand) configureYarn() error {
//
// go env -w GOPROXY=https://<user>:<token>@<your-artifactory-url>/artifactory/go/<repo-name>,direct
func (btlc *BuildToolLoginCommand) configureGo() error {
repoWithCredsUrl, err := goutils.GetArtifactoryRemoteRepoUrl(btlc.serverDetails, btlc.repoName, goutils.GoProxyUrlParams{Direct: true})
repoWithCredsUrl, err := gocommands.GetArtifactoryRemoteRepoUrl(btlc.serverDetails, btlc.repoName, gocommands.GoProxyUrlParams{Direct: true})
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions artifactory/commands/golang/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (gc *GoCommand) run() (err error) {
return
}
// If noFallback=false, missing packages will be fetched directly from VCS
repoUrl, err := getArtifactoryRemoteRepoUrl(resolverDetails, gc.resolverParams.TargetRepo(), GoProxyUrlParams{Direct: !gc.noFallback})
repoUrl, err := GetArtifactoryRemoteRepoUrl(resolverDetails, gc.resolverParams.TargetRepo(), GoProxyUrlParams{Direct: !gc.noFallback})
if err != nil {
return
}
Expand Down Expand Up @@ -336,7 +336,7 @@ func SetArtifactoryAsResolutionServer(serverDetails *config.ServerDetails, depsR
}

func setGoProxy(server *config.ServerDetails, remoteGoRepo string, goProxyParams GoProxyUrlParams) error {
repoUrl, err := getArtifactoryRemoteRepoUrl(server, remoteGoRepo, goProxyParams)
repoUrl, err := GetArtifactoryRemoteRepoUrl(server, remoteGoRepo, goProxyParams)
if err != nil {
return err
}
Expand Down Expand Up @@ -380,7 +380,7 @@ func (gdu *GoProxyUrlParams) addDirect(url string) string {
return url
}

func getArtifactoryRemoteRepoUrl(serverDetails *config.ServerDetails, repo string, goProxyParams GoProxyUrlParams) (string, error) {
func GetArtifactoryRemoteRepoUrl(serverDetails *config.ServerDetails, repo string, goProxyParams GoProxyUrlParams) (string, error) {
authServerDetails, err := serverDetails.CreateArtAuthConfig()
if err != nil {
return "", err
Expand Down
2 changes: 1 addition & 1 deletion artifactory/commands/golang/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestGetArtifactoryRemoteRepoUrl(t *testing.T) {
AccessToken: "eyJ0eXAiOiJKV1QifQ.eyJzdWIiOiJmYWtlXC91c2Vyc1wvdGVzdCJ9.MTIzNDU2Nzg5MA",
}
repoName := "test-repo"
repoUrl, err := getArtifactoryRemoteRepoUrl(server, repoName, GoProxyUrlParams{})
repoUrl, err := GetArtifactoryRemoteRepoUrl(server, repoName, GoProxyUrlParams{})
assert.NoError(t, err)
assert.Equal(t, "https://test:eyJ0eXAiOiJKV1QifQ.eyJzdWIiOiJmYWtlXC91c2Vyc1wvdGVzdCJ9.MTIzNDU2Nzg5MA@server.com/artifactory/api/go/test-repo", repoUrl)
}
Expand Down
5 changes: 2 additions & 3 deletions artifactory/utils/npm/config-delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package npm

import (
gofrogcmd "github.com/jfrog/gofrog/io"
npmutils "github.com/jfrog/jfrog-cli-core/v2/utils/npm"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
)

Expand All @@ -15,8 +14,8 @@ func ConfigDelete(key, executablePath string) error {
return nil
}

func createConfigDeleteCmdConfig(executablePath, key string) *npmutils.NpmConfig {
return &npmutils.NpmConfig{
func createConfigDeleteCmdConfig(executablePath, key string) *NpmConfig {
return &NpmConfig{
Npm: executablePath,
Command: []string{"config", "delete", key},
StrWriter: nil,
Expand Down
5 changes: 2 additions & 3 deletions artifactory/utils/npm/config-set.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package npm

import (
gofrogcmd "github.com/jfrog/gofrog/io"
npmutils "github.com/jfrog/jfrog-cli-core/v2/utils/npm"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
)

Expand All @@ -15,8 +14,8 @@ func ConfigSet(key, value, executablePath string) error {
return nil
}

func createConfigSetCmdConfig(executablePath, key, value string) *npmutils.NpmConfig {
return &npmutils.NpmConfig{
func createConfigSetCmdConfig(executablePath, key, value string) *NpmConfig {
return &NpmConfig{
Npm: executablePath,
Command: []string{"config", "set", key, value},
StrWriter: nil,
Expand Down

0 comments on commit aec982a

Please sign in to comment.