From bae93ac4abe84270a8d991bb27b8833ff17eb995 Mon Sep 17 00:00:00 2001 From: Seena Fallah Date: Mon, 1 Nov 2021 13:27:16 +0330 Subject: [PATCH] rbd: export image name Signed-off-by: Seena Fallah --- docs/api-status.json | 4 ++++ rbd/rbd.go | 5 +++++ rbd/rbd_test.go | 8 ++++++++ 3 files changed, 17 insertions(+) diff --git a/docs/api-status.json b/docs/api-status.json index a5baa7b..a6128cd 100644 --- a/docs/api-status.json +++ b/docs/api-status.json @@ -1407,6 +1407,10 @@ "name": "Image.GetId", "comment": "GetId returns the internal image ID string.\n\nImplements:\n int rbd_get_id(rbd_image_t image, char *id, size_t id_len);\n" }, + { + "name": "Image.GetName", + "comment": "GetName returns the image name." + }, { "name": "Image.SetSnapshot", "comment": "SetSnapshot updates the rbd image (not the Snapshot) such that the snapshot\nis the source of readable data.\n\nImplements:\n int rbd_snap_set(rbd_image_t image, const char *snapname);\n" diff --git a/rbd/rbd.go b/rbd/rbd.go index 7d5b1ce..e7cd6c7 100644 --- a/rbd/rbd.go +++ b/rbd/rbd.go @@ -951,6 +951,11 @@ func (image *Image) GetId() (string, error) { } +// GetName returns the image name. +func (image *Image) GetName() string { + return image.name +} + // SetSnapshot updates the rbd image (not the Snapshot) such that the snapshot // is the source of readable data. // diff --git a/rbd/rbd_test.go b/rbd/rbd_test.go index 6621637..7ab2e38 100644 --- a/rbd/rbd_test.go +++ b/rbd/rbd_test.go @@ -1641,6 +1641,14 @@ func TestGetId(t *testing.T) { conn.Shutdown() } +func TestGetName(t *testing.T) { + image := Image{ + name: "testImg", + } + imgName := image.GetName() + assert.Equal(t, image.name, imgName) +} + func TestOpenImageById(t *testing.T) { conn := radosConnect(t)