From 26357f47b5d444c09cdaaa58bf14bd6b47bb0141 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Sat, 18 Jun 2022 22:48:09 +0200 Subject: [PATCH] feat: fully implemented volume_list --- ROADMAP.md | 2 +- volumes.v | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 69f4048..68b953f 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -61,7 +61,7 @@ reference](https://docs.docker.com/engine/api/v1.41/). - [ ] Delete unused networks * Volumes - - [ ] List volumes + - [*] List volumes - [ ] Create a volume - [ ] Inspect a volume - [ ] Remove a volume diff --git a/volumes.v b/volumes.v index ae97db1..1ef10b0 100644 --- a/volumes.v +++ b/volumes.v @@ -5,11 +5,23 @@ import net.urllib import json import time +struct UsageData { + size int [json: Size] + ref_count int [json: RefCount] +} + struct Volume { - name string [json: Name] - driver string [json: Driver] - mountpoint string [json: Mountpoint] - created_at time.Time [json: CreatedAt] + created_at_str string [json: CreatedAt] +pub mut: + name string [json: Name] + driver string [json: Driver] + mountpoint string [json: Mountpoint] + created_at time.Time [skip] + status map[string]string [json: Status] + labels map[string]string [json: Labels] + scope string [json: Scope] + options map[string]string [json: Options] + usage_data UsageData [json: UsageData] } struct VolumeListResponse { @@ -27,7 +39,11 @@ pub fn (mut d DockerConn) volume_list() ?VolumeListResponse { return error(data.message) } - data := json.decode(VolumeListResponse, body)? + mut data := json.decode(VolumeListResponse, body)? + + for mut vol in data.volumes { + vol.created_at = time.parse_rfc3339(vol.created_at_str)? + } return data }