rbd: update group Stringer method

updated the group stringer method
to have pool and namespace for
proper debugging/logging and to
use it with CLI as agrument as well.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2024-07-29 14:47:57 +02:00 committed by mergify[bot]
parent 37970ae212
commit f7c78ae4fe

View File

@ -151,18 +151,17 @@ func GetVolumeGroup(
return vg, nil return vg, nil
} }
// String makes it easy to include the volumeGroup object in log and error // String returns the image-spec (pool/{namespace}/{name}) format of the group.
// messages.
func (vg *volumeGroup) String() string { func (vg *volumeGroup) String() string {
if vg.name != "" { if vg.namespace != "" && vg.pool != "" && vg.name != "" {
return vg.name return fmt.Sprintf("%s/%s/%s", vg.pool, vg.namespace, vg.name)
} }
if vg.id != "" { if vg.name != "" && vg.pool != "" {
return vg.id return fmt.Sprintf("%s/%s", vg.pool, vg.name)
} }
return fmt.Sprintf("<unidentified volume %v>", *vg) return fmt.Sprintf("<unidentified group %v>", *vg)
} }
// GetID returns the CSI-Addons VolumeGroupId of the VolumeGroup. // GetID returns the CSI-Addons VolumeGroupId of the VolumeGroup.