Repository: ceph/go-ceph
Pull request #203 (2020-03-20 14:12:23)

Complete revive fixes & set revive's exported rule back to error
This series finishes the revive clean-ups that I have been doing. It is probably the largest set of changes as it makes a number of naming changes and adds back aliases for the old names for compatibility.

The last commit changes revive's "exported" rule to an error from it's previous state as a warning. Now, if we miss one of these rules in code review it will fail in the CI.

## Checklist
- [x] Added tests for features and functional changes
- [x] Public functions and types are documented
- [x] Standard formatting is applied to Go code


phlogistonjohn: There are a couple more naming things that will probably need to be cleaned up after this series that the revive tool doesn't care about but now looks a bit inconsistent to me. Trying to avoid boiling the ocean and just get revive enabled with this series.

On a similar note, I was thinking about gathering all the aliases into an "aliases.go" file and adding a build tag that will leave the aliases enabled by default but will can disabled by a build tag. Then one can test if your code has aliases that probably should be converted by setting the build tag and compiling. Thoughts on this idea?

Patch:
diff --git a/.revive.toml b/.revive.toml
index 5e2fdaf..e6677c3 100644
--- a/.revive.toml
+++ b/.revive.toml
@@ -15,7 +15,6 @@ warningCode = 0
 [rule.error-strings]
 [rule.error-naming]
 [rule.exported]
-severity = "warning"
 [rule.if-return]
 [rule.increment-decrement]
 #[rule.var-naming]
diff --git a/rbd/features.go b/rbd/features.go
index 148a7dd..c61b5ef 100644
--- a/rbd/features.go
+++ b/rbd/features.go
@@ -74,21 +74,32 @@ const (
 	FeatureNameDataPool = C.RBD_FEATURE_NAME_DATA_POOL
 
 	// old names for backwards compatibility (unused?)
-	RbdFeatureLayering      = FeatureLayering
-	RbdFeatureStripingV2    = FeatureStripingV2
-	RbdFeatureExclusiveLock = FeatureExclusiveLock
-	RbdFeatureObjectMap     = FeatureObjectMap
-	RbdFeatureFastDiff      = FeatureFastDiff
-	RbdFeatureDeepFlatten   = FeatureDeepFlatten
-	RbdFeatureJournaling    = FeatureJournaling
-	RbdFeatureDataPool      = FeatureDataPool
 
+	// RbdFeatureLayering deprecated alias for FeatureLayering
+	RbdFeatureLayering = FeatureLayering
+	// RbdFeatureStripingV2 deprecated alias for FeatureStripingV2
+	RbdFeatureStripingV2 = FeatureStripingV2
+	// RbdFeatureExclusiveLock deprecated alias for FeatureExclusiveLock
+	RbdFeatureExclusiveLock = FeatureExclusiveLock
+	// RbdFeatureObjectMap deprecated alias for FeatureObjectMap
+	RbdFeatureObjectMap = FeatureObjectMap
+	// RbdFeatureFastDiff deprecated alias for FeatureFastDiff
+	RbdFeatureFastDiff = FeatureFastDiff
+	// RbdFeatureDeepFlatten deprecated alias for FeatureDeepFlatten
+	RbdFeatureDeepFlatten = FeatureDeepFlatten
+	// RbdFeatureJournaling deprecated alias for FeatureJournaling
+	RbdFeatureJournaling = FeatureJournaling
+	// RbdFeatureDataPool deprecated alias for FeatureDataPool
+	RbdFeatureDataPool = FeatureDataPool
+
+	// revive:disable:exported Maybe unused
 	// the following are probably really unused?
 	RbdFeaturesDefault        = uint64(C.RBD_FEATURES_DEFAULT)
 	RbdFeaturesIncompatible   = uint64(C.RBD_FEATURES_INCOMPATIBLE)
 	RbdFeaturesRwIncompatible = uint64(C.RBD_FEATURES_RW_INCOMPATIBLE)
 	RbdFeaturesMutable        = uint64(C.RBD_FEATURES_MUTABLE)
 	RbdFeaturesSingleClient   = uint64(C.RBD_FEATURES_SINGLE_CLIENT)
+	// revive:enable:exported
 )
 
 // FeatureSet is a combination of the bit value for multiple featurs.
@@ -107,6 +118,8 @@ var (
 	}
 )
 
