Skip to content

Commit

Permalink
feat(dl): add oci.download-file-sha256 API (#162)
Browse files Browse the repository at this point in the history
Signed-off-by: wuhuizuo <[email protected]>

Signed-off-by: wuhuizuo <[email protected]>
  • Loading branch information
wuhuizuo authored Jul 22, 2024
1 parent 475c476 commit 599d9c5
Show file tree
Hide file tree
Showing 45 changed files with 666 additions and 137 deletions.
39 changes: 39 additions & 0 deletions dl/design/design.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,45 @@ var _ = Service("oci", func() {
})
})
})

Method("download-file-sha256", func() {
Payload(func() {
Field(1, "repository", String, "OCI artifact repository")
Field(2, "tag", String, "OCI artifact tag")
Field(3, "file", String, "file name in OCI artifact")
Required("repository", "tag", "file")
})

Result(func() {
Attribute("length", Int64, "Length is the downloaded content length in bytes.", func() {
Example(4 * 1024 * 1024)
})
Attribute("contentDisposition", String, "Content-Disposition header for downloading", func() {
Example("attachment; filename*=UTF-8''tidb-v7.5.0-darwin-arm64.tar.gz.sha256")
})
Required("length", "contentDisposition")
})

Error("invalid_file_path", ErrorResult, "Could not locate file for download")
Error("internal_error", ErrorResult, "Fault while processing download.")

HTTP(func() {
GET("/oci-file-sha256/{*repository}")
Param("file:file", String, "file name in OCI artifact")
Param("tag:tag", String, "OCI artifact tag")

// Bypass response body encoder code generation to alleviate need for
// loading the entire response body in memory.
SkipResponseBodyEncodeDecode()

Response(func() {
// Set the content type for binary data
ContentType("application/plain-text")
Header("length:Content-Length")
Header("contentDisposition:Content-Disposition")
})
})
})
})

var _ = Service("ks3", func() {
Expand Down
2 changes: 1 addition & 1 deletion dl/gen/health/client.go

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

2 changes: 1 addition & 1 deletion dl/gen/health/endpoints.go

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

8 changes: 7 additions & 1 deletion dl/gen/health/service.go

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

38 changes: 32 additions & 6 deletions dl/gen/http/cli/server/cli.go

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

2 changes: 1 addition & 1 deletion dl/gen/http/health/client/cli.go

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

2 changes: 1 addition & 1 deletion dl/gen/http/health/client/client.go

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

2 changes: 1 addition & 1 deletion dl/gen/http/health/client/encode_decode.go

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

2 changes: 1 addition & 1 deletion dl/gen/http/health/client/paths.go

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

2 changes: 1 addition & 1 deletion dl/gen/http/health/client/types.go

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

2 changes: 1 addition & 1 deletion dl/gen/http/health/server/encode_decode.go

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

2 changes: 1 addition & 1 deletion dl/gen/http/health/server/paths.go

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

2 changes: 1 addition & 1 deletion dl/gen/http/health/server/server.go

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

2 changes: 1 addition & 1 deletion dl/gen/http/health/server/types.go

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

2 changes: 1 addition & 1 deletion dl/gen/http/ks3/client/cli.go

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

2 changes: 1 addition & 1 deletion dl/gen/http/ks3/client/client.go

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

2 changes: 1 addition & 1 deletion dl/gen/http/ks3/client/encode_decode.go

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

2 changes: 1 addition & 1 deletion dl/gen/http/ks3/client/paths.go

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

2 changes: 1 addition & 1 deletion dl/gen/http/ks3/client/types.go

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

2 changes: 1 addition & 1 deletion dl/gen/http/ks3/server/encode_decode.go

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

2 changes: 1 addition & 1 deletion dl/gen/http/ks3/server/paths.go

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

2 changes: 1 addition & 1 deletion dl/gen/http/ks3/server/server.go

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

2 changes: 1 addition & 1 deletion dl/gen/http/ks3/server/types.go

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

25 changes: 24 additions & 1 deletion dl/gen/http/oci/client/cli.go

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

Loading

0 comments on commit 599d9c5

Please sign in to comment.