-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolves #13629 Add RegistryAuthHeader to manifest push #13653
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,13 +162,35 @@ func ManifestAdd(w http.ResponseWriter, r *http.Request) { | |
// Wrapper to support 3.x with 4.x libpod | ||
query := struct { | ||
entities.ManifestAddOptions | ||
Images []string | ||
Images []string | ||
TLSVerify bool `schema:"tlsVerify"` | ||
}{} | ||
if err := json.NewDecoder(r.Body).Decode(&query); err != nil { | ||
utils.Error(w, http.StatusInternalServerError, errors.Wrap(err, "Decode()")) | ||
return | ||
} | ||
|
||
authconf, authfile, err := auth.GetCredentials(r) | ||
if err != nil { | ||
utils.Error(w, http.StatusBadRequest, err) | ||
return | ||
} | ||
defer auth.RemoveAuthfile(authfile) | ||
var username, password string | ||
if authconf != nil { | ||
username = authconf.Username | ||
password = authconf.Password | ||
} | ||
query.ManifestAddOptions.Authfile = authfile | ||
query.ManifestAddOptions.Username = username | ||
query.ManifestAddOptions.Password = password | ||
if sys := runtime.SystemContext(); sys != nil { | ||
query.ManifestAddOptions.CertDir = sys.DockerCertPath | ||
} | ||
if _, found := r.URL.Query()["tlsVerify"]; found { | ||
query.SkipTLSVerify = types.NewOptionalBool(!query.TLSVerify) | ||
} | ||
|
||
name := utils.GetName(r) | ||
if _, err := runtime.LibimageRuntime().LookupManifestList(name); err != nil { | ||
utils.Error(w, http.StatusNotFound, err) | ||
|
@@ -271,7 +293,7 @@ func ManifestPushV3(w http.ResponseWriter, r *http.Request) { | |
utils.Error(w, http.StatusBadRequest, errors.Wrapf(err, "error pushing image %q", query.Destination)) | ||
return | ||
} | ||
utils.WriteResponse(w, http.StatusOK, digest) | ||
utils.WriteResponse(w, http.StatusOK, handlers.IDResponse{ID: digest}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! Aligns with swagger now. |
||
} | ||
|
||
// ManifestPush push image to registry | ||
|
@@ -350,6 +372,24 @@ func ManifestModify(w http.ResponseWriter, r *http.Request) { | |
return | ||
} | ||
|
||
authconf, authfile, err := auth.GetCredentials(r) | ||
if err != nil { | ||
utils.Error(w, http.StatusBadRequest, err) | ||
return | ||
} | ||
defer auth.RemoveAuthfile(authfile) | ||
var username, password string | ||
if authconf != nil { | ||
username = authconf.Username | ||
password = authconf.Password | ||
} | ||
body.ManifestAddOptions.Authfile = authfile | ||
body.ManifestAddOptions.Username = username | ||
body.ManifestAddOptions.Password = password | ||
if sys := runtime.SystemContext(); sys != nil { | ||
body.ManifestAddOptions.CertDir = sys.DockerCertPath | ||
} | ||
|
||
var report entities.ManifestModifyReport | ||
switch { | ||
case strings.EqualFold("update", body.Operation): | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way to do this?