+// FeatureSetFromNames returns a FeatureSet built from flag bits corresponding
+// to the provided feature names.
 func FeatureSetFromNames(names []string) FeatureSet {
 	var fs uint64
 	for _, name := range names {
@@ -115,6 +128,8 @@ func FeatureSetFromNames(names []string) FeatureSet {
 	return FeatureSet(fs)
 }
 
+// Names converts all of the enabled feature bits in the FeatureSet to
+// a slice of strings corresponding to the names for each feature.
 func (fs *FeatureSet) Names() []string {
 	names := []string{}
 
diff --git a/rbd/options.go b/rbd/options.go
index 46ece70..404968a 100644
--- a/rbd/options.go
+++ b/rbd/options.go
@@ -12,34 +12,93 @@ import (
 
 const (
 	// RBD image options.
-	RbdImageOptionFormat            = C.RBD_IMAGE_OPTION_FORMAT
-	RbdImageOptionFeatures          = C.RBD_IMAGE_OPTION_FEATURES
-	RbdImageOptionOrder             = C.RBD_IMAGE_OPTION_ORDER
-	RbdImageOptionStripeUnit        = C.RBD_IMAGE_OPTION_STRIPE_UNIT
-	RbdImageOptionStripeCount       = C.RBD_IMAGE_OPTION_STRIPE_COUNT
-	RbdImageOptionJournalOrder      = C.RBD_IMAGE_OPTION_JOURNAL_ORDER
-	RbdImageOptionJournalSplayWidth = C.RBD_IMAGE_OPTION_JOURNAL_SPLAY_WIDTH
-	RbdImageOptionJournalPool       = C.RBD_IMAGE_OPTION_JOURNAL_POOL
-	RbdImageOptionFeaturesSet       = C.RBD_IMAGE_OPTION_FEATURES_SET
-	RbdImageOptionFeaturesClear     = C.RBD_IMAGE_OPTION_FEATURES_CLEAR
-	RbdImageOptionDataPool          = C.RBD_IMAGE_OPTION_DATA_POOL
+
+	// ImageOptionFormat is the representation of RBD_IMAGE_OPTION_FORMAT from
+	// librbd
+	ImageOptionFormat = C.RBD_IMAGE_OPTION_FORMAT
+	// ImageOptionFeatures is the representation of RBD_IMAGE_OPTION_FEATURES
+	// from librbd
+	ImageOptionFeatures = C.RBD_IMAGE_OPTION_FEATURES
+	// ImageOptionOrder is the representation of RBD_IMAGE_OPTION_ORDER from
+	// librbd
+	ImageOptionOrder = C.RBD_IMAGE_OPTION_ORDER
+	// ImageOptionStripeUnit is the representation of
+	// RBD_IMAGE_OPTION_STRIPE_UNIT from librbd
+	ImageOptionStripeUnit = C.RBD_IMAGE_OPTION_STRIPE_UNIT
+	// ImageOptionStripeCount is the representation of
+	// RBD_IMAGE_OPTION_STRIPE_COUNT from librbd
+	ImageOptionStripeCount = C.RBD_IMAGE_OPTION_STRIPE_COUNT
+	// ImageOptionJournalOrder is the representation of
+	// RBD_IMAGE_OPTION_JOURNAL_ORDER from librbd
+	ImageOptionJournalOrder = C.RBD_IMAGE_OPTION_JOURNAL_ORDER
+	// ImageOptionJournalSplayWidth is the representation of
+	// RBD_IMAGE_OPTION_JOURNAL_SPLAY_WIDTH from librbd
+	ImageOptionJournalSplayWidth = C.RBD_IMAGE_OPTION_JOURNAL_SPLAY_WIDTH
+	// ImageOptionJournalPool is the representation of
+	// RBD_IMAGE_OPTION_JOURNAL_POOL from librbd
+	ImageOptionJournalPool = C.RBD_IMAGE_OPTION_JOURNAL_POOL
+	// ImageOptionFeaturesSet is the representation of
+	// RBD_IMAGE_OPTION_FEATURES_SET from librbd
+	ImageOptionFeaturesSet = C.RBD_IMAGE_OPTION_FEATURES_SET
+	// ImageOptionFeaturesClear is the representation of
+	// RBD_IMAGE_OPTION_FEATURES_CLEAR from librbd
+	ImageOptionFeaturesClear = C.RBD_IMAGE_OPTION_FEATURES_CLEAR
+	// ImageOptionDataPool is the representation of RBD_IMAGE_OPTION_DATA_POOL
+	// from librbd
+	ImageOptionDataPool = C.RBD_IMAGE_OPTION_DATA_POOL
+
+	// RbdImageOptionFormat deprecated alias for ImageOptionFormat
+	RbdImageOptionFormat = ImageOptionFormat
+	// RbdImageOptionFeatures deprecated alias for ImageOptionFeatures
+	RbdImageOptionFeatures = ImageOptionFeatures
+	// RbdImageOptionOrder deprecated alias for ImageOptionOrder
+	RbdImageOptionOrder = ImageOptionOrder
+	// RbdImageOptionStripeUnit deprecated alias for ImageOptionStripeUnit
+	RbdImageOptionStripeUnit = ImageOptionStripeUnit
+	// RbdImageOptionStripeCount deprecated alias for ImageOptionStripeCount
+	RbdImageOptionStripeCount = ImageOptionStripeCount
+	// RbdImageOptionJournalOrder deprecated alias for ImageOptionJournalOrder
+	RbdImageOptionJournalOrder = ImageOptionJournalOrder
+	// RbdImageOptionJournalSplayWidth deprecated alias for
+	RbdImageOptionJournalSplayWidth = ImageOptionJournalSplayWidth
+	// RbdImageOptionJournalPool deprecated alias for ImageOptionJournalPool
+	RbdImageOptionJournalPool = ImageOptionJournalPool
+	// RbdImageOptionFeaturesSet deprecated alias for ImageOptionFeaturesSet
+	RbdImageOptionFeaturesSet = ImageOptionFeaturesSet
+	// RbdImageOptionFeaturesClear deprecated alias for ImageOptionFeaturesClear
+	RbdImageOptionFeaturesClear = ImageOptionFeaturesClear
+	// RbdImageOptionDataPool deprecated alias for ImageOptionDataPool
+	RbdImageOptionDataPool = ImageOptionDataPool
+
 	// introduced with Ceph Mimic
 	//RbdImageOptionFlatten = C.RBD_IMAGE_OPTION_FLATTEN
 )
 
-type RbdImageOptions struct {
+// ImageOptions represents a group of configurable image options.
+type ImageOptions struct {
 	options C.rbd_image_options_t
 }
 
-type RbdImageOption C.int
+// ImageOption values are unique keys for configurable options.
+type ImageOption C.int
+
+// revive:disable:exported Deprecated aliases
+
+// RbdImageOptions deprecated alias for ImageOptions
+type RbdImageOptions = ImageOptions
+
+// RbdImageOption is a deprecated alias for ImageOption
+type RbdImageOption = ImageOption
+
+//revive:enable:exported
 
 // NewRbdImageOptions creates a new RbdImageOptions struct. Call
 // RbdImageOptions.Destroy() to free the resources.
 //
 // Implements:
 //  void rbd_image_options_create(rbd_image_options_t* opts)
-func NewRbdImageOptions() *RbdImageOptions {
-	rio := &RbdImageOptions{}
+func NewRbdImageOptions() *ImageOptions {
+	rio := &ImageOptions{}
 	C.rbd_image_options_create(&rio.options)
 	return rio
 }
@@ -48,7 +107,7 @@ func NewRbdImageOptions() *RbdImageOptions {
 //
 // Implements:
 //  void rbd_image_options_destroy(rbd_image_options_t opts);
-func (rio *RbdImageOptions) Destroy() {
+func (rio *ImageOptions) Destroy() {
 	C.rbd_image_options_destroy(rio.options)
 }
 
@@ -57,7 +116,7 @@ func (rio *RbdImageOptions) Destroy() {
 // Implements:
 //  int rbd_image_options_set_string(rbd_image_options_t opts, int optname,
 //          const char* optval);
-func (rio *RbdImageOptions) SetString(option RbdImageOption, value string) error {
+func (rio *ImageOptions) SetString(option ImageOption, value string) error {
 	c_value := C.CString(value)
 	defer C.free(unsafe.Pointer(c_value))
 
@@ -75,7 +134,7 @@ func (rio *RbdImageOptions) SetString(option RbdImageOption, value string) error
 // Implements:
 //  int rbd_image_options_get_string(rbd_image_options_t opts, int optname,
 //          char* optval, size_t maxlen);
-func (rio *RbdImageOptions) GetString(option RbdImageOption) (string, error) {
+func (rio *ImageOptions) GetString(option ImageOption) (string, error) {
 	value := make([]byte, 4096)
 
 	ret := C.rbd_image_options_get_string(rio.options, C.int(option),
@@ -93,7 +152,7 @@ func (rio *RbdImageOptions) GetString(option RbdImageOption) (string, error) {
 // Implements:
 //  int rbd_image_options_set_uint64(rbd_image_options_t opts, int optname,
 //          const uint64_t optval);
-func (rio *RbdImageOptions) SetUint64(option RbdImageOption, value uint64) error {
+func (rio *ImageOptions) SetUint64(option ImageOption, value uint64) error {
 	c_value := C.uint64_t(value)
 
 	ret := C.rbd_image_options_set_uint64(rio.options, C.int(option), c_value)
@@ -110,7 +169,7 @@ func (rio *RbdImageOptions) SetUint64(option RbdImageOption, value uint64) error
 // Implements:
 //  int rbd_image_options_get_uint64(rbd_image_options_t opts, int optname,
 //          uint64_t* optval);
-func (rio *RbdImageOptions) GetUint64(option RbdImageOption) (uint64, error) {
+func (rio *ImageOptions) GetUint64(option ImageOption) (uint64, error) {
 	var c_value C.uint64_t
 
 	ret := C.rbd_image_options_get_uint64(rio.options, C.int(option), &c_value)
@@ -126,7 +185,7 @@ func (rio *RbdImageOptions) GetUint64(option RbdImageOption) (uint64, error) {
 // Implements:
 //  int rbd_image_options_is_set(rbd_image_options_t opts, int optname,
 //          bool* is_set);
-func (rio *RbdImageOptions) IsSet(option RbdImageOption) (bool, error) {
+func (rio *ImageOptions) IsSet(option ImageOption) (bool, error) {
 	var c_set C.bool
 
 	ret := C.rbd_image_options_is_set(rio.options, C.int(option), &c_set)
@@ -141,7 +200,7 @@ func (rio *RbdImageOptions) IsSet(option RbdImageOption) (bool, error) {
 //
 // Implements:
 //  int rbd_image_options_unset(rbd_image_options_t opts, int optname)
-func (rio *RbdImageOptions) Unset(option RbdImageOption) error {
+func (rio *ImageOptions) Unset(option ImageOption) error {
 	ret := C.rbd_image_options_unset(rio.options, C.int(option))
 	if ret != 0 {
 		return fmt.Errorf("%v, could not unset option %v", getError(ret), option)
@@ -154,7 +213,7 @@ func (rio *RbdImageOptions) Unset(option RbdImageOption) error {
 //
 // Implements:
 //  void rbd_image_options_clear(rbd_image_options_t opts)
-func (rio *RbdImageOptions) Clear() {
+func (rio *ImageOptions) Clear() {
 	C.rbd_image_options_clear(rio.options)
 }
 
@@ -163,7 +222,7 @@ func (rio *RbdImageOptions) Clear() {
 //
 // Implements:
 //  int rbd_image_options_is_empty(rbd_image_options_t opts)
-func (rio *RbdImageOptions) IsEmpty() bool {
+func (rio *ImageOptions) IsEmpty() bool {
 	ret := C.rbd_image_options_is_empty(rio.options)
 	return ret != 0
 }
diff --git a/rbd/rbd.go b/rbd/rbd.go
index 0780b03..02d6c0e 100644
--- a/rbd/rbd.go
+++ b/rbd/rbd.go
@@ -911,7 +911,10 @@ func (image *Image) GetSnapshotNames() (snaps []SnapInfo, err error) {
 	return snaps[:len(snaps)-1], nil
 }
 
-// int rbd_metadata_get(rbd_image_t image, const char *key, char *value, size_t *vallen)
+// GetMetadata returns the metadata string associated with the given key.
+//
+// Implements:
+//  int rbd_metadata_get(rbd_image_t image, const char *key, char *value, size_t *vallen)
 func (image *Image) GetMetadata(key string) (string, error) {
 	if err := image.validate(imageIsOpen); err != nil {
 		return "", err
@@ -938,7 +941,10 @@ func (image *Image) GetMetadata(key string) (string, error) {
 	return string(value), nil
 }
 
-// int rbd_metadata_set(rbd_image_t image, const char *key, const char *value)
+// SetMetadata updates the metadata string associated with the given key.
+//
+// Implements:
+//  int rbd_metadata_set(rbd_image_t image, const char *key, const char *value)
 func (image *Image) SetMetadata(key string, value string) error {
 	if err := image.validate(imageIsOpen); err != nil {
 		return err
@@ -957,7 +963,10 @@ func (image *Image) SetMetadata(key string, value string) error {
 	return nil
 }
 
-// int rbd_metadata_remove(rbd_image_t image, const char *key)
+// RemoveMetadata clears the metadata associated with the given key.
+//
+// Implements:
+//  int rbd_metadata_remove(rbd_image_t image, const char *key)
 func (image *Image) RemoveMetadata(key string) error {
 	if err := image.validate(imageIsOpen); err != nil {
 		return err
@@ -1200,7 +1209,7 @@ func OpenImageByIdReadOnly(ioctx *rados.IOContext, id, snapName string) (*Image,
 // Implements:
 //  int rbd_create4(rados_ioctx_t io, const char *name, uint64_t size,
 //                 rbd_image_options_t opts);
-func CreateImage(ioctx *rados.IOContext, name string, size uint64, rio *RbdImageOptions) error {
+func CreateImage(ioctx *rados.IOContext, name string, size uint64, rio *ImageOptions) error {
 
 	if rio == nil {
 		return RBDError(C.EINVAL)
@@ -1232,7 +1241,7 @@ func RemoveImage(ioctx *rados.IOContext, name string) error {
 //                  const char *p_snapname, rados_ioctx_t c_ioctx,
 //                  const char *c_name, rbd_image_options_t c_opts);
 func CloneImage(ioctx *rados.IOContext, parentName, snapName string,
-	destctx *rados.IOContext, name string, rio *RbdImageOptions) error {
+	destctx *rados.IOContext, name string, rio *ImageOptions) error {
 
 	if rio == nil {
 		return RBDError(C.EINVAL)
@@ -1260,7 +1269,7 @@ func CloneImage(ioctx *rados.IOContext, parentName, snapName string,
 // This function is a convenience wrapper around CloneImage to support cloning
 // from an existing Image.
 func CloneFromImage(parent *Image, snapName string,
-	destctx *rados.IOContext, name string, rio *RbdImageOptions) error {
+	destctx *rados.IOContext, name string, rio *ImageOptions) error {
 
 	if err := parent.validate(imageNeedsIOContext); err != nil {
 		return err


Test patch:
diff --git a/rbd/features_test.go b/rbd/features_test.go
index b876bc3..cd08ea4 100644
--- a/rbd/features_test.go
+++ b/rbd/features_test.go
@@ -25,12 +25,12 @@ func TestGetFeatures(t *testing.T) {
 	name := GetUUID()
 
 	options := NewRbdImageOptions()
-	err = options.SetUint64(RbdImageOptionFeatures, FeatureLayering|FeatureStripingV2)
+	err = options.SetUint64(ImageOptionFeatures, FeatureLayering|FeatureStripingV2)
 	require.NoError(t, err)
 	// FeatureStripingV2 only works with additional arguments
-	err = options.SetUint64(RbdImageOptionStripeUnit, 1024*1024)
+	err = options.SetUint64(ImageOptionStripeUnit, 1024*1024)
 	require.NoError(t, err)
-	err = options.SetUint64(RbdImageOptionStripeCount, 4)
+	err = options.SetUint64(ImageOptionStripeCount, 4)
 	require.NoError(t, err)
 
 	err = CreateImage(ioctx, name, 16*1024*1024, options)
@@ -90,7 +90,7 @@ func TestUpdateFeatures(t *testing.T) {
 
 	options := NewRbdImageOptions()
 	// test with FeatureExclusiveLock as that is mutable
-	err = options.SetUint64(RbdImageOptionFeatures, FeatureExclusiveLock)
+	err = options.SetUint64(ImageOptionFeatures, FeatureExclusiveLock)
 	require.NoError(t, err)
 
 	err = CreateImage(ioctx, name, 16*1024*1024, options)
diff --git a/rbd/options_test.go b/rbd/options_test.go
index 60e642c..74b38a7 100644
--- a/rbd/options_test.go
+++ b/rbd/options_test.go
@@ -13,169 +13,169 @@ func TestRbdOptions(t *testing.T) {
 	options := NewRbdImageOptions()
 	defer options.Destroy()
 
-	err = options.SetUint64(RbdImageOptionFormat, 1)
+	err = options.SetUint64(ImageOptionFormat, 1)
 	assert.NoError(t, err)
-	err = options.SetString(RbdImageOptionFormat, "string not allowed")
+	err = options.SetString(ImageOptionFormat, "string not allowed")
 	assert.Error(t, err)
-	i, err = options.GetUint64(RbdImageOptionFormat)
+	i, err = options.GetUint64(ImageOptionFormat)
 	assert.NoError(t, err)
 	assert.True(t, i == 1)
-	_, err = options.GetString(RbdImageOptionFormat)
+	_, err = options.GetString(ImageOptionFormat)
 	assert.Error(t, err)
-	set, err := options.IsSet(RbdImageOptionFormat)
+	set, err := options.IsSet(ImageOptionFormat)
 	assert.NoError(t, err)
 	assert.True(t, set)
-	err = options.Unset(RbdImageOptionFormat)
+	err = options.Unset(ImageOptionFormat)
 	assert.NoError(t, err)
 
-	err = options.SetUint64(RbdImageOptionFeatures, 1)
+	err = options.SetUint64(ImageOptionFeatures, 1)
 	assert.NoError(t, err)
-	err = options.SetString(RbdImageOptionFeatures, "string not allowed")
+	err = options.SetString(ImageOptionFeatures, "string not allowed")
 	assert.Error(t, err)
-	i, err = options.GetUint64(RbdImageOptionFeatures)
+	i, err = options.GetUint64(ImageOptionFeatures)
 	assert.NoError(t, err)
 	assert.True(t, i == 1)
-	_, err = options.GetString(RbdImageOptionFeatures)
+	_, err = options.GetString(ImageOptionFeatures)
 	assert.Error(t, err)
-	set, err = options.IsSet(RbdImageOptionFeatures)
+	set, err = options.IsSet(ImageOptionFeatures)
 	assert.NoError(t, err)
 	assert.True(t, set)
-	err = options.Unset(RbdImageOptionFeatures)
+	err = options.Unset(ImageOptionFeatures)
 	assert.NoError(t, err)
 
-	err = options.SetUint64(RbdImageOptionOrder, 1)
+	err = options.SetUint64(ImageOptionOrder, 1)
 	assert.NoError(t, err)
-	err = options.SetString(RbdImageOptionOrder, "string not allowed")
+	err = options.SetString(ImageOptionOrder, "string not allowed")
 	assert.Error(t, err)
-	i, err = options.GetUint64(RbdImageOptionOrder)
+	i, err = options.GetUint64(ImageOptionOrder)
 	assert.NoError(t, err)
 	assert.True(t, i == 1)
-	_, err = options.GetString(RbdImageOptionOrder)
+	_, err = options.GetString(ImageOptionOrder)
 	assert.Error(t, err)
-	set, err = options.IsSet(RbdImageOptionOrder)
+	set, err = options.IsSet(ImageOptionOrder)
 	assert.NoError(t, err)
 	assert.True(t, set)
-	err = options.Unset(RbdImageOptionOrder)
+	err = options.Unset(ImageOptionOrder)
 	assert.NoError(t, err)
 
-	err = options.SetUint64(RbdImageOptionStripeUnit, 1)
+	err = options.SetUint64(ImageOptionStripeUnit, 1)
 	assert.NoError(t, err)
-	err = options.SetString(RbdImageOptionStripeUnit, "string not allowed")
+	err = options.SetString(ImageOptionStripeUnit, "string not allowed")
 	assert.Error(t, err)
-	i, err = options.GetUint64(RbdImageOptionStripeUnit)
+	i, err = options.GetUint64(ImageOptionStripeUnit)
 	assert.NoError(t, err)
 	assert.True(t, i == 1)
-	_, err = options.GetString(RbdImageOptionStripeUnit)
+	_, err = options.GetString(ImageOptionStripeUnit)
 	assert.Error(t, err)
-	set, err = options.IsSet(RbdImageOptionStripeUnit)
+	set, err = options.IsSet(ImageOptionStripeUnit)
 	assert.NoError(t, err)
 	assert.True(t, set)
-	err = options.Unset(RbdImageOptionStripeUnit)
+	err = options.Unset(ImageOptionStripeUnit)
 	assert.NoError(t, err)
 
-	err = options.SetUint64(RbdImageOptionStripeCount, 1)
+	err = options.SetUint64(ImageOptionStripeCount, 1)
 	assert.NoError(t, err)
-	err = options.SetString(RbdImageOptionStripeCount, "string not allowed")
+	err = options.SetString(ImageOptionStripeCount, "string not allowed")
 	assert.Error(t, err)
-	i, err = options.GetUint64(RbdImageOptionStripeCount)
+	i, err = options.GetUint64(ImageOptionStripeCount)
 	assert.NoError(t, err)
 	assert.True(t, i == 1)
-	_, err = options.GetString(RbdImageOptionStripeCount)
+	_, err = options.GetString(ImageOptionStripeCount)
 	assert.Error(t, err)
-	set, err = options.IsSet(RbdImageOptionStripeCount)
+	set, err = options.IsSet(ImageOptionStripeCount)
 	assert.NoError(t, err)
 	assert.True(t, set)
-	err = options.Unset(RbdImageOptionStripeCount)
+	err = options.Unset(ImageOptionStripeCount)
 	assert.NoError(t, err)
 
-	err = options.SetUint64(RbdImageOptionJournalOrder, 1)
+	err = options.SetUint64(ImageOptionJournalOrder, 1)
 	assert.NoError(t, err)
-	err = options.SetString(RbdImageOptionJournalOrder, "string not allowed")
+	err = options.SetString(ImageOptionJournalOrder, "string not allowed")
 	assert.Error(t, err)
-	i, err = options.GetUint64(RbdImageOptionJournalOrder)
+	i, err = options.GetUint64(ImageOptionJournalOrder)
 	assert.NoError(t, err)
 	assert.True(t, i == 1)
-	_, err = options.GetString(RbdImageOptionJournalOrder)
+	_, err = options.GetString(ImageOptionJournalOrder)
 	assert.Error(t, err)
-	set, err = options.IsSet(RbdImageOptionJournalOrder)
+	set, err = options.IsSet(ImageOptionJournalOrder)
 	assert.NoError(t, err)
 	assert.True(t, set)
-	err = options.Unset(RbdImageOptionJournalOrder)
+	err = options.Unset(ImageOptionJournalOrder)
 	assert.NoError(t, err)
 
-	err = options.SetUint64(RbdImageOptionJournalSplayWidth, 1)
+	err = options.SetUint64(ImageOptionJournalSplayWidth, 1)
 	assert.NoError(t, err)
-	err = options.SetString(RbdImageOptionJournalSplayWidth, "string not allowed")
+	err = options.SetString(ImageOptionJournalSplayWidth, "string not allowed")
 	assert.Error(t, err)
-	i, err = options.GetUint64(RbdImageOptionJournalSplayWidth)
+	i, err = options.GetUint64(ImageOptionJournalSplayWidth)
 	assert.NoError(t, err)
 	assert.True(t, i == 1)
-	_, err = options.GetString(RbdImageOptionJournalSplayWidth)
+	_, err = options.GetString(ImageOptionJournalSplayWidth)
 	assert.Error(t, err)
-	set, err = options.IsSet(RbdImageOptionJournalSplayWidth)
+	set, err = options.IsSet(ImageOptionJournalSplayWidth)
 	assert.NoError(t, err)
 	assert.True(t, set)
-	err = options.Unset(RbdImageOptionJournalSplayWidth)
+	err = options.Unset(ImageOptionJournalSplayWidth)
 	assert.NoError(t, err)
 
-	err = options.SetUint64(RbdImageOptionJournalPool, 1)
+	err = options.SetUint64(ImageOptionJournalPool, 1)
 	assert.Error(t, err)
-	err = options.SetString(RbdImageOptionJournalPool, "journal")
+	err = options.SetString(ImageOptionJournalPool, "journal")
 	assert.NoError(t, err)
-	_, err = options.GetUint64(RbdImageOptionJournalPool)
+	_, err = options.GetUint64(ImageOptionJournalPool)
 	assert.Error(t, err)
-	s, err = options.GetString(RbdImageOptionJournalPool)
+	s, err = options.GetString(ImageOptionJournalPool)
 	assert.NoError(t, err)
 	assert.True(t, s == "journal")
-	set, err = options.IsSet(RbdImageOptionJournalPool)
+	set, err = options.IsSet(ImageOptionJournalPool)
 	assert.NoError(t, err)
 	assert.True(t, set)
-	err = options.Unset(RbdImageOptionJournalPool)
+	err = options.Unset(ImageOptionJournalPool)
 	assert.NoError(t, err)
 
-	err = options.SetUint64(RbdImageOptionFeaturesSet, 1)
+	err = options.SetUint64(ImageOptionFeaturesSet, 1)
 	assert.NoError(t, err)
-	err = options.SetString(RbdImageOptionFeaturesSet, "string not allowed")
+	err = options.SetString(ImageOptionFeaturesSet, "string not allowed")
 	assert.Error(t, err)
-	i, err = options.GetUint64(RbdImageOptionFeaturesSet)
+	i, err = options.GetUint64(ImageOptionFeaturesSet)
 	assert.NoError(t, err)
 	assert.True(t, i == 1)
-	_, err = options.GetString(RbdImageOptionFeaturesSet)
+	_, err = options.GetString(ImageOptionFeaturesSet)
 	assert.Error(t, err)
-	set, err = options.IsSet(RbdImageOptionFeaturesSet)
+	set, err = options.IsSet(ImageOptionFeaturesSet)
 	assert.NoError(t, err)
 	assert.True(t, set)
-	err = options.Unset(RbdImageOptionFeaturesSet)
+	err = options.Unset(ImageOptionFeaturesSet)
 	assert.NoError(t, err)
 
-	err = options.SetUint64(RbdImageOptionFeaturesClear, 1)
+	err = options.SetUint64(ImageOptionFeaturesClear, 1)
 	assert.NoError(t, err)
-	err = options.SetString(RbdImageOptionFeaturesClear, "string not allowed")
+	err = options.SetString(ImageOptionFeaturesClear, "string not allowed")
 	assert.Error(t, err)
-	i, err = options.GetUint64(RbdImageOptionFeaturesClear)
+	i, err = options.GetUint64(ImageOptionFeaturesClear)
 	assert.NoError(t, err)
 	assert.True(t, i == 1)
-	_, err = options.GetString(RbdImageOptionFeaturesClear)
+	_, err = options.GetString(ImageOptionFeaturesClear)
 	assert.Error(t, err)
-	set, err = options.IsSet(RbdImageOptionFeaturesClear)
+	set, err = options.IsSet(ImageOptionFeaturesClear)
 	assert.NoError(t, err)
 	assert.True(t, set)
-	err = options.Unset(RbdImageOptionFeaturesClear)
+	err = options.Unset(ImageOptionFeaturesClear)
 	assert.NoError(t, err)
 
-	err = options.SetUint64(RbdImageOptionDataPool, 1)
+	err = options.SetUint64(ImageOptionDataPool, 1)
 	assert.Error(t, err)
-	err = options.SetString(RbdImageOptionDataPool, "data")
+	err = options.SetString(ImageOptionDataPool, "data")
 	assert.NoError(t, err)
-	_, err = options.GetUint64(RbdImageOptionDataPool)
+	_, err = options.GetUint64(ImageOptionDataPool)
 	assert.Error(t, err)
-	s, err = options.GetString(RbdImageOptionDataPool)
+	s, err = options.GetString(ImageOptionDataPool)
 	assert.NoError(t, err)
 	assert.True(t, s == "data")
-	set, err = options.IsSet(RbdImageOptionDataPool)
+	set, err = options.IsSet(ImageOptionDataPool)
 	assert.NoError(t, err)
 	assert.True(t, set)
-	err = options.Unset(RbdImageOptionDataPool)
+	err = options.Unset(ImageOptionDataPool)
 	assert.NoError(t, err)
 
 	/* introduced with Ceph Mimic, can not be tested on Luminous
@@ -200,7 +200,7 @@ func TestRbdOptionsClear(t *testing.T) {
 	options := NewRbdImageOptions()
 
 	// set at least one option
-	err := options.SetUint64(RbdImageOptionFormat, 1)
+	err := options.SetUint64(ImageOptionFormat, 1)
 	assert.NoError(t, err)
 
 	empty := options.IsEmpty()
@@ -216,13 +216,13 @@ func TestRbdOptionsClear(t *testing.T) {
 func TestInvalidRbdOption(t *testing.T) {
 	options := NewRbdImageOptions()
 
-	err := options.SetUint64(RbdImageOption(-1), 1)
+	err := options.SetUint64(ImageOption(-1), 1)
 	assert.Error(t, err)
 
-	_, err = options.IsSet(RbdImageOption(-1))
+	_, err = options.IsSet(ImageOption(-1))
 	assert.Error(t, err)
 
-	err = options.Unset(RbdImageOption(-1))
+	err = options.Unset(ImageOption(-1))
 	assert.Error(t, err)
 
 	options.Destroy()
diff --git a/rbd/rbd_test.go b/rbd/rbd_test.go
index f39925c..5e96039 100644
--- a/rbd/rbd_test.go
+++ b/rbd/rbd_test.go
@@ -178,7 +178,7 @@ func TestCreateImageWithOptions(t *testing.T) {
 	assert.NoError(t, err)
 
 	// create image with RbdImageOptionOrder
-	err = options.SetUint64(RbdImageOptionOrder, uint64(testImageOrder))
+	err = options.SetUint64(ImageOptionOrder, uint64(testImageOrder))
 	assert.NoError(t, err)
 	name = GetUUID()
 	err = CreateImage(ioctx, name, testImageSize, options)
@@ -191,7 +191,7 @@ func TestCreateImageWithOptions(t *testing.T) {
 	datapool := GetUUID()
 	err = conn.MakePool(datapool)
 	assert.NoError(t, err)
-	err = options.SetString(RbdImageOptionDataPool, datapool)
+	err = options.SetString(ImageOptionDataPool, datapool)
 	assert.NoError(t, err)
 	name = GetUUID()
 	err = CreateImage(ioctx, name, testImageSize, options)
@@ -635,7 +635,7 @@ func TestReadAt(t *testing.T) {
 	name := GetUUID()
 	options := NewRbdImageOptions()
 	defer options.Destroy()
-	err = options.SetUint64(RbdImageOptionOrder, uint64(testImageOrder))
+	err = options.SetUint64(ImageOptionOrder, uint64(testImageOrder))
 	assert.NoError(t, err)
 	err = CreateImage(ioctx, name, testImageSize, options)
 	require.NoError(t, err)
@@ -714,7 +714,7 @@ func TestImageCopy(t *testing.T) {
 		name := GetUUID()
 		options := NewRbdImageOptions()
 		defer options.Destroy()
-		err = options.SetUint64(RbdImageOptionOrder, uint64(testImageOrder))
+		err = options.SetUint64(ImageOptionOrder, uint64(testImageOrder))
 		assert.NoError(t, err)
 		err = CreateImage(ioctx, name, testImageSize, options)
 		require.NoError(t, err)
@@ -748,7 +748,7 @@ func TestImageCopy(t *testing.T) {
 		name := GetUUID()
 		options := NewRbdImageOptions()
 		defer options.Destroy()
-		err = options.SetUint64(RbdImageOptionOrder, uint64(testImageOrder))
+		err = options.SetUint64(ImageOptionOrder, uint64(testImageOrder))
 		assert.NoError(t, err)
 		err = CreateImage(ioctx, name, testImageSize, options)
 		require.NoError(t, err)
@@ -784,7 +784,7 @@ func TestImageCopy(t *testing.T) {
 
 		options := NewRbdImageOptions()
 		defer options.Destroy()
-		err = options.SetUint64(RbdImageOptionOrder, uint64(testImageOrder))
+		err = options.SetUint64(ImageOptionOrder, uint64(testImageOrder))
 		assert.NoError(t, err)
 		err = CreateImage(ioctx, name, testImageSize, options)
 		require.NoError(t, err)
@@ -806,7 +806,7 @@ func TestImageCopy(t *testing.T) {
 
 		options := NewRbdImageOptions()
 		defer options.Destroy()
-		err = options.SetUint64(RbdImageOptionOrder, uint64(testImageOrder))
+		err = options.SetUint64(ImageOptionOrder, uint64(testImageOrder))
 		assert.NoError(t, err)
 		err = CreateImage(ioctx, name, testImageSize, options)
 		require.NoError(t, err)
@@ -1338,9 +1338,9 @@ func TestCloneImage(t *testing.T) {
 	cloneName := "clone1"
 	options := NewRbdImageOptions()
 	defer options.Destroy()
-	err = options.SetUint64(RbdImageOptionOrder, uint64(testImageOrder))
+	err = options.SetUint64(ImageOptionOrder, uint64(testImageOrder))
 	assert.NoError(t, err)
-	err = options.SetUint64(RbdImageOptionFeatures, 1)
+	err = options.SetUint64(ImageOptionFeatures, 1)
 	assert.NoError(t, err)
 	err = CreateImage(ioctx, imageName, testImageSize, options)
 	assert.NoError(t, err)
@@ -1361,7 +1361,7 @@ func TestCloneImage(t *testing.T) {
 
 		options := NewRbdImageOptions()
 		defer options.Destroy()
-		err = options.SetUint64(RbdImageOptionFormat, uint64(2))
+		err = options.SetUint64(ImageOptionFormat, uint64(2))
 		assert.NoError(t, err)
 		err = CloneImage(ioctx, imageName, snapName, ioctx, cloneName, options)
 		assert.NoError(t, err)
@@ -1383,7 +1383,7 @@ func TestCloneImage(t *testing.T) {
 
 		options := NewRbdImageOptions()
 		defer options.Destroy()
-		err = options.SetUint64(RbdImageOptionFormat, uint64(2))
+		err = options.SetUint64(ImageOptionFormat, uint64(2))
 		assert.NoError(t, err)
 		err = CloneFromImage(image, snapName, ioctx, cloneName, options)
 		assert.NoError(t, err)
@@ -1400,7 +1400,7 @@ func TestCloneImage(t *testing.T) {
 	t.Run("cloneFromImageInvalidCtx", func(t *testing.T) {
 		options := NewRbdImageOptions()
 		defer options.Destroy()
-		err = options.SetUint64(RbdImageOptionFormat, uint64(2))
+		err = options.SetUint64(ImageOptionFormat, uint64(2))
 		assert.NoError(t, err)
 		badImage := GetImage(nil, image.name)
 		err = CloneFromImage(badImage, snapName, ioctx, cloneName, options)
@@ -1435,7 +1435,7 @@ func TestCloneImage(t *testing.T) {
 func quickCreate(ioctx *rados.IOContext, name string, size uint64, order int) error {
 	options := NewRbdImageOptions()
 	defer options.Destroy()
-	err := options.SetUint64(RbdImageOptionOrder, uint64(order))
+	err := options.SetUint64(ImageOptionOrder, uint64(order))
 	if err != nil {
 		return err
 	}
@@ -1455,7 +1455,7 @@ func TestGetId(t *testing.T) {
 	name := GetUUID()
 	options := NewRbdImageOptions()
 	assert.NoError(t,
-		options.SetUint64(RbdImageOptionOrder, uint64(testImageOrder)))
+		options.SetUint64(ImageOptionOrder, uint64(testImageOrder)))
 	err = CreateImage(ioctx, name, testImageSize, options)
 	assert.NoError(t, err)
 
@@ -1493,7 +1493,7 @@ func TestOpenImageById(t *testing.T) {
 	name := GetUUID()
 	options := NewRbdImageOptions()
 	assert.NoError(t,
-		options.SetUint64(RbdImageOptionOrder, uint64(testImageOrder)))
+		options.SetUint64(ImageOptionOrder, uint64(testImageOrder)))
 	err = CreateImage(ioctx, name, testImageSize, options)
 	assert.NoError(t, err)