Display SHA256 digest only, and in hex
This commit is contained in:
parent
dd55491138
commit
37a916517d
6 changed files with 11 additions and 15 deletions
|
@ -14,6 +14,8 @@ build: [
|
||||||
depends: [
|
depends: [
|
||||||
"builder"
|
"builder"
|
||||||
"opium"
|
"opium"
|
||||||
|
"bos"
|
||||||
|
"hex"
|
||||||
]
|
]
|
||||||
|
|
||||||
synopsis: "Web interface for builder"
|
synopsis: "Web interface for builder"
|
||||||
|
|
|
@ -92,7 +92,7 @@ let routes (t : Model.t) =
|
||||||
let body = Body.of_string data in
|
let body = Body.of_string data in
|
||||||
Response.make ~body ()
|
Response.make ~body ()
|
||||||
|> Response.add_header ("Content-type", Magic_mime.lookup file)
|
|> 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
|
in
|
||||||
|
|
||||||
[
|
[
|
||||||
|
|
2
lib/dune
2
lib/dune
|
@ -1,3 +1,3 @@
|
||||||
(library
|
(library
|
||||||
(name builder_web)
|
(name builder_web)
|
||||||
(libraries builder opium tyxml bos rresult duration))
|
(libraries builder opium tyxml bos rresult duration hex))
|
||||||
|
|
|
@ -25,8 +25,7 @@ type job_run_info = {
|
||||||
}
|
}
|
||||||
|
|
||||||
type digest = {
|
type digest = {
|
||||||
sha256 : string;
|
sha256 : Cstruct.t;
|
||||||
sha512 : string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type t = {
|
type t = {
|
||||||
|
@ -59,8 +58,7 @@ let digest (path, data) =
|
||||||
let module H = Mirage_crypto.Hash in
|
let module H = Mirage_crypto.Hash in
|
||||||
let data = Cstruct.of_string data in
|
let data = Cstruct.of_string data in
|
||||||
(path, {
|
(path, {
|
||||||
sha256 = H.SHA256.digest data |> Cstruct.to_string;
|
sha256 = H.SHA256.digest data;
|
||||||
sha512 = H.SHA512.digest data |> Cstruct.to_string;
|
|
||||||
})
|
})
|
||||||
|
|
||||||
let read_full_with_digests t path run =
|
let read_full_with_digests t path run =
|
||||||
|
|
|
@ -9,8 +9,7 @@ type job_run_meta = {
|
||||||
}
|
}
|
||||||
|
|
||||||
type digest = {
|
type digest = {
|
||||||
sha256 : string;
|
sha256 : Cstruct.t;
|
||||||
sha512 : string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type job_run_info = {
|
type job_run_info = {
|
||||||
|
|
11
lib/views.ml
11
lib/views.ml
|
@ -129,17 +129,14 @@ let job_run
|
||||||
p [txtf "Execution result: %a." Builder.pp_execution_result result];
|
p [txtf "Execution result: %a." Builder.pp_execution_result result];
|
||||||
h3 [txt "Digests of build artifacts"];
|
h3 [txt "Digests of build artifacts"];
|
||||||
dl (List.concat_map
|
dl (List.concat_map
|
||||||
(fun (path, { Model.sha256; sha512 }) -> [
|
(fun (path, { Model.sha256 }) ->
|
||||||
|
let (`Hex sha256_hex) = Hex.of_cstruct sha256 in
|
||||||
|
[
|
||||||
dt [a
|
dt [a
|
||||||
~a:[Fmt.kstr a_href "f/%a" Fpath.pp path]
|
~a:[Fmt.kstr a_href "f/%a" Fpath.pp path]
|
||||||
[code [txtf "%a" Fpath.pp path]];
|
[code [txtf "%a" Fpath.pp path]];
|
||||||
txt "(SHA256)"];
|
txt "(SHA256)"];
|
||||||
dd [code [txtf "%s" (Base64.encode_string sha256)]];
|
dd [code [txt sha256_hex]];
|
||||||
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)]];
|
|
||||||
])
|
])
|
||||||
digests);
|
digests);
|
||||||
h3 [txt "Job script"];
|
h3 [txt "Job script"];
|
||||||
|
|
Loading…
Reference in a new issue