1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
open Sexplib.Std
open Sexplib.Sexp
type t = {
id : string;
target : string;
buildkit_options : (string * string) list [@sexp.list];
} [@@deriving sexp]
let t_of_sexp x =
match x with
| List (Atom id :: fields) -> t_of_sexp (List (List [Atom "id"; Atom id] :: fields))
| x -> Fmt.failwith "Invalid secret: %a" Sexplib.Sexp.pp_hum x
let sexp_of_t x =
match sexp_of_t x with
| List (List [Atom "id"; Atom id] :: fields) -> List (Atom id :: fields)
| x -> Fmt.failwith "Invalid secret: %a" Sexplib.Sexp.pp_hum x
let v ?(buildkit_options=[]) ?target id =
let target = Option.value target ~default:("/run/secrets/"^id) in
{ id; target; buildkit_options }