Skip to content

Commit a82f79e

Browse files
committed
Added hints in errors message on possible causes of 403 status for docker push
1 parent 5f4344d commit a82f79e

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

artifactory/utils/container/image.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package container
33
import (
44
"net/http"
55
"path"
6+
"strconv"
67
"strings"
78

89
"github.com/jfrog/jfrog-client-go/artifactory"
@@ -152,6 +153,9 @@ func (image *Image) GetRemoteRepo(serviceManager artifactory.ArtifactoryServices
152153
if err != nil {
153154
return "", err
154155
}
156+
if resp.StatusCode == http.StatusForbidden {
157+
return "", errorutils.CheckErrorf(getStatusForbiddenErrorMessage())
158+
}
155159
if resp.StatusCode != http.StatusOK {
156160
return "", errorutils.CheckErrorf("error while getting docker repository name. Artifactory response: " + resp.Status)
157161
}
@@ -169,3 +173,10 @@ func buildRequestUrl(longImageName, imageTag, containerRegistryUrl string, https
169173
}
170174
return "http://" + endpoint
171175
}
176+
177+
func getStatusForbiddenErrorMessage() string {
178+
errorMessage := "error while getting docker repository name. Artifactory response: " + strconv.Itoa(http.StatusForbidden) +
179+
", Possible causes include: \n- Xray scan in progress \n- Xray policy violations \n- insufficient permissions\n- invalid authentication method\n- disabled anonymous access\n- missing Docker manifests." +
180+
"\nPlease verify the above factors to resolve the issue."
181+
return errorMessage
182+
}

plugins/common/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
coreConfig "github.com/jfrog/jfrog-cli-core/v2/utils/config"
1111
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
1212
clientutils "github.com/jfrog/jfrog-client-go/utils"
13-
"os"
1413
"github.com/jfrog/jfrog-client-go/utils/errorutils"
1514
"github.com/jfrog/jfrog-client-go/utils/io/content"
15+
"os"
1616
"sort"
1717
"strconv"
1818
"strings"

utils/coreutils/coreconsts.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ var (
6767
HomeDir = "JFROG_CLI_HOME_DIR"
6868
BuildName = "JFROG_CLI_BUILD_NAME"
6969
BuildNumber = "JFROG_CLI_BUILD_NUMBER"
70-
BuildUrl = "JFROG_CLI_BUILD_URL"
71-
EnvExclude = "JFROG_CLI_ENV_EXCLUDE"
70+
BuildUrl = "JFROG_CLI_BUILD_URL"
71+
EnvExclude = "JFROG_CLI_ENV_EXCLUDE"
7272
Project = "JFROG_CLI_BUILD_PROJECT"
7373
ApplicationKey = "JFROG_CLI_APPLICATION_KEY"
7474
SourceCodeRepository = "JFROG_CLI_SOURCECODE_REPOSITORY"

0 commit comments

Comments
 (0)