Skip to content
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

Only attempt to mount for MountableLayer #401

Merged
merged 1 commit into from
Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions pkg/v1/remote/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,9 @@ func (w *writer) checkExistingManifest(h v1.Hash, mt types.MediaType) (bool, err
func (w *writer) initiateUpload(from, mount string) (location string, mounted bool, err error) {
u := w.url(fmt.Sprintf("/v2/%s/blobs/uploads/", w.ref.Context().RepositoryStr()))
uv := url.Values{}
if mount != "" {
if mount != "" && from != "" {
// Quay will fail if we specify a "mount" without a "from".
jonjohnsonjr marked this conversation as resolved.
Show resolved Hide resolved
uv["mount"] = []string{mount}
}
if from != "" {
uv["from"] = []string{from}
}
u.RawQuery = uv.Encode()
Expand Down
12 changes: 8 additions & 4 deletions pkg/v1/remote/write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ func TestInitiateUploadNoMountsExists(t *testing.T) {
expectedPath := fmt.Sprintf("/v2/%s/blobs/uploads/", expectedRepo)
expectedQuery := url.Values{
"mount": []string{h.String()},
"from": []string{"baz/bar"},
}.Encode()

w, closer, err := setupWriter(expectedRepo, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -248,7 +249,7 @@ func TestInitiateUploadNoMountsExists(t *testing.T) {
}
defer closer.Close()

_, mounted, err := w.initiateUpload("", h.String())
_, mounted, err := w.initiateUpload("baz/bar", h.String())
if err != nil {
t.Errorf("intiateUpload() = %v", err)
}
Expand All @@ -264,6 +265,7 @@ func TestInitiateUploadNoMountsInitiated(t *testing.T) {
expectedPath := fmt.Sprintf("/v2/%s/blobs/uploads/", expectedRepo)
expectedQuery := url.Values{
"mount": []string{h.String()},
"from": []string{"baz/bar"},
}.Encode()
expectedLocation := "https://somewhere.io/upload?foo=bar"

Expand All @@ -285,7 +287,7 @@ func TestInitiateUploadNoMountsInitiated(t *testing.T) {
}
defer closer.Close()

location, mounted, err := w.initiateUpload("", h.String())
location, mounted, err := w.initiateUpload("baz/bar", h.String())
if err != nil {
t.Errorf("intiateUpload() = %v", err)
}
Expand All @@ -304,6 +306,7 @@ func TestInitiateUploadNoMountsBadStatus(t *testing.T) {
expectedPath := fmt.Sprintf("/v2/%s/blobs/uploads/", expectedRepo)
expectedQuery := url.Values{
"mount": []string{h.String()},
"from": []string{"baz/bar"},
}.Encode()

w, closer, err := setupWriter(expectedRepo, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -323,7 +326,7 @@ func TestInitiateUploadNoMountsBadStatus(t *testing.T) {
}
defer closer.Close()

location, mounted, err := w.initiateUpload("", h.String())
location, mounted, err := w.initiateUpload("baz/bar", h.String())
if err == nil {
t.Errorf("intiateUpload() = %v, %v; wanted error", location, mounted)
}
Expand All @@ -337,6 +340,7 @@ func TestInitiateUploadMountsWithMountFromDifferentRegistry(t *testing.T) {
expectedPath := fmt.Sprintf("/v2/%s/blobs/uploads/", expectedRepo)
expectedQuery := url.Values{
"mount": []string{h.String()},
"from": []string{"baz/bar"},
}.Encode()

img = &mountableImage{
Expand All @@ -361,7 +365,7 @@ func TestInitiateUploadMountsWithMountFromDifferentRegistry(t *testing.T) {
}
defer closer.Close()

_, mounted, err := w.initiateUpload("", h.String())
_, mounted, err := w.initiateUpload("baz/bar", h.String())
if err != nil {
t.Errorf("intiateUpload() = %v", err)
}
Expand Down