Skip to content

Commit

Permalink
Improve repositores code
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Sverdlov <[email protected]>
  • Loading branch information
sverdlov93 committed Nov 6, 2024
1 parent f280aa5 commit ecb74bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions artifactory/commands/buildtoollogin/buildtoollogin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,14 @@ func TestBuildToolLoginCommand_Pipenv(t *testing.T) {
}

func testBuildToolLoginCommandPip(t *testing.T, buildTool project.ProjectType) {
// Retrieve the home directory and construct the pip.conf file path.
homeDir, err := os.UserHomeDir()
assert.NoError(t, err)

var pipConfFilePath string
if coreutils.IsWindows() {
pipConfFilePath = filepath.Join(homeDir, "pip", "pip.ini")
pipConfFilePath = filepath.Join(os.Getenv("APPDATA"), "pip", "pip.ini")
} else {
// Retrieve the home directory and construct the pip.conf file path.
homeDir, err := os.UserHomeDir()
assert.NoError(t, err)
pipConfFilePath = filepath.Join(homeDir, ".config", "pip", "pip.conf")
}

Expand Down
9 changes: 5 additions & 4 deletions artifactory/commands/utils/npmcmdutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,15 @@ func GetNpmRepositoryUrl(repositoryName, artifactoryUrl string) string {

// GetNpmAuthKeyValue generates the correct authentication key and value for npm or Yarn, based on the repo URL.
func GetNpmAuthKeyValue(serverDetails *config.ServerDetails, repoUrl string) (key, value string) {
keySuffix := ""
if serverDetails.GetAccessToken() != "" {
var keySuffix string
switch {
case serverDetails.GetAccessToken() != "":
keySuffix = NpmConfigAuthTokenKey
value = serverDetails.GetAccessToken()
} else if serverDetails.GetUser() != "" && serverDetails.GetPassword() != "" {
case serverDetails.GetUser() != "" && serverDetails.GetPassword() != "":
keySuffix = NpmConfigAuthKey
value = basicAuthBase64Encode(serverDetails.GetUser(), serverDetails.GetPassword())
} else {
default:
return "", ""
}

Expand Down

0 comments on commit ecb74bb

Please sign in to comment.