Skip to content

Migrate snapshot file storage v2 - #284

Open
Bxota wants to merge 5 commits into
mainfrom
dev/tleterme/migrate-snapshot-file-storage-v2
Open

Bxota wants to merge 5 commits into
mainfrom
dev/tleterme/migrate-snapshot-file-storage-v2

Conversation

@Bxota

@Bxota Bxota commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

Migrates the file storage share snapshot commands to APIv2
(/v2/publicCloud/project/{projectId}/storage/file/snapshot) and aligns the embedded
cloud_v2.json schema with the published APIv2 schema.

Snapshot routes are project scoped in v2 (they are no longer nested under a share), so:

  • The parent share is now referenced through targetSpec.share.id, and snapshot list
    filters the project-wide listing on it.
  • get, edit and delete check that the requested snapshot really belongs to the share
    given on the command line, so a snapshot cannot be read or deleted through an unrelated
    share ID.
  • The listing columns only read targetSpec and the root resourceStatus, so a snapshot
    that is still being created — and therefore has no currentState yet — is listed like
    any other one instead of aborting the whole listing.
  • A snapshot inherits the region of its parent share: targetSpec has no location, so the
    extra GET on the share that was only there to resolve the region is gone.

Schema alignment (internal/assets/api-schemas/cloud_v2.json):

  • FileStorageSnapshotCurrentState: snapshotSize renamed to size, shareProto and
    shareSize removed (they are not part of the contract).
  • FileStorageSnapshotTargetSpec: location removed, share is the only required field.
  • Request/response examples updated accordingly.

Command changes:

  • snapshot create now goes through the shared creation helper, so it supports --from-file,
    --init-file and --editor, validates the payload client-side, and accepts --wait.
    Creation is asynchronous, so the default output now reports that creation started.
  • snapshot edit <share_id> <snapshot_id> is added (PUT, name and description), with
    --editor and --wait.
  • snapshot delete reports that the snapshot is being deleted, matching its asynchronous
    behavior.
  • The --region persistent flag is removed: it only fed the v1 region discovery, which no
    longer exists now that every file storage route is project scoped.

The detail template only referenced fields that do not exist in the API and crashed on a
snapshot whose currentState is still null (right after creation); it now renders the real
fields and degrades gracefully.

Also removes 17 stale doc/ovhcloud_cloud_storage-file_*.md files left over from the
storage-file -> storage file command rename, and regenerates doc/.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (improvement of existing commands)
  • Breaking change (fix or feature that can break a current behavior)
  • Documentation update

Breaking change: the --region flag of ovhcloud cloud storage file is removed.

Checklist:

  • My code follows the style guidelines of this project
  • I have commented my code
  • I ran go mod tidy
  • I have added tests that prove my fix is effective or that my feature works

Signed-off-by: Thomas Leterme <thomas.leterme@corp.ovh.com>
Signed-off-by: Thomas Leterme <thomas.leterme@corp.ovh.com>
@Bxota
Bxota force-pushed the dev/tleterme/migrate-snapshot-file-storage-v2 branch from b9239bf to b8337df Compare September 9, 2026 14:56
Signed-off-by: Thomas Leterme <thomas.leterme@corp.ovh.com>
@Bxota
Bxota force-pushed the dev/tleterme/migrate-snapshot-file-storage-v2 branch from b8337df to 44b5a56 Compare September 9, 2026 14:58
Signed-off-by: Thomas Leterme <thomas.leterme@corp.ovh.com>
@Bxota
Bxota marked this pull request as ready for review September 10, 2026 14:58
@Bxota
Bxota requested a review from a team as a code owner September 10, 2026 14:58
@Bxota
Bxota marked this pull request as draft September 10, 2026 14:58
Signed-off-by: Thomas Leterme <thomas.leterme@corp.ovh.com>
@Bxota
Bxota marked this pull request as ready for review September 10, 2026 15:17
Edit a snapshot of the given share

```
ovhcloud cloud storage file share snapshot edit <share_id> <snapshot_id> [flags]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the snapshots commands should be at the same level as share to mimic the API path (/publicCloud/project/{projectId}/storage/file/snapshot) => ovhcloud cloud storage file snapshot create|edit|get|…

if err := httpLib.Client.Get(endpoint+"/snapshot", &snapshots); err != nil {
display.OutputError(&flags.OutputFormatConfig, "failed to fetch share snapshots: %s", err)
filters := append([]string{}, flags.GenericFilters...)
filters = append(filters, fmt.Sprintf("targetSpec.share.id==%q", args[0]))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

listing should be global by default (not filtered by parent share), and have an optional argument to add this filter

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants