style: add blank lines between declarations and statement blocks

Separate top-level declarations and multi-line statements with blank
lines, keeping an "if err != nil" check next to the statement it
belongs to. Expand semicolon one-liners, group the nativeTransport
fields by purpose, and format the cgo preamble as readable C.
Apart from the expanded one-liners and the C preamble, the change
is whitespace only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-12-03 18:36:19 +01:00
1 parent ec0297fd23
commit a6fda8f8d3
25 files changed
+929 -41

No files matched your search

+32
View File
@@ -23,124 +23,156 @@ func (c ceph) call(ctx context.Context, args ...string) ([]byte, error) {
if c.endpoint.User != "" {
flags = append(flags, "--name", c.endpoint.User)
}
b, err := output(ctx, c.exec, "ceph", append(flags, args...)...)
if err != nil {
// The first three tokens identify the operation; omit names and metadata
// values, which can contain confidential application information.
return nil, fmt.Errorf("Ceph %s: %w", strings.Join(args[:min(3, len(args))], " "), err)
}
return b, nil
}
func (c ceph) sub(ctx context.Context, op string, extra ...string) ([]byte, error) {
args := []string{"fs", "subvolume", op, c.endpoint.Filesystem, c.endpoint.Subvolume}
args = append(args, extra...)
if c.endpoint.Group != "" {
args = append(args, "--group_name", c.endpoint.Group)
}
return c.call(ctx, args...)
}
func (c ceph) snap(ctx context.Context, op, name string, extra ...string) ([]byte, error) {
args := []string{"fs", "subvolume", "snapshot", op, c.endpoint.Filesystem, c.endpoint.Subvolume}
if name != "" {
args = append(args, name)
}
args = append(args, extra...)
if c.endpoint.Group != "" {
args = append(args, "--group_name", c.endpoint.Group)
}
return c.call(ctx, args...)
}
func (c ceph) snapshotPath(ctx context.Context, name string) (string, error) {
b, err := c.snap(ctx, "getpath", name)
if err != nil {
return "", err
}
p := strings.TrimSpace(string(b))
if c.native {
return nativePath(p)
}
return dataPath(c.endpoint.Mount, p)
}
func (c ceph) names(ctx context.Context) ([]string, error) {
b, err := c.snap(ctx, "ls", "")
if err != nil {
return nil, err
}
var list []struct {
Name string `json:"name"`
}
if err = json.Unmarshal(b, &list); err != nil {
return nil, err
}
names := make([]string, 0, len(list))
for _, s := range list {
if !validName(s.Name) {
return nil, fmt.Errorf("unsupported snapshot name %q", s.Name)
}
names = append(names, s.Name)
}
return names, nil
}
func (c ceph) metadata(ctx context.Context, snapshot string) (map[string]string, error) {
args := []string{"fs", "subvolume"}
if snapshot != "" {
args = append(args, "snapshot")
}
args = append(args, "metadata", "ls", c.endpoint.Filesystem, c.endpoint.Subvolume)
if snapshot != "" {
args = append(args, snapshot)
}
if c.endpoint.Group != "" {
args = append(args, "--group_name", c.endpoint.Group)
}
b, err := c.call(ctx, args...)
if err != nil {
return nil, err
}
var m map[string]string
err = json.Unmarshal(b, &m)
return m, err
}
func (c ceph) setMetadata(ctx context.Context, snapshot string, m map[string]string) error {
// Remove obsolete keys too, including keys removed during a catch-up round.
old, err := c.metadata(ctx, snapshot)
if err != nil {
return err
}
for k := range old {
if _, exists := m[k]; exists {
continue
}
if err := c.metadataCommand(ctx, snapshot, "rm", k, ""); err != nil {
return err
}
}
for k, v := range m {
if ov, ok := old[k]; ok && ov == v {
continue
}
if err := c.metadataCommand(ctx, snapshot, "set", k, v); err != nil {
return err
}
}
return nil
}
func (c ceph) metadataCommand(ctx context.Context, snapshot, op, key, value string) error {
args := []string{"fs", "subvolume"}
if snapshot != "" {
args = append(args, "snapshot")
}
args = append(args, "metadata", op, c.endpoint.Filesystem, c.endpoint.Subvolume)
if snapshot != "" {
args = append(args, snapshot)
}
args = append(args, "--key_name="+key)
if op == "set" {
args = append(args, "--value="+value)
}
if c.endpoint.Group != "" {
args = append(args, "--group_name", c.endpoint.Group)
}
_, err := c.call(ctx, args...)
return err
}