Skip to content

Commit

Permalink
Rashell_Docker.tags: compatibility with newer docker.
Browse files Browse the repository at this point in the history
  • Loading branch information
mfp committed Oct 23, 2016
1 parent f6ffab7 commit f55cbca
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/rashell_Docker.ml
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,19 @@ let image_keyword = [
"TAG";
"IMAGE ID";
"CREATED";
"VIRTUAL SIZE";
"\\(VIRTUAL \\)?SIZE";
]

let image_keyword_map =
[
"REPOSITORY", "REPOSITORY";
"TAG", "TAG";
"IMAGE ID", "IMAGE ID";
"CREATED", "CREATED";
"VIRTUAL SIZE", "SIZE";
"SIZE", "SIZE";
]

type field = {
field_name: string;
field_position: int;
Expand All @@ -101,19 +111,23 @@ let error fmt =

let field_make kwlist header =
let open Str in
let pat =
regexp ("\\(" ^ (String.concat "\\|" kwlist) ^ "\\)\\( *\\)")
in
let pat = regexp ("\\(" ^ (String.concat "\\|" kwlist) ^ "\\)") in
let pat2 = regexp "\\( *\\)" in
let rec loop ax i =
match string_match pat header i, i = String.length header with
| false, false -> error "field_make: Protocol mismatch."
| false, true -> ax
| true, _ ->
let orig_name = matched_group 1 header in
let field_name =
try List.assoc orig_name image_keyword_map
with Not_found -> orig_name in
let _ = string_match pat2 header (i + String.length orig_name) in
let field = {
field_name = matched_group 1 header;
field_name;
field_position = i;
field_width =
if matched_group 2 header = "" then
if matched_group 1 header = "" then
None
else
Some (match_end () - 1 - i)
Expand Down

0 comments on commit f55cbca

Please sign in to comment.