Skip to content
Open
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
25 changes: 8 additions & 17 deletions Documentation/reference/api.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion httptransport/api/v1/openapi.etag

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions httptransport/api/v1/openapi.jq
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,16 @@ def responses($r):
],
},
},
"\($path_match)/internal/update_operation/{digest}": {
"\($path_match)/internal/update_operation/{id}": {
delete: {
operationId: "DeleteUpdateOperation",
responses: (responses({})),
responses: (responses({
"204": {
description: "Success",
},
}) | del(.["200"])),
},
parameters: [ param_ref("digest") ],
parameters: [ param_ref("update_operation_id") ],
},
"\($path_match)/internal/update_diff": {
get: {
Expand Down Expand Up @@ -349,6 +353,16 @@ def responses($r):
in: "path",
schema: schema_ref("digest"),
required: true,
},
update_operation_id: {
description: "UUID of the update operation to delete.",
name: "id",
in: "path",
schema: {
type: "string",
format: "uuid",
},
required: true,
}
},
headers: {
Expand Down
23 changes: 14 additions & 9 deletions httptransport/api/v1/openapi.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions httptransport/api/v1/openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions httptransport/matcher_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,15 @@ func (h *MatcherV1) updateOperationHandlerDelete(w http.ResponseWriter, r *http.
id := filepath.Base(path)
uuid, err := uuid.Parse(id)
if err != nil {
slog.WarnContext(ctx, "could not deserialize manifest", "reason", err)
apiError(ctx, w, http.StatusBadRequest, "could not deserialize manifest: %v", err)
slog.WarnContext(ctx, "could not parse update operation id", "reason", err)
apiError(ctx, w, http.StatusBadRequest, "could not parse update operation id: %v", err)
}

_, err = h.srv.DeleteUpdateOperations(ctx, uuid)
if err != nil {
apiError(ctx, w, http.StatusInternalServerError, "could not get update operations: %v", err)
}
// TODO(hank) This should return HTTP 204.
w.WriteHeader(http.StatusNoContent)
}

func init() {
Expand Down
26 changes: 26 additions & 0 deletions httptransport/matcher_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,18 @@ func testUpdateOperationHandlerGet(t *testing.T) {
idStr := "\"" + id.String() + "\""
var called bool
var latestCalled bool
var deleteCalled bool
m := &matcher.Mock{
DeleteUpdateOperations_: func(_ context.Context, refs ...uuid.UUID) (int64, error) {
deleteCalled = true
if got, want := len(refs), 1; got != want {
t.Fatalf("got: %v, want: %v", got, want)
}
if got, want := refs[0], id; got != want {
t.Fatalf("got: %v, want: %v", got, want)
}
return 1, nil
},
LatestUpdateOperation_: func(context.Context, driver.UpdateKind) (uuid.UUID, error) {
return id, nil
},
Expand Down Expand Up @@ -411,4 +422,19 @@ func testUpdateOperationHandlerGet(t *testing.T) {
if etag != idStr {
t.Fatalf("got: %v, want: %v", etag, id.String())
}

req, err = httputil.NewRequestWithContext(ctx, http.MethodDelete, srv.URL+path.Join("/", "internal", "update_operation", id.String()), nil)
if err != nil {
t.Fatalf("failed to create request: %v", err)
}
resp, err = c.Do(req)
if err != nil {
t.Fatalf("failed to make request: %v", err)
}
if resp.StatusCode != http.StatusNoContent {
t.Fatalf("got: %v, want: %v", resp.StatusCode, http.StatusNoContent)
}
if !deleteCalled {
t.Fatalf("got: %v, want: %v", deleteCalled, true)
}
}
Loading