diff --git a/.librarian/puppet/config b/.librarian/puppet/config index c6633a6..6ea0f3f 100644 --- a/.librarian/puppet/config +++ b/.librarian/puppet/config @@ -1,2 +1,2 @@ --- -LIBRARIAN_PUPPET_PATH: "/var/folders/v2/7gc2hhw16tb0cr95bl047bdm0000gn/T/default-ubuntu-1204-sandbox-20150506-61638-1acbdss/modules" +LIBRARIAN_PUPPET_PATH: "/var/folders/s_/1fglf2kj27z2dvld6gbmphl80000gn/T/default-ubuntu-1204-sandbox-20151016-22554-ncxv79/modules" diff --git a/Gemfile b/Gemfile index 73a3025..965c070 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source "https://rubygems.org" group :test do gem "rake" - gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.7.0' + gem "puppet", ENV['PUPPET_VERSION'] || '~> 4.0' gem "rspec", '< 3.2.0' gem "rspec-puppet", :git => 'https://github.com/rodjek/rspec-puppet.git' gem "puppetlabs_spec_helper" @@ -13,7 +13,6 @@ end group :development do gem "travis" gem "travis-lint" - gem "vagrant-wrapper" gem "puppet-blacksmith" gem "guard-rake" end diff --git a/Gemfile.lock b/Gemfile.lock index bf74ec7..30f8140 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,6 +8,7 @@ GIT GEM remote: https://rubygems.org/ specs: + CFPropertyList (2.2.8) activemodel (4.2.1) activesupport (= 4.2.1) builder (~> 3.1) @@ -28,7 +29,8 @@ GEM unf (>= 0.0.5, < 1.0.0) ethon (0.7.3) ffi (>= 1.3.0) - facter (1.7.6) + facter (2.4.4) + CFPropertyList (~> 2.2.6) faraday (0.9.1) multipart-post (>= 1.2, < 3) faraday_middleware (0.9.1) @@ -59,7 +61,7 @@ GEM activesupport (>= 3.0.0, <= 4.2.1) faraday (>= 0.8, < 1.0) multi_json (~> 1.7) - hiera (1.3.4) + hiera (3.0.1) json_pure highline (1.7.2) hitimes (1.2.2) @@ -110,9 +112,9 @@ GEM coderay (~> 1.0) method_source (~> 0.8) slop (~> 3.4) - puppet (3.7.5) - facter (> 1.6, < 3) - hiera (~> 1.0) + puppet (4.2.2) + facter (> 2.0, < 4) + hiera (>= 2.0, < 4) json_pure puppet-blacksmith (3.3.1) puppet (>= 2.7.16) @@ -190,7 +192,6 @@ GEM unf (0.1.4) unf_ext unf_ext (0.0.7.1) - vagrant-wrapper (2.0.2) websocket (1.2.2) PLATFORMS @@ -202,7 +203,7 @@ DEPENDENCIES kitchen-vagrant librarian-puppet metadata-json-lint - puppet (~> 3.7.0) + puppet (~> 4.0) puppet-blacksmith puppetlabs_spec_helper rake @@ -212,4 +213,3 @@ DEPENDENCIES test-kitchen travis travis-lint - vagrant-wrapper diff --git a/fixtures/mirage-web/config.ml b/fixtures/mirage-web/config.ml index a21e03b..b82ac39 100644 --- a/fixtures/mirage-web/config.ml +++ b/fixtures/mirage-web/config.ml @@ -6,8 +6,9 @@ open Mirage *) let mode = try match String.lowercase (Unix.getenv "FS") with - | "fat" -> `Fat - | _ -> `Crunch + | "fat" -> `Fat + | "archive" -> `Archive + | _ -> `Crunch with Not_found -> `Crunch @@ -17,6 +18,7 @@ let fat_ro dir = let fs = match mode with | `Fat -> fat_ro "./htdocs" | `Crunch -> crunch "./htdocs" + | `Archive -> archive_of_files ~dir:"./htdocs" () let net = try match Sys.getenv "NET" with @@ -37,19 +39,14 @@ let stack console = | `Direct, false -> direct_stackv4_with_default_ipv4 console tap0 | `Socket, _ -> socket_stackv4 console [Ipaddr.V4.any] -let server = - conduit_direct (stack default_console) - -let http_srv = - let mode = `TCP (`Port 8080) in - http_server mode server +let http_srv = http_server (conduit_direct ~tls:true (stack default_console)) let main = foreign "Dispatch.Main" (console @-> kv_ro @-> http @-> job) let () = - add_to_ocamlfind_libraries ["re.str"]; - add_to_opam_packages ["re"]; + add_to_ocamlfind_libraries ["re.str"; "magic-mime"]; + add_to_opam_packages ["re"; "magic-mime"]; register "www" [ main $ default_console $ fs $ http_srv diff --git a/fixtures/mirage-web/dispatch.ml b/fixtures/mirage-web/dispatch.ml index c9cca85..bf09de0 100644 --- a/fixtures/mirage-web/dispatch.ml +++ b/fixtures/mirage-web/dispatch.ml @@ -7,12 +7,10 @@ module Main (C:CONSOLE) (FS:KV_RO) (S:Cohttp_lwt.Server) = struct let start c fs http = let read_fs name = - FS.size fs name - >>= function + FS.size fs name >>= function | `Error (FS.Unknown_key _) -> fail (Failure ("read " ^ name)) | `Ok size -> - FS.read fs name 0 (Int64.to_int size) - >>= function + FS.read fs name 0 (Int64.to_int size) >>= function | `Error (FS.Unknown_key _) -> fail (Failure ("read " ^ name)) | `Ok bufs -> return (Cstruct.copyv bufs) in @@ -33,23 +31,27 @@ module Main (C:CONSOLE) (FS:KV_RO) (S:Cohttp_lwt.Server) = struct | [] | [""] -> dispatcher ["index.html"] | segments -> let path = String.concat "/" segments in - try_lwt + Lwt.catch (fun () -> read_fs path >>= fun body -> - S.respond_string ~status:`OK ~body () - with exn -> - S.respond_not_found () + let mime_type = Magic_mime.lookup path in + let headers = Cohttp.Header.init () in + let headers = Cohttp.Header.add headers "content-type" mime_type in + S.respond_string ~status:`OK ~body ~headers () + ) (fun exn -> + S.respond_not_found () + ) in (* HTTP callback *) let callback conn_id request body = - let uri = S.Request.uri request in + let uri = Cohttp.Request.uri request in dispatcher (split_path uri) in let conn_closed (_,conn_id) = let cid = Cohttp.Connection.to_string conn_id in C.log c (Printf.sprintf "conn %s closed" cid) in - http (S.make ~conn_closed ~callback ()) + http (`TCP 8080) (S.make ~conn_closed ~callback ()) end