Skip to content

fix!: unwrap standard transfer handler and fix spiff handler #1501

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions api/ocm/tools/transfer/transferhandler/spiff/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ func (h *Handler) TransferResource(src ocm.ComponentVersionAccess, a ocm.AccessS
if !h.opts.IsResourcesByValue() {
return false, nil
}
if h.opts.IsAccessTypeOmitted(a.GetType()) {
return false, nil
}
if h.opts.GetScript() == nil {
return true, nil
}
Expand All @@ -123,6 +126,9 @@ func (h *Handler) TransferSource(src ocm.ComponentVersionAccess, a ocm.AccessSpe
if !h.opts.IsSourcesByValue() {
return false, nil
}
if h.opts.IsAccessTypeOmitted(a.GetType()) {
return false, nil
}
if h.opts.GetScript() == nil {
return true, nil
}
Expand Down
11 changes: 10 additions & 1 deletion cmds/ocm/commands/ocmcmds/components/transfer/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/mandelsoft/vfs/pkg/vfs"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"ocm.software/ocm/api/ocm/compdesc"

clictx "ocm.software/ocm/api/cli"
"ocm.software/ocm/api/ocm"
Expand Down Expand Up @@ -173,7 +174,15 @@ func (a *action) Add(e interface{}) error {
if !ok {
return fmt.Errorf("object of type %T is not a valid comphdlr.Object", e)
}
err := transfer.TransferVersion(a.printer, a.closure, o.ComponentVersion, a.target, a.handler)
sub, h, err := a.handler.TransferVersion(o.Repository, nil, compdesc.NewComponentReference("", o.ComponentVersion.GetName(), o.ComponentVersion.GetVersion(), nil), a.target)
if err != nil {
return errors.Wrapf(err, "cannot transfer component version %s/%s", o.ComponentVersion.GetName(), o.ComponentVersion.GetVersion())
}
if sub == nil {
return fmt.Errorf("cannot transfer component version %s/%s", o.ComponentVersion.GetName(), o.ComponentVersion.GetVersion())
}
Comment on lines +181 to +183
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add an explanation on why we cannot transfer the cv?

err = transfer.TransferVersion(a.printer, a.closure, sub, a.target, h)
sub.Close()
a.errors.Add(err)
if err != nil {
a.printer.Printf("Error: %s\n", err)
Expand Down
Loading