package awsm-lwt
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file cfg.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
open! Import open Lwt.Infix let get ?profile ?aws_access_key_id ?aws_secret_access_key ?region ?output () = let profile : string option = List.reduce_exn ~f:Option.first_some [ profile; Sys.getenv "AWS_DEFAULT_PROFILE" ] in let file path of_string = match path () with | None -> Lwt.return (Ok None) | Some file -> ( file_contents file >>= fun contents -> match of_string contents with | Error e -> Lwt.return (Error e) | Ok r -> Lwt.return (Ok (Some (file, r)))) in match%bind file Awsm.Cfg.Config_file.path Awsm.Cfg.Config_file.of_string with | Error e -> Lwt.return (Error e) | Ok config_file -> ( match%map file Awsm.Cfg.Shared_credentials_file.path Awsm.Cfg.Shared_credentials_file.of_string with | Error e -> Error e | Ok -> Awsm.Cfg.make ?config_file ?shared_credentials_file ?profile ?aws_access_key_id ?aws_secret_access_key ?region ?output ()) ;; let get_exn ?profile ?aws_access_key_id ?aws_secret_access_key ?region ?output () = match%map get ?profile ?aws_access_key_id ?aws_secret_access_key ?region ?output () with | Ok r -> r | Error e -> failwithf "Cfg.get_exn: %s" e () ;;