Skip to content

Commit

Permalink
rbd: update group Stringer method
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Madhu-1 committed Jul 29, 2024
1 parent 0b326b4 commit d12f27e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions internal/rbd/group/volume_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,17 @@ func GetVolumeGroup(
return vg, nil
}

// String makes it easy to include the volumeGroup object in log and error
// messages.
// String returns the image-spec (pool/{namespace}/{name}) format of the group.
func (vg *volumeGroup) String() string {
if vg.name != "" {
return vg.name
if vg.namespace != "" && vg.pool != "" && vg.name != "" {
return fmt.Sprintf("%s/%s/%s", vg.pool, vg.namespace, vg.name)
}

if vg.id != "" {
return vg.id
if vg.name != "" && vg.pool != "" {
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.
Expand Down

0 comments on commit d12f27e

Please sign in to comment.