chore: migrate to transfer module#2075
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe CLI transfer command now delegates graph construction, builder setup, and transformer configuration to the new Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as "CLI"
participant Transfer as "transfer pkg\n(runnable builder + graph)"
participant PM as "plugin registries\n(pm.ComponentVersionRepositoryRegistry\npm.ResourcePluginRegistry)"
participant Cred as "CredentialGraph"
participant Repo as "Repository / Resolver"
CLI->>Transfer: BuildGraphDefinition(component, opts)
Transfer->>Repo: FromResolver(spec)
Transfer->>PM: NewDefaultBuilder(PM, ..., Cred)
PM-->>Transfer: registry references
Transfer->>Transfer: Compose transfer config (Component, ToRepoSpec, FromResolver)
CLI->>Transfer: Process(graph)
Transfer->>Repo: Fetch/Upload artifacts
Transfer->>Cred: Resolve credentials
Transfer-->>CLI: Result/Status
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
cli/cmd/transfer/component-version/cmd.go (1)
157-192: Add a focused regression test for the option translation.This block now owns the CLI contract for
--copy-resources,--upload-as, and the resulting graph setup, but the PR only notes manual verification. A small table-driven test here would catch enum drift before it changes the generated graph unexpectedly.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cli/cmd/transfer/component-version/cmd.go` around lines 157 - 192, Add a focused table-driven regression test that exercises the CLI-to-graph translation for the copy-resources and upload-as flags: for each case set copyResources and FlagUploadAs values (including defaults and both enum variants) and invoke the command code-path that runs the logic producing transfer.BuildGraphDefinition (or call a small extracted helper that encapsulates the block creating copyMode, upTyp and calling transfer.BuildGraphDefinition). Assert the resulting graph definition (tgd) or the Builder inputs include the expected transfer.CopyMode (via WithCopyMode) and transfer.UploadAs (via WithUploadType) values; stub/mocks for repoProvider/creds are fine. Target the symbols copyMode/copyResources, enum.Get(FlagUploadAs), upTyp, transfer.BuildGraphDefinition and the WithCopyMode/WithUploadType options so future enum drift is caught.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cli/go.mod`:
- Line 38: The go.mod adds a new dependency
ocm.software/open-component-model/bindings/go/transfer
v0.0.0-20260326091035-ef0ea1b8f695 but corresponding checksums are missing from
cli/go.sum; fix it by running `go mod tidy` (or `go mod download`) in the cli
module to regenerate and populate cli/go.sum with the checksum entries for the
transfer module, then stage and commit the updated cli/go.sum alongside the
go.mod change.
---
Nitpick comments:
In `@cli/cmd/transfer/component-version/cmd.go`:
- Around line 157-192: Add a focused table-driven regression test that exercises
the CLI-to-graph translation for the copy-resources and upload-as flags: for
each case set copyResources and FlagUploadAs values (including defaults and both
enum variants) and invoke the command code-path that runs the logic producing
transfer.BuildGraphDefinition (or call a small extracted helper that
encapsulates the block creating copyMode, upTyp and calling
transfer.BuildGraphDefinition). Assert the resulting graph definition (tgd) or
the Builder inputs include the expected transfer.CopyMode (via WithCopyMode) and
transfer.UploadAs (via WithUploadType) values; stub/mocks for repoProvider/creds
are fine. Target the symbols copyMode/copyResources, enum.Get(FlagUploadAs),
upTyp, transfer.BuildGraphDefinition and the WithCopyMode/WithUploadType options
so future enum drift is caught.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1457dd6d-0ced-4136-8e10-e6fcd303f859
📒 Files selected for processing (2)
cli/cmd/transfer/component-version/cmd.gocli/go.mod
Signed-off-by: Jakob Möller <contact@jakob-moeller.com>
6ba632e to
45f703f
Compare
|
tested with my handy test script #!/bin/zsh
alias OCM='go run ../../main.go'
REGISTRY="ghcr.io/matthiasbruns/ocm-tutorials"
REGISTRY2="ghcr.io/matthiasbruns/ocm-tutorials-2"
pause() {
echo "\n>>> Next: $1"
echo "--- Press Enter to continue ---"
read
}
# OCM --help
# create constructor.yaml
# https://stefanprodan.github.io/podinfo/podinfo-6.9.1.tgz
cat <<EOF > constructor.yaml
components:
- name: ocm.software/podinfo
version: 6.9.1
provider:
name: ocm.software
resources:
- name: podinfo
version: 6.9.1
type: helmChart
access:
type: helm/v1
helmRepository: https://stefanprodan.github.io/podinfo
helmChart: podinfo-6.9.1.tgz
EOF
CTF_DIR=$(mktemp -d)
echo "Using temporary directory: $CTF_DIR"
pause "Add component version to CTF from constructor.yaml"
# add cv command
OCM add cv --repository ctf::$CTF_DIR --constructor constructor.yaml --skip-reference-digest-processing
HELM_REF="ctf::$CTF_DIR//ocm.software/podinfo:6.9.1"
pause "Create component version ($REGISTRY)"
# transfer
OCM transfer component-version $HELM_REF $REGISTRY --copy-resources --loglevel debug
# pause "Transfer with --upload-as localBlob (OCI registry)"
# transfer --upload-as localBlob
# OCM transfer component-version $HELM_REF $REGISTRY --copy-resources --upload-as localBlob
pause "Transfer with --upload-as ociArtifact (OCI registry)"
# transfer --upload-as ociArtifact
OCM transfer component-version $HELM_REF $REGISTRY --copy-resources --upload-as ociArtifact --loglevel debug
pause "Download resource using OCM CLI"
# rm downloaded if exists
rm -rf downloaded
# downloadCMD resource
OCM download resource https://$REGISTRY//ocm.software/podinfo:6.9.1 --identity name=podinfo,version=6.9.1 --output ./downloadedgood work |
What this PR does / why we need it
this migrates to our new transfer lib in the CLI
Which issue(s) this PR fixes
fix open-component-model/ocm-project#933
Testing
mostly ran a lot of manual back and forth
Verification
ocm