From 8b72a72ca2171a8545023ee45ab42de9a78ae5f4 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Mon, 15 Jul 2019 14:55:20 -0400 Subject: Implement backend for 'volume inspect' Begin to separate the internal structures and frontend for inspect on volumes. We can't rely on keeping internal data structures for external presentation - separating presentation and internal data format is good practice. Signed-off-by: Matthew Heon --- libpod/volume.go | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) (limited to 'libpod/volume.go') diff --git a/libpod/volume.go b/libpod/volume.go index 9ed2ff087..bb1e9b6f1 100644 --- a/libpod/volume.go +++ b/libpod/volume.go @@ -1,5 +1,9 @@ package libpod +import ( + "time" +) + // Volume is the type used to create named volumes // TODO: all volumes should be created using this and the Volume API type Volume struct { @@ -15,10 +19,10 @@ type VolumeConfig struct { Name string `json:"name"` Labels map[string]string `json:"labels"` - MountPoint string `json:"mountPoint"` Driver string `json:"driver"` + MountPoint string `json:"mountPoint"` + CreatedTime time.Time `json:"createdAt,omitempty"` Options map[string]string `json:"options"` - Scope string `json:"scope"` IsCtrSpecific bool `json:"ctrSpecific"` UID int `json:"uid"` GID int `json:"gid"` @@ -29,6 +33,18 @@ func (v *Volume) Name() string { return v.config.Name } +// Driver retrieves the volume's driver. +func (v *Volume) Driver() string { + return v.config.Driver +} + +// Scope retrieves the volume's scope. +// Libpod does not implement volume scoping, and this is provided solely for +// Docker compatability. It returns only "local". +func (v *Volume) Scope() string { + return "local" +} + // Labels returns the volume's labels func (v *Volume) Labels() map[string]string { labels := make(map[string]string) @@ -43,11 +59,6 @@ func (v *Volume) MountPoint() string { return v.config.MountPoint } -// Driver returns the volume's driver -func (v *Volume) Driver() string { - return v.config.Driver -} - // Options return the volume's options func (v *Volume) Options() map[string]string { options := make(map[string]string) @@ -58,14 +69,25 @@ func (v *Volume) Options() map[string]string { return options } -// Scope returns the scope of the volume -func (v *Volume) Scope() string { - return v.config.Scope -} - // IsCtrSpecific returns whether this volume was created specifically for a // given container. Images with this set to true will be removed when the // container is removed with the Volumes parameter set to true. func (v *Volume) IsCtrSpecific() bool { return v.config.IsCtrSpecific } + +// UID returns the UID the volume will be created as. +func (v *Volume) UID() int { + return v.config.UID +} + +// GID returns the GID the volume will be created as. +func (v *Volume) GID() int { + return v.config.GID +} + +// CreatedTime returns the time the volume was created at. It was not tracked +// for some time, so older volumes may not contain one. +func (v *Volume) CreatedTime() time.Time { + return v.config.CreatedTime +} -- cgit v1.2.3-54-g00ecf From 582a24dfed12da93a3a5e36ad269787b4ece93fc Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Fri, 2 Aug 2019 15:30:31 -0400 Subject: Fix typos Signed-off-by: Matthew Heon --- libpod/volume.go | 2 +- libpod/volume_inspect.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'libpod/volume.go') diff --git a/libpod/volume.go b/libpod/volume.go index bb1e9b6f1..74126b49b 100644 --- a/libpod/volume.go +++ b/libpod/volume.go @@ -40,7 +40,7 @@ func (v *Volume) Driver() string { // Scope retrieves the volume's scope. // Libpod does not implement volume scoping, and this is provided solely for -// Docker compatability. It returns only "local". +// Docker compatibility. It returns only "local". func (v *Volume) Scope() string { return "local" } diff --git a/libpod/volume_inspect.go b/libpod/volume_inspect.go index 893661a7a..87ed9d340 100644 --- a/libpod/volume_inspect.go +++ b/libpod/volume_inspect.go @@ -19,7 +19,7 @@ type InspectVolumeData struct { // CreatedAt is the date and time the volume was created at. This is not // stored for older Libpod volumes; if so, it will be omitted. CreatedAt time.Time `json:"CreatedAt,omitempty"` - // Status is presently unused and provided only for Docker compatability. + // Status is presently unused and provided only for Docker compatibility. // In the future it will be used to return information on the volume's // current state. Status map[string]string `json:"Status,omitempty"` @@ -27,7 +27,7 @@ type InspectVolumeData struct { // can be passed during volume creation to provide information for third // party tools. Labels map[string]string `json:"Labels"` - // Scope is unused and provided solely for Docker compatability. It is + // Scope is unused and provided solely for Docker compatibility. It is // unconditionally set to "local". Scope string `json:"Scope"` // Options is a set of options that were used when creating the volume. -- cgit v1.2.3-54-g00ecf