Skip to content

feat(cli): make origin import --to a bare filesystem path; document the S3 aws-sync route - #2091

Merged
alpergundogdu merged 3 commits into
mainfrom
claude/decdn-s3-store-import-76a23b
Sep 21, 2026
Merged

alpergundogdu merged 3 commits into
mainfrom
claude/decdn-s3-store-import-76a23b

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Implements Option 0 from #2090.

What changed

decdn origin import --to now takes a plain directory path instead of an
fs:<dir> target string:

decdn origin import -i ./site --to /var/lib/decdn/origin

The filesystem is the only write backend, so the fs: scheme prefix carried no
information — a bare path is what operators expect to type.

Why no native S3 writer

Populating an S3 origin needs no separate writer. The fs and S3 object layouts
are byte-identical — the S3 read backend (crates/cache/src/origin/s3.rs)
keys objects {prefix}{hex[0..2]}/{hex} (+ .obao4) to match the on-disk
shard. So the whole "S3 import" story is an import to a local dir plus one
aws s3 sync:

decdn origin import -i ./site --to /tmp/origin
aws s3 sync /tmp/origin s3://my-bucket/prefix/

Rather than pull the AWS SDK into the deliberately SDK-free publisher CLI
(.github/scripts/check_crate_edges.py, #578), parse_target turns an s3://
target into an error that spells out that exact recipe. A http(s):// target is
rejected the same way (an HTTP origin is a read-only static server). A leftover
fs: prefix is rejected with a hint to drop it, so muscle memory does not
silently seed a directory literally named fs:....

Changes

  • crates/cli/src/commands/origin.rs — parse_target: bare path → fs;
    actionable s3:// (aws-sync recipe) / http(s):// / legacy-fs: errors;
    updated unit tests.
  • crates/common/src/cli/origin.rs — --to arg docs + module docstring.
  • crates/cli/tests/origin_import.rs — call sites use bare paths.
  • adr/appendix-bundles.md — --to grammar + the S3-sync note.

Verification

  • cargo nextest run -p decdn-cli -p decdn-common — 1201 passed.
  • cargo clippy -p decdn-cli -p decdn-common --all-targets --all-features -D warnings — clean.
  • cargo fmt -- --check — clean.
  • pre-commit (fmt, clippy, cargo doc, ADR hygiene, …) — passed.

Closes #2090.

🤖 Generated with Claude Code

… the S3 sync route

`--to` now takes a plain directory path instead of an `fs:<dir>` target
string. The filesystem is the only write backend, so the scheme prefix
carried no information; a bare path is what operators expect to type.

Populating an S3 origin needs no native writer: the fs and S3 object
layouts are byte-identical (the S3 reader keys objects to match the
on-disk shard), so an import to a local directory followed by
`aws s3 sync <dir> s3://<bucket>/<prefix>` fills the bucket with no
renaming. `parse_target` turns an `s3://` target into an error that
spells out that exact recipe, and rejects a `http(s)://` target the same
way, rather than silently writing to a directory named after the URL. A
leftover `fs:` prefix is rejected with a hint to drop it, so muscle
memory does not seed a directory literally named `fs:...`.

Closes #2090.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 21, 2026 08:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The updated ADR text contains a broken inline-code span (split across a newline) that should be fixed before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

This PR updates decdn origin import --to to accept a bare filesystem directory path (removing the fs: scheme), and documents the supported operational path for populating S3 origins via a local import followed by aws s3 sync, keeping the CLI AWS-SDK-free.

Changes:

  • Switch --to parsing from fs:<dir> to a plain directory path and add actionable errors for s3://, http(s)://, and legacy fs: usage.
  • Update CLI docs and unit/integration tests to reflect the new --to grammar.
  • Document the S3 sync workflow in the bundles appendix.
File Description
crates/​common/​src/​cli/​origin.rs Updates origin import/--to documentation and adjusts clap parsing tests to use bare paths in some cases.
crates/​cli/​src/​commands/​origin.rs Updates --to target parsing and error messages; updates unit tests for new behavior.
crates/​cli/​tests/​origin_import.rs Updates integration tests to pass bare directory paths for --to.
adr/​appendix-bundles.md Updates documentation for --to <dir> and the aws s3 sync route for S3 origins.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/common/src/cli/origin.rs Resolved
Comment thread adr/appendix-bundles.md Resolved
Address PR review:
- `OriginImportArgs.to` becomes `Option<PathBuf>` so a non-UTF-8 origin-store
  directory is accepted on Unix, consistent with `--input`. `parse_target`
  sniffs the `s3://` / `http(s)://` / legacy-`fs:` schemes on the UTF-8 view; a
  non-UTF-8 path can be none of them and falls through to the filesystem arm.
- Keep the `aws s3 sync <dir> s3://<bucket>/<prefix>` command on one line in
  appendix-bundles.md so the inline-code span parses under CommonMark.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 83.36% (was 83.37%, ● 0.00%) — 84361/101195 lines

File Coverage Lines Δ
crates/cli/src/commands/origin.rs 86.45% 638/738 ▲ +0.32%
crates/common/src/cli/origin.rs 100.00% 41/41 ● 0.00%
History
Commit Total Δ vs base
83ae6ab 83.37% ● 0.00%
2768481 (HEAD) 83.36% ● 0.00%

The cross-layer `cli_bundle_pull_from_optimize_import_dedups` journey spawns
the real `decdn origin import --optimize` and still passed `--to fs:<dir>`,
which the parser now rejects — the anvil-e2e journeys job caught it. Pass the
store directory directly, matching the new bare-path grammar. Also refresh the
stale `fs:/tmp/origin` report-label fixtures and one `--to fs:/o` parse test to
the bare-path form.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@alpergundogdu
alpergundogdu merged commit dcf8245 into main Sep 21, 2026
25 checks passed
@alpergundogdu
alpergundogdu deleted the claude/decdn-s3-store-import-76a23b branch September 21, 2026 09:37
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.

decdn origin import: support s3:// write target (or document aws s3 sync path)

2 participants