Display SHA256 digest only, and in hex

This commit is contained in:
Reynir Björnsson 2021-01-06 11:48:24 +01:00
parent dd55491138
commit 37a916517d
6 changed files with 11 additions and 15 deletions

View file

@ -14,6 +14,8 @@ build: [
depends: [
"builder"
"opium"
"bos"
"hex"
]
synopsis: "Web interface for builder"

View file

@ -92,7 +92,7 @@ let routes (t : Model.t) =
let body = Body.of_string data in
Response.make ~body ()
|> Response.add_header ("Content-type", Magic_mime.lookup file)
|> Response.set_etag (Base64.encode_string digest.sha256)
|> Response.set_etag (Base64.encode_string (Cstruct.to_string digest.sha256))
in
[

View file

@ -1,3 +1,3 @@
(library
(name builder_web)
(libraries builder opium tyxml bos rresult duration))
(libraries builder opium tyxml bos rresult duration hex))

View file

@ -25,8 +25,7 @@ type job_run_info = {
}
type digest = {
sha256 : string;
sha512 : string;
sha256 : Cstruct.t;
}
type t = {
@ -59,8 +58,7 @@ let digest (path, data) =
let module H = Mirage_crypto.Hash in
let data = Cstruct.of_string data in
(path, {
sha256 = H.SHA256.digest data |> Cstruct.to_string;
sha512 = H.SHA512.digest data |> Cstruct.to_string;
sha256 = H.SHA256.digest data;
})
let read_full_with_digests t path run =

View file

@ -9,8 +9,7 @@ type job_run_meta = {
}
type digest = {
sha256 : string;
sha512 : string;
sha256 : Cstruct.t;
}
type job_run_info = {

View file

@ -129,17 +129,14 @@ let job_run
p [txtf "Execution result: %a." Builder.pp_execution_result result];
h3 [txt "Digests of build artifacts"];
dl (List.concat_map
(fun (path, { Model.sha256; sha512 }) -> [
(fun (path, { Model.sha256 }) ->
let (`Hex sha256_hex) = Hex.of_cstruct sha256 in
[
dt [a
~a:[Fmt.kstr a_href "f/%a" Fpath.pp path]
[code [txtf "%a" Fpath.pp path]];
txt "(SHA256)"];
dd [code [txtf "%s" (Base64.encode_string sha256)]];
dt [a
~a:[Fmt.kstr a_href "f/%a" Fpath.pp path]
[code [txtf "%a" Fpath.pp path]];
txt "(SHA512)"];
dd [code [txtf "%s" (Base64.encode_string sha512)]];
dd [code [txt sha256_hex]];
])
digests);
h3 [txt "Job script"];