mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-04 12:10:20 +00:00
a66012a5d4
Bumps [github.com/ceph/go-ceph](https://github.com/ceph/go-ceph) from 0.11.0 to 0.12.0. - [Release notes](https://github.com/ceph/go-ceph/releases) - [Changelog](https://github.com/ceph/go-ceph/blob/master/docs/release-process.md) - [Commits](https://github.com/ceph/go-ceph/compare/v0.11.0...v0.12.0) --- updated-dependencies: - dependency-name: github.com/ceph/go-ceph dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
62 lines
1.5 KiB
Go
62 lines
1.5 KiB
Go
//go:build !luminous && !mimic
|
|
// +build !luminous,!mimic
|
|
|
|
package admin
|
|
|
|
// For APIs that accept extra sets of "boolean" flags we may end up wanting
|
|
// multiple different sets of supported flags. Example: most rm functions
|
|
// accept a force flag, but only subvolume delete has retain snapshots.
|
|
// To make this somewhat uniform in the admin package we define a utility
|
|
// interface and helper function to merge flags with naming options.
|
|
|
|
type flagSet interface {
|
|
flags() map[string]bool
|
|
}
|
|
|
|
type commonRmFlags struct {
|
|
force bool
|
|
}
|
|
|
|
func (f commonRmFlags) flags() map[string]bool {
|
|
o := make(map[string]bool)
|
|
if f.force {
|
|
o["force"] = true
|
|
}
|
|
return o
|
|
}
|
|
|
|
// SubVolRmFlags does not embed other types to simplify and keep the
|
|
// interface with the type flat and simple. At the cost of some code
|
|
// duplication we get a nicer UX for those using the library.
|
|
|
|
// SubVolRmFlags may be used to specify behavior modifying flags when
|
|
// removing sub volumes.
|
|
type SubVolRmFlags struct {
|
|
Force bool
|
|
RetainSnapshots bool
|
|
}
|
|
|
|
func (f SubVolRmFlags) flags() map[string]bool {
|
|
o := make(map[string]bool)
|
|
if f.Force {
|
|
o["force"] = true
|
|
}
|
|
if f.RetainSnapshots {
|
|
o["retain_snapshots"] = true
|
|
}
|
|
return o
|
|
}
|
|
|
|
// mergeFlags combines a set of key-value settings with any type implementing
|
|
// the flagSet interface.
|
|
func mergeFlags(m map[string]string, f flagSet) map[string]interface{} {
|
|
o := make(map[string]interface{})
|
|
for k, v := range m {
|
|
o[k] = v
|
|
}
|
|
for k, v := range f.flags() {
|
|
o[k] = v
|
|
}
|
|
return o
|
|
}
|