You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
return"", fmt.Errorf("failed to build RSA key request: %w", err)
124
+
return"", errorutils.CheckErrorf("failed to build RSA key request: %w", err)
124
125
}
125
-
req.SetBasicAuth(creds.Username, creds.Password)
126
+
req.SetBasicAuth(username, password)
126
127
127
128
resp, err:=http.DefaultClient.Do(req)
128
129
iferr!=nil {
129
-
return"", fmt.Errorf("failed to download RSA key from Artifactory: %w", err)
130
+
return"", errorutils.CheckErrorf("failed to download RSA key from Artifactory: %w", err)
130
131
}
131
132
deferresp.Body.Close()
132
133
133
134
switchresp.StatusCode {
134
135
casehttp.StatusOK:
135
136
casehttp.StatusNotFound:
136
-
return"", fmt.Errorf("[WARN] No RSA key configured for %q. Use --allow-untrusted or configure a signing key in Artifactory", endpoint)
137
+
return"", errorutils.CheckErrorf("no RSA key configured for %q. Use --allow-untrusted or configure a signing key in Artifactory", endpoint)
137
138
casehttp.StatusUnauthorized:
138
-
return"", fmt.Errorf("[ERROR] Access token expired or invalid. Run: jf c add")
139
+
return"", errorutils.CheckErrorf("access token expired or invalid. Run: jf c add")
139
140
casehttp.StatusForbidden:
140
-
return"", fmt.Errorf("[ERROR] Access token lacks read permission on the repository")
141
+
return"", errorutils.CheckErrorf("access token lacks read permission on the repository")
141
142
default:
142
-
return"", fmt.Errorf("unexpected HTTP %d from Artifactory RSA key endpoint", resp.StatusCode)
143
+
return"", errorutils.CheckErrorf("unexpected HTTP %d from Artifactory RSA key endpoint", resp.StatusCode)
143
144
}
144
145
145
146
body, err:=io.ReadAll(resp.Body)
146
147
iferr!=nil {
147
-
return"", fmt.Errorf("failed to read RSA key response body: %w", err)
148
+
return"", errorutils.CheckErrorf("failed to read RSA key response body: %w", err)
148
149
}
149
150
150
151
pem:=string(body)
151
152
if!strings.Contains(pem, "BEGIN PUBLIC KEY") {
152
-
return"", fmt.Errorf("Artifactory returned an unexpected response for the RSA key endpoint (does the repo have a signing keypair configured?)")
153
+
return"", errorutils.CheckErrorf("Artifactory returned an unexpected response for the RSA key endpoint (does the repo have a signing keypair configured?)")
0 commit comments